org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED

Here are the examples of the java api org.springframework.http.HttpStatus.METHOD_NOT_ALLOWED taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

67 Examples 7

19 Source : HesperidesScenario.java
with GNU General Public License v3.0
from voyages-sncf-technologies

protected void replacedertMethodNotAllowed() {
    replacedertEquals(HttpStatus.METHOD_NOT_ALLOWED, testContext.getResponseStatusCode());
}

19 Source : StatusResultMatchers.java
with MIT License
from Vip-Augus

/**
 * replacedert the response status code is {@code HttpStatus.METHOD_NOT_ALLOWED} (405).
 */
public ResultMatcher isMethodNotAllowed() {
    return matcher(HttpStatus.METHOD_NOT_ALLOWED);
}

19 Source : DeleteProcessVariableFullTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete empty process variable")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION })
public void deleteEmptyProcessVariable() throws Exception {
    variableModel = new RestProcessVariableModel("", "", "bpm:workflowPackage");
    restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI().getProcesses().getProcessModelByProcessDefId(processModel.getId());
    restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT).descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT).stackTraceIs(RestErrorModel.STACKTRACE);
}

19 Source : DeleteSiteMembershipRequestTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a site memebership request to an empty site id and response is 405")
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
public void adminIsNotAbleToDeleteSiteMembershipRequestWithEmptySiteId() throws Exception {
    SiteModel inexistentSite = new SiteModel("");
    restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(adminUserModel).deleteSiteMembershipRequest(inexistentSite);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT);
}

18 Source : MethodNotAllowedException.java
with Apache License 2.0
from zhuangjinming16

@Override
public int getHttpErrorCode() {
    return HttpStatus.METHOD_NOT_ALLOWED.value();
}

18 Source : GlobalErrorController.java
with Apache License 2.0
from yujunhao8831

@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public ResponseEnreplacedy forbiddenErrorHandler(HttpRequestMethodNotSupportedException e) {
    LogUtils.getLogger().error("error", e);
    return ResponseEnreplacedyPro.status(HttpStatus.METHOD_NOT_ALLOWED, e.getMessage());
}

18 Source : MethodRoutePredicateFactoryTests.java
with Apache License 2.0
from spring-cloud

@Test
public void methodRouteNotMatching() {
    testClient.delete().uri("/multivalueheaders").header("Host", "www.method.org").exchange().expectStatus().value(integer -> integer.equals(HttpStatus.METHOD_NOT_ALLOWED)).expectHeader().valueEquals(HANDLER_MAPPER_HEADER, RoutePredicateHandlerMapping.clreplaced.getSimpleName()).expectHeader().valueEquals(ROUTE_ID_HEADER, "default_path_to_httpbin");
}

18 Source : ReadOnlyException.java
with Apache License 2.0
from provectus

@Override
public HttpStatus getResponseStatusCode() {
    return HttpStatus.METHOD_NOT_ALLOWED;
}

18 Source : ExceptionHandlerAdvice.java
with Apache License 2.0
from justimaging

@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
@ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
public Map<String, Object> handleError(HttpRequestMethodNotSupportedException e) {
    Map<String, Object> data = new HashMap<>();
    data.put("code", HttpStatus.METHOD_NOT_ALLOWED.value());
    data.put("msg", e.getMessage());
    return data;
}

18 Source : GlobalExceptionHandler.java
with Apache License 2.0
from febsteam

@ExceptionHandler(value = HttpRequestMethodNotSupportedException.clreplaced)
public FebsResponse handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
    String message = String.format("该方法不支持%s请求", StringUtils.substringBetween(e.getMessage(), Strings.SINGLE_QUOTE, Strings.SINGLE_QUOTE));
    log.error(message, e.getMessage());
    return new FebsResponse().code(HttpStatus.METHOD_NOT_ALLOWED).message(message);
}

18 Source : RemoveTaskItemTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete existing task item with empty item id")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION })
public void deleteTaskItemEmptyItemId() throws Exception {
    taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndreplacedignTo(replacedigneeUser);
    restClient.authenticateUser(userWhoStartsTask);
    doreplacedent2 = dataContent.usingSite(siteModel).createContent(DoreplacedentType.XML);
    taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(doreplacedent2);
    taskItem.setId("");
    restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT);
}

18 Source : UpdateSiteMembershipRequestTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Update site membership request - empty SiteId")
public void emptySiteIdUpdateSiteMembershipRequest() throws Exception {
    moderatedSite.setId("");
    restClient.authenticateUser(managerUser).withCoreAPI().usingAuthUser().updateSiteMembershipRequest(moderatedSite, updatedMessage);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT).containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT).descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE);
    moderatedSite.setId(moderatedSiteId);
}

18 Source : ConfirmationOfFundsControllerTest.java
with Apache License 2.0
from adorsys

@Test
void createConsentConfirmationOfFunds_piisConsentFromTppNotSupported() {
    // Given
    when(aspspProfileServiceWrapper.getPiisConsentSupported()).thenReturn(PiisConsentSupported.ASPSP_CONSENT_SUPPORTED);
    HttpStatus httpStatus = HttpStatus.METHOD_NOT_ALLOWED;
    when(responseErrorMapper.generateErrorResponse(any(MessageError.clreplaced))).thenReturn(ResponseEnreplacedy.status(httpStatus).build());
    // When
    ResponseEnreplacedy responseEnreplacedy = confirmationOfFundsController.createConsentConfirmationOfFunds(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
    // Then
    replacedertThat(responseEnreplacedy.getStatusCode()).isEqualTo(httpStatus);
}

18 Source : SB405ErrorMapper.java
with Apache License 2.0
from adorsys

@Override
public HttpStatus getErrorStatus() {
    return HttpStatus.METHOD_NOT_ALLOWED;
}

17 Source : ControllerAdvice.java
with MIT License
from woowacourse-teams

@ExceptionHandler({ MethodArgumentNotValidException.clreplaced, MethodNotAllowedException.clreplaced })
public ResponseEnreplacedy<ErrorResponse> badRequestExceptionHandler(Exception exception) {
    ErrorResponse errorResponse = new ErrorResponse(exception.getMessage());
    log.info("MethodArgumentNotValidException, MethodNotAllowedException : {}", exception.getMessage());
    return ResponseEnreplacedy.status(HttpStatus.METHOD_NOT_ALLOWED).body(errorResponse);
}

17 Source : ResourceHandlerFunction.java
with MIT License
from Vip-Augus

@Override
public ServerResponse handle(ServerRequest request) {
    HttpMethod method = request.method();
    if (method != null) {
        switch(method) {
            case GET:
                return EnreplacedyResponse.fromObject(this.resource).build();
            case HEAD:
                Resource headResource = new HeadMethodResource(this.resource);
                return EnreplacedyResponse.fromObject(headResource).build();
            case OPTIONS:
                return ServerResponse.ok().allow(SUPPORTED_METHODS).build();
        }
    }
    return ServerResponse.status(HttpStatus.METHOD_NOT_ALLOWED).allow(SUPPORTED_METHODS).build();
}

17 Source : FeedbackyExceptionHandler.java
with MIT License
from Plajer

@ExceptionHandler(UnsupportedOperationException.clreplaced)
public ResponseEnreplacedy handleUnsupported(UnsupportedOperationException ex) {
    return ResponseEnreplacedy.status(HttpStatus.METHOD_NOT_ALLOWED).body(new RestApiError(HttpStatus.METHOD_NOT_ALLOWED, ex.getMessage()));
}

17 Source : CustomGlobalExceptionHandler.java
with MIT License
from mkyong

@ExceptionHandler(BookUnSupportedFieldPatchException.clreplaced)
public void springUnSupportedFieldPatch(HttpServletResponse response) throws IOException {
    response.sendError(HttpStatus.METHOD_NOT_ALLOWED.value());
}

17 Source : CustomGlobalExceptionHandler.java
with MIT License
from mkyong

/*@ExceptionHandler(BookNotFoundException.clreplaced)
    public ResponseEnreplacedy<CustomErrorResponse> customHandleNotFound(Exception ex, WebRequest request) {

        CustomErrorResponse errors = new CustomErrorResponse();
        errors.setTimestamp(LocalDateTime.now());
        errors.setError(ex.getMessage());
        errors.setStatus(HttpStatus.NOT_FOUND.value());

        return new ResponseEnreplacedy<>(errors, HttpStatus.NOT_FOUND);

    }*/
@ExceptionHandler(BookUnSupportedFieldPatchException.clreplaced)
public void springUnSupportedFieldPatch(HttpServletResponse response) throws IOException {
    response.sendError(HttpStatus.METHOD_NOT_ALLOWED.value());
}

17 Source : CustomizedExceptionHandler.java
with GNU Affero General Public License v3.0
from GIScience

@ExceptionHandler(NotAllowedException.clreplaced)
public final ResponseEnreplacedy<ErrorDetails> handleNotAllowedException(NotAllowedException ex, HttpServletRequest servletRequest) {
    return createExceptionResponse(ex, HttpStatus.METHOD_NOT_ALLOWED, servletRequest);
}

17 Source : ChaosMonkeyRequestScopeRestEndpointIntegration.java
with Apache License 2.0
from codecentric

@Test
void postChaosMonkeySettingsValueObjectreplacedaultPropertiesNull() {
    ResponseEnreplacedy<String> responseEnreplacedy = postChaosMonkeySettings(new ChaosMonkeySettings(new ChaosMonkeyProperties(), null, new WatcherProperties()));
    replacedertEquals(HttpStatus.METHOD_NOT_ALLOWED, responseEnreplacedy.getStatusCode());
}

17 Source : ChaosMonkeyRequestScopeRestEndpointIntegration.java
with Apache License 2.0
from codecentric

@Test
void postChaosMonkeySettingsValueObjecreplacedcherPropertiesNull() {
    ResponseEnreplacedy<String> responseEnreplacedy = postChaosMonkeySettings(new ChaosMonkeySettings(new ChaosMonkeyProperties(), new replacedaultProperties(), null));
    replacedertEquals(HttpStatus.METHOD_NOT_ALLOWED, responseEnreplacedy.getStatusCode());
}

17 Source : ChaosMonkeyRequestScopeRestEndpointIntegration.java
with Apache License 2.0
from codecentric

@Test
void disableChaosMonkeyExecutionNotAllowed() {
    ChaosMonkeyProperties chaosMonkeyProperties = new ChaosMonkeyProperties();
    chaosMonkeyProperties.setEnabled(false);
    chaosMonkeySettings.setChaosMonkeyProperties(chaosMonkeyProperties);
    replacedertEquals(postChaosMonkeySettings(chaosMonkeySettings).getStatusCode(), HttpStatus.METHOD_NOT_ALLOWED);
    replacedertEquals(false, this.chaosMonkeySettings.getChaosMonkeyProperties().isEnabled());
}

17 Source : CommonErrorControllerTest.java
with Apache License 2.0
from bliblidotcom

@Test
void testMethodNotAllowedException() {
    webTestClient.post().uri("/MethodNotAllowedException").exchange().expectStatus().isEqualTo(HttpStatus.METHOD_NOT_ALLOWED);
}

17 Source : DeleteTaskVariableTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete task variable with empty variable name")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION })
public void deleteTaskEmptyVariableName() throws Exception {
    restClient.authenticateUser(userModel);
    RestVariableModel variableModel = RestVariableModel.getRandomTaskVariableModel("local", "d:text");
    restClient.withWorkflowAPI().usingTask(taskModel).addTaskVariable(variableModel);
    variableModel.setName("");
    restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskVariable(variableModel);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsErrorKey(RestErrorModel.DELETE_EMPTY_ARGUMENT).containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT).stackTraceIs(RestErrorModel.STACKTRACE).descriptionURLIs(RestErrorModel.RESTAPIEXPLORER);
}

17 Source : AddProcessVariableCoreTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable is falling in case empty name is provided")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION })
public void failedAddingProcessVariableIfEmptyNameIsProvided() throws Exception {
    processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().addProcess("activitiAdhoc", replacedignee, false, Priority.Normal);
    RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
    variableModel.setName("");
    processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
    restClient.withWorkflowAPI().usingProcess(processModel).updateProcessVariable(variableModel);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT).containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT).descriptionURLIs(RestErrorModel.RESTAPIEXPLORER).stackTraceIs(RestErrorModel.STACKTRACE);
}

17 Source : AddTagTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that you cannot tag a comment and it returns status code 405")
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
public void addTagToAComment() throws Exception {
    FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DoreplacedentType.TEXT_PLAIN);
    String comment = "comment for a tag";
    restClient.authenticateUser(adminUserModel);
    returnedModelComment = restClient.withCoreAPI().usingResource(file).addComment(comment);
    file.setNodeRef(returnedModelComment.getId());
    restClient.withCoreAPI().usingResource(file).addTag(tagValue);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsSummary(RestErrorModel.CANNOT_TAG);
}

17 Source : AddTagTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify that you cannot tag a tag and it returns status code 405")
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
public void addTagToATag() throws Exception {
    FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DoreplacedentType.TEXT_PLAIN);
    restClient.authenticateUser(adminUserModel);
    returnedModel = restClient.withCoreAPI().usingResource(file).addTag(tagValue);
    file.setNodeRef(returnedModel.getId());
    restClient.withCoreAPI().usingResource(file).addTag(tagValue);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsSummary(RestErrorModel.CANNOT_TAG);
}

17 Source : DeleteSiteMemberCoreTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user is not able to remove a member of an empty site id and response is 404")
public void userIsNotAbleToRemoveMembershipOfEmptySiteId() throws Exception {
    SiteModel inexistentSite = new SiteModel("");
    restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(userModel).deleteSiteMember(inexistentSite);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT);
}

17 Source : AddCommentTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that comment cannot be added to another comment")
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION })
public void addCommentToAComment() throws Exception {
    comment = RandomData.getRandomName("comment1");
    FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DoreplacedentType.TEXT_PLAIN);
    RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment);
    file.setNodeRef(commentEntry.getId());
    restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT);
}

17 Source : AddCommentsTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that comments cannot be added to another comment")
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION })
public void addCommentsToAComment() throws JsonToModelConversionException, Exception {
    FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DoreplacedentType.TEXT_PLAIN);
    RestCommentModel commentEntry = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment1);
    file.setNodeRef(commentEntry.getId());
    restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComments(comment1, comment2);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT);
}

17 Source : SB405ErrorMapperTest.java
with Apache License 2.0
from adorsys

@Test
void getErrorStatus_shouldReturn405() {
    // When
    HttpStatus errorStatus = sb405ErrorMapper.getErrorStatus();
    // Then
    replacedertEquals(HttpStatus.METHOD_NOT_ALLOWED, errorStatus);
}

17 Source : PISCANC405ErrorMapperTest.java
with Apache License 2.0
from adorsys

@Test
void getErrorStatus_shouldReturn405() {
    // When
    HttpStatus errorStatus = piscanc405ErrorMapper.getErrorStatus();
    // Then
    replacedertEquals(HttpStatus.METHOD_NOT_ALLOWED, errorStatus);
}

17 Source : PIS405ErrorMapperTest.java
with Apache License 2.0
from adorsys

@Test
void getErrorStatus_shouldReturn405() {
    // When
    HttpStatus errorStatus = pis405ErrorMapper.getErrorStatus();
    // Then
    replacedertEquals(HttpStatus.METHOD_NOT_ALLOWED, errorStatus);
}

17 Source : PIIS405ErrorMapperTest.java
with Apache License 2.0
from adorsys

@Test
void getErrorStatus_shouldReturn405() {
    // When
    HttpStatus errorStatus = piis405ErrorMapper.getErrorStatus();
    // Then
    replacedertEquals(HttpStatus.METHOD_NOT_ALLOWED, errorStatus);
}

17 Source : AIS405ErrorMapperTest.java
with Apache License 2.0
from adorsys

@Test
void getErrorStatus_shouldReturn405() {
    // When
    HttpStatus errorStatus = ais405ErrorMapper.getErrorStatus();
    // Then
    replacedertEquals(HttpStatus.METHOD_NOT_ALLOWED, errorStatus);
}

16 Source : ResourceHandlerFunction.java
with MIT License
from Vip-Augus

