FilteredObjectMapperResolver implements ContextResolver<ObjectMapper> { @Override public ObjectMapper getContext(Class<?> type) { checkNotNull(type); return paramFilter.configurePartialResponse(new ObjectMapper()); } @Inject  FilteredObjectMapperResolver(JacksonRequestParamFilter paramFilter); @Override ObjectMapper getContext(Class<?> type);  }
@Test public void testGetContext() { JacksonRequestParamFilter filter = mock(JacksonRequestParamFilter.class); ObjectMapper mapperResponse = new ObjectMapper(); ArgumentCaptor<ObjectMapper> mapper = ArgumentCaptor.forClass(ObjectMapper.class); when(filter.configurePartialResponse(mapper.capture())).thenReturn(mapperResponse); ObjectMapper context = new FilteredObjectMapperResolver(filter).getContext(ObjectMapper.class); assertSame(mapperResponse, context); verify(filter).configurePartialResponse(mapper.getValue()); }