Example usage for com.fasterxml.jackson.databind AnnotationIntrospector findFilterId

List of usage examples for com.fasterxml.jackson.databind AnnotationIntrospector findFilterId

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind AnnotationIntrospector findFilterId.

Prototype

public Object findFilterId(AnnotatedClass paramAnnotatedClass) 

Source Link

Usage

From source file:com.pressassociation.pr.filter.json.jackson.JacksonFiltersTest.java

@Test
@Parameters(method = "methods")
public void testFilterAllOutput(OverloadedFilterAllOutput method) {
    ObjectMapper mapper = method.filterAllOutput(new ObjectMapper(), "foo/bar");
    AnnotationIntrospector introspector = mapper.getSerializationConfig().getAnnotationIntrospector();
    Object filterId = introspector.findFilterId((Annotated) AnnotatedClass.construct(TestObject.class,
            introspector, mapper.getDeserializationConfig()));
    assertNotNull(filterId);/*from w ww .  j  a v a 2s.co  m*/

    PropertyFilter propertyFilter = mapper.getSerializationConfig().getFilterProvider()
            .findPropertyFilter(filterId, new TestObject());
    assertNotNull(propertyFilter);
    assertTrue(propertyFilter instanceof JacksonMatcherFilter);
    assertEquals(Matcher.of("foo/bar"), ((JacksonMatcherFilter) propertyFilter).getMatcher());
}

From source file:com.pressassociation.pr.filter.json.jackson.JacksonRequestParamFilterTest.java

private void assertConfiguredWithoutMatcher(ObjectMapper mapper) {
    AnnotationIntrospector introspector = mapper.getSerializationConfig().getAnnotationIntrospector();
    Object filterId = introspector.findFilterId((Annotated) AnnotatedClass.construct(TestObject.class,
            introspector, mapper.getDeserializationConfig()));
    assertNull(filterId);/*www .  j a  v a2 s .  c o m*/
}

From source file:com.pressassociation.pr.filter.json.jackson.JacksonRequestParamFilterTest.java

private void assertConfiguredWithMatcher(ObjectMapper mapper, Matcher matcher) {
    AnnotationIntrospector introspector = mapper.getSerializationConfig().getAnnotationIntrospector();
    Object filterId = introspector.findFilterId((Annotated) AnnotatedClass.construct(TestObject.class,
            introspector, mapper.getDeserializationConfig()));
    assertNotNull(filterId);/*from   ww w . j  av  a  2  s.  c  om*/

    PropertyFilter propertyFilter = mapper.getSerializationConfig().getFilterProvider()
            .findPropertyFilter(filterId, new TestObject());
    assertNotNull(propertyFilter);
    assertTrue(propertyFilter instanceof JacksonMatcherFilter);
    assertEquals(matcher, ((JacksonMatcherFilter) propertyFilter).getMatcher());
}