@Override
public Mono<ServerResponse> handle(ServerRequest request) {
    HttpMethod method = request.method();
    if (method != null) {
        switch(method) {
            case GET:
                return EnreplacedyResponse.fromObject(this.resource).build().map(response -> response);
            case HEAD:
                Resource headResource = new HeadMethodResource(this.resource);
                return EnreplacedyResponse.fromObject(headResource).build().map(response -> response);
            case OPTIONS:
                return ServerResponse.ok().allow(SUPPORTED_METHODS).body(BodyInserters.empty());
        }
    }
    return ServerResponse.status(HttpStatus.METHOD_NOT_ALLOWED).allow(SUPPORTED_METHODS).body(BodyInserters.empty());
}

16 Source : FeedbackyExceptionHandler.java
with MIT License
from Plajer

@ExceptionHandler(HttpRequestMethodNotSupportedException.clreplaced)
public ResponseEnreplacedy handleNotSupported(HttpRequestMethodNotSupportedException ex) {
    return ResponseEnreplacedy.status(HttpStatus.METHOD_NOT_ALLOWED).body(new RestApiError(HttpStatus.METHOD_NOT_ALLOWED, "Supported methods: " + Arrays.toString(ex.getSupportedMethods())));
}

16 Source : ExceptionTranslatorIT.java
with Apache License 2.0
from oktadeveloper

@Test
void testMethodNotSupported() {
    webTestClient.post().uri("/api/exception-translator-test/access-denied").exchange().expectStatus().isEqualTo(HttpStatus.METHOD_NOT_ALLOWED).expectHeader().contentType(MediaType.APPLICATION_PROBLEM_JSON).expectBody().jsonPath("$.message").isEqualTo("error.http.405").jsonPath("$.detail").isEqualTo("405 METHOD_NOT_ALLOWED \"Request method 'POST' not supported\"");
}

16 Source : AbstractHttpMethodsFilter.java
with Apache License 2.0
from eclipse

private static void sendMethodNotAllowedError(final HttpServletResponse response) throws IOException {
    addCommonResponseHeaders(response);
    response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, HttpStatus.METHOD_NOT_ALLOWED.getReasonPhrase());
}

16 Source : ChaosMonkeyRequestScopeRestEndpointIntegration.java
with Apache License 2.0
from codecentric

@Test
void postChaosMonkeySettingsEqualsNull() {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);
    HttpEnreplacedy<ChaosMonkeySettings> enreplacedy = new HttpEnreplacedy<>(null, headers);
    ResponseEnreplacedy<String> responseEnreplacedy = postHttpEnreplacedy(enreplacedy);
    replacedertEquals(HttpStatus.METHOD_NOT_ALLOWED, responseEnreplacedy.getStatusCode());
}

16 Source : ServletWebErrorHandlerTest.java
with Apache License 2.0
from alimate

private Object[] provideParamsForHandle() {
    return p(p(new HttpMessageNotReadableException("", mock(HttpInputMessage.clreplaced)), INVALID_OR_MISSING_BODY, BAD_REQUEST, emptyMap()), p(new HttpMediaTypeNotAcceptableException(asList(APPLICATION_JSON, MediaType.APPLICATION_PDF)), ServletWebErrorHandler.NOT_ACCEPTABLE, HttpStatus.NOT_ACCEPTABLE, singletonMap(ServletWebErrorHandler.NOT_ACCEPTABLE, singletonList(arg("types", new HashSet<>(asList(APPLICATION_JSON_VALUE, APPLICATION_PDF_VALUE)))))), p(new HttpMediaTypeNotSupportedException(APPLICATION_JSON, emptyList()), NOT_SUPPORTED, UNSUPPORTED_MEDIA_TYPE, singletonMap(NOT_SUPPORTED, singletonList(arg("type", APPLICATION_JSON_VALUE)))), p(new HttpRequestMethodNotSupportedException("POST"), ServletWebErrorHandler.METHOD_NOT_ALLOWED, HttpStatus.METHOD_NOT_ALLOWED, singletonMap(ServletWebErrorHandler.METHOD_NOT_ALLOWED, singletonList(arg("method", "POST")))), p(new MissingServletRequestParameterException("name", "String"), MISSING_PARAMETER, BAD_REQUEST, singletonMap(MISSING_PARAMETER, asList(arg("name", "name"), arg("expected", "String")))), p(new MissingServletRequestPartException("file"), MISSING_PART, BAD_REQUEST, singletonMap(MISSING_PART, singletonList(arg("name", "file")))), p(new NoHandlerFoundException("POST", "/test", null), NO_HANDLER, NOT_FOUND, singletonMap(NO_HANDLER, singletonList(arg("path", "/test")))), p(new ServletException(), "unknown_error", INTERNAL_SERVER_ERROR, emptyMap()));
}

