FallbackContentNegotiationStrategy implements ContentNegotiationStrategy { @Override @Nonnull public List<MediaType> resolveMediaTypes(final NativeWebRequest request) throws HttpMediaTypeNotAcceptableException { final List<MediaType> mediaTypes = delegate.resolveMediaTypes(request); if (mediaTypes.isEmpty()) { return all; } return mediaTypes; } FallbackContentNegotiationStrategy(final ContentNegotiationStrategy delegate); @Override @Nonnull List<MediaType> resolveMediaTypes(final NativeWebRequest request);  }
@Test void shouldPassThroughResolvedMediaTypes() throws HttpMediaTypeNotAcceptableException { final List<MediaType> json = singletonList(APPLICATION_JSON); when(delegate.resolveMediaTypes(any())).thenReturn(json); final List<MediaType> actual = unit.resolveMediaTypes(mock(NativeWebRequest.class)); assertSame(json, actual); }
@Test void shouldFallback() throws HttpMediaTypeNotAcceptableException { when(delegate.resolveMediaTypes(any())).thenReturn(emptyList()); final List<MediaType> actual = unit.resolveMediaTypes(mock(NativeWebRequest.class)); assertEquals(singletonList(ALL), actual); }