use of cn.taketoday.web.util.pattern.PathPatternParser in project today-infrastructure by TAKETODAY.
the class RequestMappingInfoTests method mutate.
@Test
void mutate() {
RequestMappingInfo.BuilderConfiguration options = new RequestMappingInfo.BuilderConfiguration();
options.setPatternParser(new PathPatternParser());
RequestMappingInfo info1 = RequestMappingInfo.paths("/foo").methods(GET).headers("h1=hv1").params("q1=qv1").consumes("application/json").produces("application/json").mappingName("testMapping").options(options).build();
RequestMappingInfo info2 = info1.mutate().produces("application/hal+json").build();
assertThat(info2.getName()).isEqualTo(info1.getName());
assertThat(info2.getPathPatternsCondition()).isEqualTo(info1.getPathPatternsCondition());
assertThat(info2.getHeadersCondition()).isEqualTo(info1.getHeadersCondition());
assertThat(info2.getParamsCondition()).isEqualTo(info1.getParamsCondition());
assertThat(info2.getConsumesCondition()).isEqualTo(info1.getConsumesCondition());
assertThat(info2.getProducesCondition().getProducibleMediaTypes()).containsOnly(MediaType.parseMediaType("application/hal+json"));
}
use of cn.taketoday.web.util.pattern.PathPatternParser in project today-infrastructure by TAKETODAY.
the class PathPatternsRequestConditionTests method matchTrailingSlash.
@Test
void matchTrailingSlash() {
MockHttpServletRequest request = createRequest("/foo/");
PathPatternsRequestCondition condition = createCondition("/foo");
PathPatternsRequestCondition match = condition.getMatchingCondition(new ServletRequestContext(null, request, null));
assertThat(match).isNotNull();
assertThat(match.getPatternValues().iterator().next()).as("Should match by default").isEqualTo("/foo");
PathPatternParser strictParser = new PathPatternParser();
strictParser.setMatchOptionalTrailingSeparator(false);
condition = new PathPatternsRequestCondition(strictParser, "/foo");
match = condition.getMatchingCondition(new ServletRequestContext(null, request, null));
assertThat(match).isNull();
}
use of cn.taketoday.web.util.pattern.PathPatternParser in project today-framework by TAKETODAY.
the class RequestMappingInfoTests method mutate.
@Test
void mutate() {
RequestMappingInfo.BuilderConfiguration options = new RequestMappingInfo.BuilderConfiguration();
options.setPatternParser(new PathPatternParser());
RequestMappingInfo info1 = RequestMappingInfo.paths("/foo").methods(GET).headers("h1=hv1").params("q1=qv1").consumes("application/json").produces("application/json").mappingName("testMapping").options(options).build();
RequestMappingInfo info2 = info1.mutate().produces("application/hal+json").build();
assertThat(info2.getName()).isEqualTo(info1.getName());
assertThat(info2.getPathPatternsCondition()).isEqualTo(info1.getPathPatternsCondition());
assertThat(info2.getHeadersCondition()).isEqualTo(info1.getHeadersCondition());
assertThat(info2.getParamsCondition()).isEqualTo(info1.getParamsCondition());
assertThat(info2.getConsumesCondition()).isEqualTo(info1.getConsumesCondition());
assertThat(info2.getProducesCondition().getProducibleMediaTypes()).containsOnly(MediaType.parseMediaType("application/hal+json"));
}
use of cn.taketoday.web.util.pattern.PathPatternParser in project today-framework by TAKETODAY.
the class PathPatternsRequestConditionTests method matchTrailingSlash.
@Test
void matchTrailingSlash() {
MockHttpServletRequest request = createRequest("/foo/");
PathPatternsRequestCondition condition = createCondition("/foo");
PathPatternsRequestCondition match = condition.getMatchingCondition(new ServletRequestContext(null, request, null));
assertThat(match).isNotNull();
assertThat(match.getPatternValues().iterator().next()).as("Should match by default").isEqualTo("/foo");
PathPatternParser strictParser = new PathPatternParser();
strictParser.setMatchOptionalTrailingSeparator(false);
condition = new PathPatternsRequestCondition(strictParser, "/foo");
match = condition.getMatchingCondition(new ServletRequestContext(null, request, null));
assertThat(match).isNull();
}
use of cn.taketoday.web.util.pattern.PathPatternParser in project today-framework by TAKETODAY.
the class RequestMappingInfoTests method pathPatternsArguments.
@SuppressWarnings("unused")
static Stream<RequestMappingInfo.Builder> pathPatternsArguments() {
RequestMappingInfo.BuilderConfiguration config = new RequestMappingInfo.BuilderConfiguration();
config.setPatternParser(new PathPatternParser());
return Stream.of(RequestMappingInfo.paths().options(config), RequestMappingInfo.paths());
}
Aggregations