@Test public void delete_activity_older_than_180_days_and_their_scanner_context() { LocalDateTime now = LocalDateTime.now(); insertWithDate("VERY_OLD", now.minusDays(180).minusMonths(10)); insertWithDate("JUST_OLD_ENOUGH", now.minusDays(180).minusDays(1)); insertWithDate("NOT_OLD_ENOUGH", now.minusDays(180)); insertWithDate("RECENT", now.minusDays(1)); when(system2.now()).thenReturn(now.toInstant(ZoneOffset.UTC).toEpochMilli()); underTest.start(); assertThat(selectActivity("VERY_OLD").isPresent()).isFalse(); assertThat(selectTaskInput("VERY_OLD").isPresent()).isFalse(); assertThat(selectTaskCharecteristic("VERY_OLD")).hasSize(0); assertThat(scannerContextExists("VERY_OLD")).isFalse(); assertThat(selectActivity("JUST_OLD_ENOUGH").isPresent()).isFalse(); assertThat(selectTaskInput("JUST_OLD_ENOUGH").isPresent()).isFalse(); assertThat(selectTaskCharecteristic("JUST_OLD_ENOUGH")).hasSize(0); assertThat(scannerContextExists("JUST_OLD_ENOUGH")).isFalse(); assertThat(selectActivity("NOT_OLD_ENOUGH").isPresent()).isTrue(); assertThat(selectTaskInput("NOT_OLD_ENOUGH").isPresent()).isTrue(); assertThat(selectTaskCharecteristic("NOT_OLD_ENOUGH")).hasSize(1); assertThat(scannerContextExists("NOT_OLD_ENOUGH")).isFalse(); // because more than 4 weeks old assertThat(selectActivity("RECENT").isPresent()).isTrue(); assertThat(selectTaskInput("RECENT").isPresent()).isTrue(); assertThat(selectTaskCharecteristic("RECENT")).hasSize(1); assertThat(scannerContextExists("RECENT")).isTrue(); }
@Test public void delete_ce_scanner_context_older_than_28_days() { LocalDateTime now = LocalDateTime.now(); insertWithDate("VERY_OLD", now.minusDays(28).minusMonths(12)); insertWithDate("JUST_OLD_ENOUGH", now.minusDays(28).minusDays(1)); insertWithDate("NOT_OLD_ENOUGH", now.minusDays(28)); insertWithDate("RECENT", now.minusDays(1)); when(system2.now()).thenReturn(now.toInstant(ZoneOffset.UTC).toEpochMilli()); underTest.start(); assertThat(scannerContextExists("VERY_OLD")).isFalse(); assertThat(scannerContextExists("JUST_OLD_ENOUGH")).isFalse(); assertThat(scannerContextExists("NOT_OLD_ENOUGH")).isTrue(); assertThat(scannerContextExists("RECENT")).isTrue(); }