@Test public void testWaitEnvironmentNetworkCreationFinished() { Long sdxId = 42L; SdxCluster sdxCluster = new SdxCluster(); sdxCluster.setId(sdxId); sdxCluster.setClusterShape(SdxClusterShape.LIGHT_DUTY); sdxCluster.setEnvName("env"); sdxCluster.setEnvCrn("crn"); sdxCluster.setClusterName("cluster"); Optional<SdxCluster> sdxClusterOptional = Optional.of(sdxCluster); when(sdxClusterRepository.findById(sdxId)).thenReturn(sdxClusterOptional); when(environmentClientService.getByCrn("crn")) .thenReturn(getDetailedEnvironmentResponseWithStatus(EnvironmentStatus.ENVIRONMENT_VALIDATION_IN_PROGRESS)) .thenReturn(getDetailedEnvironmentResponseWithStatus(EnvironmentStatus.NETWORK_CREATION_IN_PROGRESS)) .thenReturn(getDetailedEnvironmentResponseWithStatus(EnvironmentStatus.PUBLICKEY_CREATE_IN_PROGRESS)); DetailedEnvironmentResponse environment = underTest.waitNetworkAndGetEnvironment(sdxId); assertThat(environment.getEnvironmentStatus(), is(EnvironmentStatus.PUBLICKEY_CREATE_IN_PROGRESS)); verifyZeroInteractions(sdxClusterRepository); verifyZeroInteractions(environmentClientService); }
public DetailedEnvironmentResponse waitNetworkAndGetEnvironment(Long sdxId) { PollingConfig pollingConfig = new PollingConfig(SLEEP_TIME_IN_SEC_FOR_ENV_POLLING, TimeUnit.SECONDS, DURATION_IN_MINUTES_FOR_ENV_POLLING, TimeUnit.MINUTES); return waitAndGetEnvironment(sdxId, pollingConfig, EnvironmentStatus::isNetworkCreationFinished); }
EnvironmentService { public DetailedEnvironmentResponse waitNetworkAndGetEnvironment(Long sdxId) { PollingConfig pollingConfig = new PollingConfig(SLEEP_TIME_IN_SEC_FOR_ENV_POLLING, TimeUnit.SECONDS, DURATION_IN_MINUTES_FOR_ENV_POLLING, TimeUnit.MINUTES); return waitAndGetEnvironment(sdxId, pollingConfig, EnvironmentStatus::isNetworkCreationFinished); } }
EnvironmentService { public DetailedEnvironmentResponse waitNetworkAndGetEnvironment(Long sdxId) { PollingConfig pollingConfig = new PollingConfig(SLEEP_TIME_IN_SEC_FOR_ENV_POLLING, TimeUnit.SECONDS, DURATION_IN_MINUTES_FOR_ENV_POLLING, TimeUnit.MINUTES); return waitAndGetEnvironment(sdxId, pollingConfig, EnvironmentStatus::isNetworkCreationFinished); }  }
EnvironmentService { public DetailedEnvironmentResponse waitNetworkAndGetEnvironment(Long sdxId) { PollingConfig pollingConfig = new PollingConfig(SLEEP_TIME_IN_SEC_FOR_ENV_POLLING, TimeUnit.SECONDS, DURATION_IN_MINUTES_FOR_ENV_POLLING, TimeUnit.MINUTES); return waitAndGetEnvironment(sdxId, pollingConfig, EnvironmentStatus::isNetworkCreationFinished); }  DetailedEnvironmentResponse waitAndGetEnvironment(Long sdxId); DetailedEnvironmentResponse waitNetworkAndGetEnvironment(Long sdxId); DetailedEnvironmentResponse waitAndGetEnvironment(Long sdxId, PollingConfig pollingConfig, Function<EnvironmentStatus, Boolean> statusCheck); DetailedEnvironmentResponse getDetailedEnvironmentResponseByName(String environmentName); }
EnvironmentService { public DetailedEnvironmentResponse waitNetworkAndGetEnvironment(Long sdxId) { PollingConfig pollingConfig = new PollingConfig(SLEEP_TIME_IN_SEC_FOR_ENV_POLLING, TimeUnit.SECONDS, DURATION_IN_MINUTES_FOR_ENV_POLLING, TimeUnit.MINUTES); return waitAndGetEnvironment(sdxId, pollingConfig, EnvironmentStatus::isNetworkCreationFinished); }  DetailedEnvironmentResponse waitAndGetEnvironment(Long sdxId); DetailedEnvironmentResponse waitNetworkAndGetEnvironment(Long sdxId); DetailedEnvironmentResponse waitAndGetEnvironment(Long sdxId, PollingConfig pollingConfig, Function<EnvironmentStatus, Boolean> statusCheck); DetailedEnvironmentResponse getDetailedEnvironmentResponseByName(String environmentName); static final int SLEEP_TIME_IN_SEC_FOR_ENV_POLLING; static final int DURATION_IN_MINUTES_FOR_ENV_POLLING; }