PersistenceExtensions { public static DecimalType evolutionRate(Item item, ZonedDateTime timestamp) { return evolutionRate(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 testEvolutionRate() { item.setState(new DecimalType(2012)); DecimalType rate = PersistenceExtensions.evolutionRate(item, ZonedDateTime.of(1940, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault()), TestPersistenceService.ID); assertNull(rate); rate = PersistenceExtensions.evolutionRate(item, ZonedDateTime.of(2005, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault()), TestPersistenceService.ID); assertNotNull(rate); assertEquals(0.349127182, rate.doubleValue(), 0.001); item.setState(new QuantityType<>(2012, SIUnits.CELSIUS)); rate = PersistenceExtensions.evolutionRate(item, ZonedDateTime.of(2005, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault()), TestPersistenceService.ID); assertNotNull(rate); assertEquals(0.349127182, rate.doubleValue(), 0.001); rate = PersistenceExtensions.evolutionRate(item, ZonedDateTime.of(2005, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault())); assertNull(rate); }