Java Code Examples for org.springframework.web.bind.annotation.RequestMethod#name()
The following examples show how to use
org.springframework.web.bind.annotation.RequestMethod#name() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: springdoc-openapi File: DataRestOperationBuilder.java License: Apache License 2.0 | 6 votes |
/** * Add operation description. * * @param operation the operation * @param requestMethod the request method * @param entity the entity */ private void addOperationDescription(Operation operation, RequestMethod requestMethod, String entity) { switch (requestMethod) { case GET: operation.setDescription("get-" + entity); break; case POST: operation.setDescription("create-" + entity); break; case DELETE: operation.setDescription("delete-" + entity); break; case PUT: operation.setDescription("update-" + entity); break; case PATCH: operation.setDescription("patch-" + entity); break; default: throw new IllegalArgumentException(requestMethod.name()); } }
Example 2
Source Project: spring-analysis-note File: RequestMethodsRequestConditionTests.java License: MIT License | 5 votes |
@Test public void getMatchingConditionWithEmptyConditions() { RequestMethodsRequestCondition condition = new RequestMethodsRequestCondition(); for (RequestMethod method : RequestMethod.values()) { if (method != OPTIONS) { HttpServletRequest request = new MockHttpServletRequest(method.name(), ""); assertNotNull(condition.getMatchingCondition(request)); } } testNoMatch(condition, OPTIONS); }
Example 3
Source Project: springdoc-openapi File: DataRestResponseBuilder.java License: Apache License 2.0 | 5 votes |
/** * Add response. * * @param requestMethod the request method * @param operationPath the operation path * @param apiResponses the api responses * @param apiResponse the api response */ private void addResponse(RequestMethod requestMethod, String operationPath, ApiResponses apiResponses, ApiResponse apiResponse) { switch (requestMethod) { case GET: addResponse200(apiResponses, apiResponse); if (operationPath.contains("/{id}")) addResponse404(apiResponses); break; case POST: apiResponses.put(String.valueOf(HttpStatus.CREATED.value()), apiResponse.description(HttpStatus.CREATED.getReasonPhrase())); break; case DELETE: addResponse204(apiResponses); addResponse404(apiResponses); break; case PUT: addResponse200(apiResponses, apiResponse); apiResponses.put(String.valueOf(HttpStatus.CREATED.value()), new ApiResponse().content(apiResponse.getContent()).description(HttpStatus.CREATED.getReasonPhrase())); addResponse204(apiResponses); break; case PATCH: addResponse200(apiResponses, apiResponse); addResponse204(apiResponses); break; default: throw new IllegalArgumentException(requestMethod.name()); } }
Example 4
Source Project: java-technology-stack File: RequestMethodsRequestConditionTests.java License: MIT License | 5 votes |
@Test public void getMatchingConditionWithEmptyConditions() { RequestMethodsRequestCondition condition = new RequestMethodsRequestCondition(); for (RequestMethod method : RequestMethod.values()) { if (method != OPTIONS) { HttpServletRequest request = new MockHttpServletRequest(method.name(), ""); assertNotNull(condition.getMatchingCondition(request)); } } testNoMatch(condition, OPTIONS); }
Example 5
Source Project: spring-analysis-note File: RequestMethodsRequestConditionTests.java License: MIT License | 4 votes |
private void testMatch(RequestMethodsRequestCondition condition, RequestMethod method) { MockHttpServletRequest request = new MockHttpServletRequest(method.name(), ""); RequestMethodsRequestCondition actual = condition.getMatchingCondition(request); assertNotNull(actual); assertEquals(Collections.singleton(method), actual.getContent()); }
Example 6
Source Project: spring-analysis-note File: RequestMethodsRequestConditionTests.java License: MIT License | 4 votes |
private void testNoMatch(RequestMethodsRequestCondition condition, RequestMethod method) { MockHttpServletRequest request = new MockHttpServletRequest(method.name(), ""); assertNull(condition.getMatchingCondition(request)); }
Example 7
Source Project: java-technology-stack File: RequestMethodsRequestConditionTests.java License: MIT License | 4 votes |
private void testMatch(RequestMethodsRequestCondition condition, RequestMethod method) { MockHttpServletRequest request = new MockHttpServletRequest(method.name(), ""); RequestMethodsRequestCondition actual = condition.getMatchingCondition(request); assertNotNull(actual); assertEquals(Collections.singleton(method), actual.getContent()); }
Example 8
Source Project: java-technology-stack File: RequestMethodsRequestConditionTests.java License: MIT License | 4 votes |
private void testNoMatch(RequestMethodsRequestCondition condition, RequestMethod method) { MockHttpServletRequest request = new MockHttpServletRequest(method.name(), ""); assertNull(condition.getMatchingCondition(request)); }