@Test public void shouldThrowBadRequestExceptionGivenFreeIpaIsRunningOnSpotInstances() { EnvironmentDto environmentDto = getEnvironmentDto(); environmentDto.setFreeIpaCreation(FreeIpaCreationDto.builder() .withAws(FreeIpaCreationAwsParametersDto.builder() .withSpot(FreeIpaCreationAwsSpotParametersDto.builder() .withPercentage(100) .build()) .build()) .build()); when(environmentService.getByCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).thenReturn(environmentDto); when(environmentService.findAllByAccountIdAndParentEnvIdAndArchivedIsFalse(ACCOUNT_ID, ENV_ID)).thenReturn(Lists.emptyList()); Assertions.assertThatThrownBy(() -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.stopByCrn(ENV_CRN))) .isInstanceOf(BadRequestException.class) .hasMessage("Environment [name] can not be stopped because FreeIpa is running on spot instances."); }
public void stopByCrn(String crn) { String accountId = ThreadBasedUserCrnProvider.getAccountId(); EnvironmentDto environment = environmentService.getByCrnAndAccountId(crn, accountId); stop(environment, accountId); }
EnvironmentStopService { public void stopByCrn(String crn) { String accountId = ThreadBasedUserCrnProvider.getAccountId(); EnvironmentDto environment = environmentService.getByCrnAndAccountId(crn, accountId); stop(environment, accountId); } }
EnvironmentStopService { public void stopByCrn(String crn) { String accountId = ThreadBasedUserCrnProvider.getAccountId(); EnvironmentDto environment = environmentService.getByCrnAndAccountId(crn, accountId); stop(environment, accountId); } EnvironmentStopService(EnvironmentReactorFlowManager reactorFlowManager,
            EnvironmentService environmentService); }
EnvironmentStopService { public void stopByCrn(String crn) { String accountId = ThreadBasedUserCrnProvider.getAccountId(); EnvironmentDto environment = environmentService.getByCrnAndAccountId(crn, accountId); stop(environment, accountId); } EnvironmentStopService(EnvironmentReactorFlowManager reactorFlowManager,
            EnvironmentService environmentService); void stopByCrn(String crn); void stopByName(String name); }
EnvironmentStopService { public void stopByCrn(String crn) { String accountId = ThreadBasedUserCrnProvider.getAccountId(); EnvironmentDto environment = environmentService.getByCrnAndAccountId(crn, accountId); stop(environment, accountId); } EnvironmentStopService(EnvironmentReactorFlowManager reactorFlowManager,
            EnvironmentService environmentService); void stopByCrn(String crn); void stopByName(String name);  }