use of cn.taketoday.http.HttpMethod.HEAD in project today-infrastructure by TAKETODAY.
the class RequestMappingInfoTests method compareToWithHttpHeadMapping.
@Test
// SPR-14383
void compareToWithHttpHeadMapping() {
MockHttpServletRequest request = initRequest("GET", "/", false);
request.setMethod("HEAD");
request.addHeader("Accept", "application/json");
RequestMappingInfo noMethods = RequestMappingInfo.paths().build();
RequestMappingInfo getMethod = RequestMappingInfo.paths().methods(GET).produces("application/json").build();
RequestMappingInfo headMethod = RequestMappingInfo.paths().methods(HEAD).build();
Comparator<RequestMappingInfo> comparator = (info, otherInfo) -> info.compareTo(otherInfo, new ServletRequestContext(null, request, null));
List<RequestMappingInfo> list = asList(noMethods, getMethod, headMethod);
Collections.shuffle(list);
list.sort(comparator);
assertThat(list.get(0)).isEqualTo(headMethod);
assertThat(list.get(1)).isEqualTo(getMethod);
assertThat(list.get(2)).isEqualTo(noMethods);
}
use of cn.taketoday.http.HttpMethod.HEAD in project today-framework by TAKETODAY.
the class RequestMappingInfoTests method compareToWithHttpHeadMapping.
@Test
// SPR-14383
void compareToWithHttpHeadMapping() {
MockHttpServletRequest request = initRequest("GET", "/", false);
request.setMethod("HEAD");
request.addHeader("Accept", "application/json");
RequestMappingInfo noMethods = RequestMappingInfo.paths().build();
RequestMappingInfo getMethod = RequestMappingInfo.paths().methods(GET).produces("application/json").build();
RequestMappingInfo headMethod = RequestMappingInfo.paths().methods(HEAD).build();
Comparator<RequestMappingInfo> comparator = (info, otherInfo) -> info.compareTo(otherInfo, new ServletRequestContext(null, request, null));
List<RequestMappingInfo> list = asList(noMethods, getMethod, headMethod);
Collections.shuffle(list);
list.sort(comparator);
assertThat(list.get(0)).isEqualTo(headMethod);
assertThat(list.get(1)).isEqualTo(getMethod);
assertThat(list.get(2)).isEqualTo(noMethods);
}
Aggregations