@Test void testSyncAnEnvDifferentStatusAndUpdateEnabled() { Environment environment = new Environment(); environment.setId(1234L); environment.setStatus(ENV_STOPPED); when(environmentSyncService.getStatusByFreeipa(environment)).thenReturn(AVAILABLE); when(autoSyncConfig.isUpdateStatus()).thenReturn(true); underTest.syncAnEnv(environment); verify(environmentStatusUpdateService).updateEnvironmentStatusAndNotify(environment, AVAILABLE, ENVIRONMENT_SYNC_FINISHED); }
@VisibleForTesting void syncAnEnv(Environment environment) { try { ThreadBasedUserCrnProvider.doAs(environment.getCreator(), () -> { EnvironmentStatus status = environmentSyncService.getStatusByFreeipa(environment); if (environment.getStatus() != status) { if (!flowLogService.isOtherFlowRunning(environment.getId())) { updateIfEnabled(environment, status); } else { LOGGER.info("EnvironmentStatusCheckerJob wants to update the status but it's ignored because a flow started on: {}", environment.getName()); } } else { LOGGER.info("Environment status is the same ({}), the update is skipped", status); } }); } catch (Exception e) { LOGGER.info("Environment sync is failed for {}, error: {}", environment.getName(), e.getMessage(), e); } }
EnvironmentStatusCheckerJob extends StatusCheckerJob { @VisibleForTesting void syncAnEnv(Environment environment) { try { ThreadBasedUserCrnProvider.doAs(environment.getCreator(), () -> { EnvironmentStatus status = environmentSyncService.getStatusByFreeipa(environment); if (environment.getStatus() != status) { if (!flowLogService.isOtherFlowRunning(environment.getId())) { updateIfEnabled(environment, status); } else { LOGGER.info("EnvironmentStatusCheckerJob wants to update the status but it's ignored because a flow started on: {}", environment.getName()); } } else { LOGGER.info("Environment status is the same ({}), the update is skipped", status); } }); } catch (Exception e) { LOGGER.info("Environment sync is failed for {}, error: {}", environment.getName(), e.getMessage(), e); } } }
EnvironmentStatusCheckerJob extends StatusCheckerJob { @VisibleForTesting void syncAnEnv(Environment environment) { try { ThreadBasedUserCrnProvider.doAs(environment.getCreator(), () -> { EnvironmentStatus status = environmentSyncService.getStatusByFreeipa(environment); if (environment.getStatus() != status) { if (!flowLogService.isOtherFlowRunning(environment.getId())) { updateIfEnabled(environment, status); } else { LOGGER.info("EnvironmentStatusCheckerJob wants to update the status but it's ignored because a flow started on: {}", environment.getName()); } } else { LOGGER.info("Environment status is the same ({}), the update is skipped", status); } }); } catch (Exception e) { LOGGER.info("Environment sync is failed for {}, error: {}", environment.getName(), e.getMessage(), e); } } EnvironmentStatusCheckerJob(EnvironmentService environmentService, FlowLogService flowLogService,
            EnvironmentSyncService environmentSyncService, EnvironmentStatusUpdateService environmentStatusUpdateService,
            EnvironmentJobService environmentJobService, AutoSyncConfig autoSyncConfig); }
EnvironmentStatusCheckerJob extends StatusCheckerJob { @VisibleForTesting void syncAnEnv(Environment environment) { try { ThreadBasedUserCrnProvider.doAs(environment.getCreator(), () -> { EnvironmentStatus status = environmentSyncService.getStatusByFreeipa(environment); if (environment.getStatus() != status) { if (!flowLogService.isOtherFlowRunning(environment.getId())) { updateIfEnabled(environment, status); } else { LOGGER.info("EnvironmentStatusCheckerJob wants to update the status but it's ignored because a flow started on: {}", environment.getName()); } } else { LOGGER.info("Environment status is the same ({}), the update is skipped", status); } }); } catch (Exception e) { LOGGER.info("Environment sync is failed for {}, error: {}", environment.getName(), e.getMessage(), e); } } EnvironmentStatusCheckerJob(EnvironmentService environmentService, FlowLogService flowLogService,
            EnvironmentSyncService environmentSyncService, EnvironmentStatusUpdateService environmentStatusUpdateService,
            EnvironmentJobService environmentJobService, AutoSyncConfig autoSyncConfig);  }
EnvironmentStatusCheckerJob extends StatusCheckerJob { @VisibleForTesting void syncAnEnv(Environment environment) { try { ThreadBasedUserCrnProvider.doAs(environment.getCreator(), () -> { EnvironmentStatus status = environmentSyncService.getStatusByFreeipa(environment); if (environment.getStatus() != status) { if (!flowLogService.isOtherFlowRunning(environment.getId())) { updateIfEnabled(environment, status); } else { LOGGER.info("EnvironmentStatusCheckerJob wants to update the status but it's ignored because a flow started on: {}", environment.getName()); } } else { LOGGER.info("Environment status is the same ({}), the update is skipped", status); } }); } catch (Exception e) { LOGGER.info("Environment sync is failed for {}, error: {}", environment.getName(), e.getMessage(), e); } } EnvironmentStatusCheckerJob(EnvironmentService environmentService, FlowLogService flowLogService,
            EnvironmentSyncService environmentSyncService, EnvironmentStatusUpdateService environmentStatusUpdateService,
            EnvironmentJobService environmentJobService, AutoSyncConfig autoSyncConfig);   }