/** * Return declared "consumable" types but only among those that also * match the "methods" condition. */ public Set<MediaType> getConsumableMediaTypes() { return this.partialMatches.stream().filter(PartialMatch::hasMethodsMatch). flatMap(m -> m.getInfo().getConsumesCondition().getConsumableMediaTypes().stream()). collect(Collectors.toCollection(LinkedHashSet::new)); }
@Test public void getConsumableMediaTypesNegatedExpression() throws Exception { ConsumesRequestCondition condition = new ConsumesRequestCondition("!application/xml"); assertEquals(Collections.emptySet(), condition.getConsumableMediaTypes()); }
@Test // SPR-14988 public void getMappingOverridesConsumesFromTypeLevelAnnotation() throws Exception { RequestMappingInfo requestMappingInfo = assertComposedAnnotationMapping(RequestMethod.GET); assertArrayEquals(new MediaType[]{MediaType.ALL}, new ArrayList<>( requestMappingInfo.getConsumesCondition().getConsumableMediaTypes()).toArray()); }
@Test public void resolveRequestMappingViaComposedAnnotation() throws Exception { RequestMappingInfo info = assertComposedAnnotationMapping("postJson", "/postJson", RequestMethod.POST); assertEquals(MediaType.APPLICATION_JSON_VALUE, info.getConsumesCondition().getConsumableMediaTypes().iterator().next().toString()); assertEquals(MediaType.APPLICATION_JSON_VALUE, info.getProducesCondition().getProducibleMediaTypes().iterator().next().toString()); }
/** * Return declared "consumable" types but only among those that also * match the "methods" condition. */ public Set<MediaType> getConsumableMediaTypes() { return this.partialMatches.stream().filter(PartialMatch::hasMethodsMatch). flatMap(m -> m.getInfo().getConsumesCondition().getConsumableMediaTypes().stream()). collect(Collectors.toCollection(LinkedHashSet::new)); }