16 Source : UpdateTagTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with empty id")
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
public void adminIsNotAbleToUpdateTagWithEmptyId() throws Exception {
    RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(doreplacedent).addTag(RandomData.getRandomName("tag"));
    tag.setId("");
    restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag"));
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT);
}

16 Source : UpdateSiteMemberTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION })
@TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify if update site member request returns status code 405 when empty personId is used")
public void updateSiteMemberUsingEmptyPersonId() throws Exception {
    UserModel emptyUser = new UserModel("", DataUser.PreplacedWORD);
    emptyUser.setUserRole(UserRole.SiteCollaborator);
    restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).updateSiteMember(emptyUser);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT);
}

16 Source : AddCommentTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that request using nodeId that is neither doreplacedent or folder returns 405")
@Bug(id = "MNT-16904")
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION })
public void addCommentUsingResourceThatIsNotFileOrFolder() throws Exception {
    comment = RandomData.getRandomName("comment1");
    LinkModel link = dataLink.usingAdmin().usingSite(siteModel).createRandomLink();
    FileModel fileWithNodeRefFromLink = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
    fileWithNodeRefFromLink = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DoreplacedentType.TEXT_PLAIN);
    fileWithNodeRefFromLink.setNodeRef(link.getNodeRef());
    restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).withCoreAPI().usingResource(fileWithNodeRefFromLink).addComment(comment);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED);
}

16 Source : AddCommentTests.java
with GNU Lesser General Public License v3.0
from Alfresco

@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION, description = "Verify that comment cannot be added to a tag")
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.REGRESSION })
public void addCommentToATag() throws Exception {
    comment = RandomData.getRandomName("comment1");
    FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DoreplacedentType.TEXT_PLAIN);
    RestTagModel tag = restClient.withCoreAPI().usingResource(doreplacedent).addTag("randomTag");
    file.setNodeRef(tag.getId());
    restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addComment(comment);
    restClient.replacedertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).replacedertLastError().containsSummary(RestErrorModel.CANNOT_COMMENT);
}

15 Source : AbstractSockJsService.java
with MIT License
from Vip-Augus

protected void sendMethodNotAllowed(ServerHttpResponse response, HttpMethod... httpMethods) {
    logger.warn("Sending Method Not Allowed (405)");
    response.setStatusCode(HttpStatus.METHOD_NOT_ALLOWED);
    response.getHeaders().setAllow(new LinkedHashSet<>(Arrays.asList(httpMethods)));
}

15 Source : ReadOnlyModeTests.java
with Apache License 2.0
from provectus

@Test
public void shouldNotUpdateTopicForReadonlyCluster() {
    var topicName = UUID.randomUUID().toString();
    webTestClient.patch().uri("/api/clusters/{clusterName}/topics/{topicName}", SECOND_LOCAL, topicName).bodyValue(new TopicFormData().name(topicName).parreplacedions(1).replicationFactor(1).configs(Map.of())).exchange().expectStatus().isEqualTo(HttpStatus.METHOD_NOT_ALLOWED);
}

15 Source : ReadOnlyModeTests.java
with Apache License 2.0
from provectus

@Test
public void shouldNotCreateTopicForReadonlyCluster() {
    var topicName = UUID.randomUUID().toString();
    webTestClient.post().uri("/api/clusters/{clusterName}/topics", SECOND_LOCAL).bodyValue(new TopicFormData().name(topicName).parreplacedions(1).replicationFactor(1).configs(Map.of())).exchange().expectStatus().isEqualTo(HttpStatus.METHOD_NOT_ALLOWED);
}

15 Source : AbstractSockJsService.java
with Apache License 2.0
from langtianya

protected void sendMethodNotAllowed(ServerHttpResponse response, HttpMethod... httpMethods) {
    logger.warn("Sending Method Not Allowed (405)");
    response.setStatusCode(HttpStatus.METHOD_NOT_ALLOWED);
    response.getHeaders().setAllow(new HashSet<HttpMethod>(Arrays.asList(httpMethods)));
}

See More Examples