use of org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic in project uPortal by Jasig.
the class JpaStatisticalSummaryTest method testStorelessUnivariateStatistic.
public void testStorelessUnivariateStatistic(StorelessUnivariateStatistic sus, double expected) throws Exception {
assertEquals(expected, sus.getResult(), 0.1);
final ObjectMapper mapper = new ObjectMapper();
mapper.findAndRegisterModules();
// Configure Jackson to just use fields
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
mapper.setVisibility(PropertyAccessor.GETTER, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.IS_GETTER, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.SETTER, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.CREATOR, Visibility.NONE);
mapper.addMixInAnnotations(Object.class, IgnoreTypeMixIn.class);
final FilterProvider filters = new SimpleFilterProvider().addFilter("storedDataFilter", SimpleBeanPropertyFilter.serializeAllExcept("storedData"));
final ObjectWriter ssWriter = mapper.writer(filters);
final ObjectReader ssReader = mapper.reader(sus.getClass());
final String susString = ssWriter.writeValueAsString(sus);
System.out.println(susString);
final StorelessUnivariateStatistic newSus = ssReader.readValue(susString);
assertEquals(expected, newSus.getResult(), 0.1);
}
Aggregations