use of org.springframework.web.reactive.result.method.RequestMappingInfo in project spring-framework by spring-projects.
the class RequestMappingInfoTests method equals.
@Test
public void equals() {
RequestMappingInfo info1 = paths("/foo").methods(RequestMethod.GET).params("foo=bar").headers("foo=bar").consumes("text/plain").produces("text/plain").customCondition(new ParamsRequestCondition("customFoo=customBar")).build();
RequestMappingInfo info2 = paths("/foo").methods(RequestMethod.GET).params("foo=bar").headers("foo=bar").consumes("text/plain").produces("text/plain").customCondition(new ParamsRequestCondition("customFoo=customBar")).build();
assertEquals(info1, info2);
assertEquals(info1.hashCode(), info2.hashCode());
info2 = paths("/foo", "/NOOOOOO").methods(RequestMethod.GET).params("foo=bar").headers("foo=bar").consumes("text/plain").produces("text/plain").customCondition(new ParamsRequestCondition("customFoo=customBar")).build();
assertFalse(info1.equals(info2));
assertNotEquals(info1.hashCode(), info2.hashCode());
info2 = paths("/foo").methods(RequestMethod.GET, RequestMethod.POST).params("foo=bar").headers("foo=bar").consumes("text/plain").produces("text/plain").customCondition(new ParamsRequestCondition("customFoo=customBar")).build();
assertFalse(info1.equals(info2));
assertNotEquals(info1.hashCode(), info2.hashCode());
info2 = paths("/foo").methods(RequestMethod.GET).params("/NOOOOOO").headers("foo=bar").consumes("text/plain").produces("text/plain").customCondition(new ParamsRequestCondition("customFoo=customBar")).build();
assertFalse(info1.equals(info2));
assertNotEquals(info1.hashCode(), info2.hashCode());
info2 = paths("/foo").methods(RequestMethod.GET).params("foo=bar").headers("/NOOOOOO").consumes("text/plain").produces("text/plain").customCondition(new ParamsRequestCondition("customFoo=customBar")).build();
assertFalse(info1.equals(info2));
assertNotEquals(info1.hashCode(), info2.hashCode());
info2 = paths("/foo").methods(RequestMethod.GET).params("foo=bar").headers("foo=bar").consumes("text/NOOOOOO").produces("text/plain").customCondition(new ParamsRequestCondition("customFoo=customBar")).build();
assertFalse(info1.equals(info2));
assertNotEquals(info1.hashCode(), info2.hashCode());
info2 = paths("/foo").methods(RequestMethod.GET).params("foo=bar").headers("foo=bar").consumes("text/plain").produces("text/NOOOOOO").customCondition(new ParamsRequestCondition("customFoo=customBar")).build();
assertFalse(info1.equals(info2));
assertNotEquals(info1.hashCode(), info2.hashCode());
info2 = paths("/foo").methods(RequestMethod.GET).params("foo=bar").headers("foo=bar").consumes("text/plain").produces("text/plain").customCondition(new ParamsRequestCondition("customFoo=NOOOOOO")).build();
assertFalse(info1.equals(info2));
assertNotEquals(info1.hashCode(), info2.hashCode());
}
use of org.springframework.web.reactive.result.method.RequestMappingInfo in project spring-framework by spring-projects.
the class RequestMappingInfoTests method matchCustomCondition.
@Test
public void matchCustomCondition() {
ServerWebExchange exchange = MockServerHttpRequest.get("/foo?foo=bar").toExchange();
RequestMappingInfo info = paths("/foo").params("foo=bar").build();
RequestMappingInfo match = info.getMatchingCondition(exchange);
assertNotNull(match);
info = paths("/foo").params("foo!=bar").customCondition(new ParamsRequestCondition("foo!=bar")).build();
match = info.getMatchingCondition(exchange);
assertNull(match);
}
use of org.springframework.web.reactive.result.method.RequestMappingInfo in project spring-framework by spring-projects.
the class RequestMappingInfoTests method compareTwoHttpMethodsOneParam.
@Test
public void compareTwoHttpMethodsOneParam() {
RequestMappingInfo none = paths().build();
RequestMappingInfo oneMethod = paths().methods(RequestMethod.GET).build();
RequestMappingInfo oneMethodOneParam = paths().methods(RequestMethod.GET).params("foo").build();
ServerWebExchange exchange = MockServerHttpRequest.get("/foo").toExchange();
Comparator<RequestMappingInfo> comparator = (info, otherInfo) -> info.compareTo(otherInfo, exchange);
List<RequestMappingInfo> list = asList(none, oneMethod, oneMethodOneParam);
Collections.shuffle(list);
list.sort(comparator);
assertEquals(oneMethodOneParam, list.get(0));
assertEquals(oneMethod, list.get(1));
assertEquals(none, list.get(2));
}
use of org.springframework.web.reactive.result.method.RequestMappingInfo in project spring-framework by spring-projects.
the class RequestMappingInfoTests method matchProducesCondition.
@Test
public void matchProducesCondition() {
ServerWebExchange exchange = MockServerHttpRequest.get("/foo").accept(MediaType.TEXT_PLAIN).toExchange();
RequestMappingInfo info = paths("/foo").produces("text/plain").build();
RequestMappingInfo match = info.getMatchingCondition(exchange);
assertNotNull(match);
info = paths("/foo").produces("application/xml").build();
match = info.getMatchingCondition(exchange);
assertNull(match);
}
use of org.springframework.web.reactive.result.method.RequestMappingInfo in project spring-framework by spring-projects.
the class RequestMappingInfoTests method createEmpty.
// TODO: CORS pre-flight (see @Ignored)
@Test
public void createEmpty() {
RequestMappingInfo info = paths().build();
assertEquals(0, info.getPatternsCondition().getPatterns().size());
assertEquals(0, info.getMethodsCondition().getMethods().size());
assertEquals(true, info.getConsumesCondition().isEmpty());
assertEquals(true, info.getProducesCondition().isEmpty());
assertNotNull(info.getParamsCondition());
assertNotNull(info.getHeadersCondition());
assertNull(info.getCustomCondition());
}
Aggregations