use of com.fasterxml.jackson.databind.ser.FilterProvider in project jackson-databind by FasterXML.
the class TestJsonFilter method testDefaultFilter.
// defaulting, as per [JACKSON-449]
public void testDefaultFilter() throws Exception {
FilterProvider prov = new SimpleFilterProvider().setDefaultFilter(SimpleBeanPropertyFilter.filterOutAllExcept("b"));
assertEquals("{\"b\":\"b\"}", MAPPER.writer(prov).writeValueAsString(new Bean()));
}
use of com.fasterxml.jackson.databind.ser.FilterProvider in project uPortal by Jasig.
the class AnalyticsIncorporationComponentEventSerializationTest method testMixinWithCopy.
/**
* Fails as actual output is:
* {"@c":".PortletRenderExecutionEvent","timestamp":1371671516798,"serverId":"example.com","eventSessionId":"1234567890123_system_AAAAAAAAAAA","userName":"system","fname":"fname1","executionTimeNano":123450000,"parameters":{},"targeted":false,"usedPortalCache":false}
*/
@Ignore
@Test
public void testMixinWithCopy() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.findAndRegisterModules();
//Clone from "shared" ObjectMapper
mapper = mapper.copy();
mapper.addMixInAnnotations(Object.class, PortletRenderExecutionEventFilterMixIn.class);
final FilterProvider filterProvider = new SimpleFilterProvider().addFilter(PortletRenderExecutionEventFilterMixIn.FILTER_NAME, SimpleBeanPropertyFilter.filterOutAllExcept("fname", "executionTimeNano", "parameters"));
final ObjectWriter portletEventWriter = mapper.writer(filterProvider);
final String result = portletEventWriter.writeValueAsString(createEvent());
assertEquals("{\"@c\":\".PortletRenderExecutionEvent\",\"fname\":\"fname1\",\"executionTimeNano\":123450000,\"parameters\":{}}", result);
}
Aggregations