@Test public void shouldPerformUpgrade() { when(upgradeService.needUpgrade()).thenReturn(true); when(forAll.condition()).thenReturn(o -> () -> true); doAnswer((Answer<Void>) invocation -> { ((Runnable) invocation.getArguments()[1]).run(); return null; }).when(forAll).execute(any(), any()); doAnswer((Answer<Void>) invocation -> { ((Runnable) invocation.getArguments()[0]).run(); return null; }).when(executor).execute(any()); upgradeTask.execute(); verify(security, times(2)).getTenantId(); verify(upgradeService, times(1)).upgradeVersion(); }
public Supplier<Boolean> condition() { final Supplier<Boolean> needUpgradeCondition = () -> upgradeService.needUpgrade(); final Supplier<Boolean> hasRepositoryConfiguration = forAll.condition().operational(repository); return () -> needUpgradeCondition.get() && hasRepositoryConfiguration.get(); }
UpgradeTask implements MaintenanceTaskProcess { public Supplier<Boolean> condition() { final Supplier<Boolean> needUpgradeCondition = () -> upgradeService.needUpgrade(); final Supplier<Boolean> hasRepositoryConfiguration = forAll.condition().operational(repository); return () -> needUpgradeCondition.get() && hasRepositoryConfiguration.get(); } }
UpgradeTask implements MaintenanceTaskProcess { public Supplier<Boolean> condition() { final Supplier<Boolean> needUpgradeCondition = () -> upgradeService.needUpgrade(); final Supplier<Boolean> hasRepositoryConfiguration = forAll.condition().operational(repository); return () -> needUpgradeCondition.get() && hasRepositoryConfiguration.get(); }  }
UpgradeTask implements MaintenanceTaskProcess { public Supplier<Boolean> condition() { final Supplier<Boolean> needUpgradeCondition = () -> upgradeService.needUpgrade(); final Supplier<Boolean> hasRepositoryConfiguration = forAll.condition().operational(repository); return () -> needUpgradeCondition.get() && hasRepositoryConfiguration.get(); }  void performTask(); Supplier<Boolean> condition(); @Override ScheduleFrequency getFrequency(); }
UpgradeTask implements MaintenanceTaskProcess { public Supplier<Boolean> condition() { final Supplier<Boolean> needUpgradeCondition = () -> upgradeService.needUpgrade(); final Supplier<Boolean> hasRepositoryConfiguration = forAll.condition().operational(repository); return () -> needUpgradeCondition.get() && hasRepositoryConfiguration.get(); }  void performTask(); Supplier<Boolean> condition(); @Override ScheduleFrequency getFrequency();  }