PersistenceExtensions { public static DecimalType sumSince(Item item, ZonedDateTime timestamp) { return sumSince(item, timestamp, getDefaultServiceId()); } @Activate  PersistenceExtensions(@Reference PersistenceServiceRegistry registry); static void persist(Item item, String serviceId); static void persist(Item item); static HistoricItem historicState(Item item, ZonedDateTime timestamp); static HistoricItem historicState(Item item, ZonedDateTime timestamp, String serviceId); static Boolean changedSince(Item item, ZonedDateTime timestamp); static Boolean changedSince(Item item, ZonedDateTime timestamp, String serviceId); static Boolean updatedSince(Item item, ZonedDateTime timestamp); static Boolean updatedSince(Item item, ZonedDateTime timestamp, String serviceId); static HistoricItem maximumSince(Item item, ZonedDateTime timestamp); static HistoricItem maximumSince(final Item item, ZonedDateTime timestamp, String serviceId); static HistoricItem minimumSince(Item item, ZonedDateTime timestamp); static HistoricItem minimumSince(final Item item, ZonedDateTime timestamp, String serviceId); static DecimalType varianceSince(Item item, ZonedDateTime timestamp); static DecimalType varianceSince(Item item, ZonedDateTime timestamp, String serviceId); static DecimalType deviationSince(Item item, ZonedDateTime timestamp); static DecimalType deviationSince(Item item, ZonedDateTime timestamp, String serviceId); static DecimalType averageSince(Item item, ZonedDateTime timestamp); static DecimalType averageSince(Item item, ZonedDateTime timestamp, String serviceId); static DecimalType sumSince(Item item, ZonedDateTime timestamp); static DecimalType sumSince(Item item, ZonedDateTime timestamp, String serviceId); static ZonedDateTime lastUpdate(Item item); static ZonedDateTime lastUpdate(Item item, String serviceId); static DecimalType deltaSince(Item item, ZonedDateTime timestamp); static DecimalType deltaSince(Item item, ZonedDateTime timestamp, String serviceId); static DecimalType evolutionRate(Item item, ZonedDateTime timestamp); static DecimalType evolutionRate(Item item, ZonedDateTime timestamp, String serviceId); static HistoricItem previousState(Item item); static HistoricItem previousState(Item item, boolean skipEqual); static HistoricItem previousState(Item item, boolean skipEqual, String serviceId);  }
@Test public void testSumSince() { DecimalType sum = PersistenceExtensions.sumSince(item, ZonedDateTime.of(1940, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault()), TestPersistenceService.ID); assertNotNull(sum); assertEquals(0.0, sum.doubleValue(), 0.001); sum = PersistenceExtensions.sumSince(item, ZonedDateTime.of(2005, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault()), TestPersistenceService.ID); assertNotNull(sum); assertEquals(IntStream.of(2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012).sum(), sum.doubleValue(), 0.001); sum = PersistenceExtensions.sumSince(item, ZonedDateTime.of(2005, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault())); assertNotNull(sum); assertEquals(0.0, sum.doubleValue(), 0.001); }