Search in sources :

Example 21 with Environment

use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.

the class EnvironmentServiceTest method updateTunnelByEnvironmentId.

@Test
void updateTunnelByEnvironmentId() {
    ExperimentalFeatures expFeat = environment.getExperimentalFeaturesJson();
    expFeat.setTunnel(Tunnel.CCM);
    environment.setExperimentalFeaturesJson(expFeat);
    Optional<Environment> optEnv = Optional.of(environment);
    when(environmentRepository.findById(123L)).thenReturn(optEnv);
    environmentServiceUnderTest.updateTunnelByEnvironmentId(123L, Tunnel.CCMV2_JUMPGATE);
    ArgumentCaptor<Environment> envCaptor = ArgumentCaptor.forClass(Environment.class);
    verify(environmentRepository).save(envCaptor.capture());
    Environment captured = envCaptor.getValue();
    assertThat(captured.getExperimentalFeaturesJson().getTunnel()).isEqualTo(Tunnel.CCMV2_JUMPGATE);
}
Also used : ExperimentalFeatures(com.sequenceiq.environment.environment.domain.ExperimentalFeatures) Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test)

Example 22 with Environment

use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.

the class EnvironmentServiceTest method listByAccountId.

@Test
void listByAccountId() {
    Set<Environment> twoEnvironment = Set.of(new Environment(), new Environment());
    final int twoInvocations = 2;
    when(environmentRepository.findByAccountId(eq(TestConstants.ACCOUNT_ID))).thenReturn(twoEnvironment);
    environmentServiceUnderTest.listByAccountId(TestConstants.ACCOUNT_ID);
    verify(environmentRepository).findByAccountId(eq(TestConstants.ACCOUNT_ID));
    verify(environmentDtoConverter, times(twoInvocations)).environmentToDto(any(Environment.class));
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test)

Example 23 with Environment

use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.

the class EnvironmentStopServiceTest method shouldStopEnvWithOnlyStoppedChildren.

@Test
public void shouldStopEnvWithOnlyStoppedChildren() {
    EnvironmentDto environmentDto = getEnvironmentDto();
    when(environmentService.getByCrnAndAccountId(ENV_CRN, ACCOUNT_ID)).thenReturn(environmentDto);
    Environment childEnvironment = new Environment();
    childEnvironment.setStatus(EnvironmentStatus.ENV_STOPPED);
    when(environmentService.findAllByAccountIdAndParentEnvIdAndArchivedIsFalse(ACCOUNT_ID, ENV_ID)).thenReturn(List.of(childEnvironment));
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.stopByCrn(ENV_CRN));
    verify(reactorFlowManager).triggerStopFlow(ENV_ID, ENV_NAME, USER_CRN);
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test)

Example 24 with Environment

use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.

the class EnvironmentStatusCheckerJobTest method testSyncAnEnvSameStatus.

@Test
void testSyncAnEnvSameStatus() {
    Environment environment = new Environment();
    environment.setId(1234L);
    environment.setStatus(AVAILABLE);
    when(environmentSyncService.getStatusByFreeipa(environment)).thenReturn(AVAILABLE);
    underTest.syncAnEnv(environment);
    verify(environmentStatusUpdateService, never()).updateEnvironmentStatusAndNotify(eq(environment), any(), any());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test)

Example 25 with Environment

use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.

the class EnvironmentStatusTest method setUp.

@BeforeEach
void setUp() {
    underTest.setLocalId(ENVIRONMENT_ID.toString());
    environment = new Environment();
    environment.setId(ENVIRONMENT_ID);
    environment.setCreator("creator");
    environment.setResourceCrn("crn:env");
    environment.setAccountId("cloudera");
    when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(environment));
    when(flowLogService.isOtherFlowRunning(ENVIRONMENT_ID)).thenReturn(false);
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Environment (com.sequenceiq.environment.environment.domain.Environment)187 Test (org.junit.jupiter.api.Test)145 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)48 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)42 EnvironmentEditDto (com.sequenceiq.environment.environment.dto.EnvironmentEditDto)29 Credential (com.sequenceiq.environment.credential.domain.Credential)26 EnvironmentAuthentication (com.sequenceiq.environment.environment.domain.EnvironmentAuthentication)24 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)21 ParametersDto (com.sequenceiq.environment.parameter.dto.ParametersDto)16 AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)15 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)14 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)13 SecurityAccessDto (com.sequenceiq.environment.environment.dto.SecurityAccessDto)12 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)11 AwsParametersDto (com.sequenceiq.environment.parameter.dto.AwsParametersDto)11 AzureResourceEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto)11 Headers (reactor.bus.Event.Headers)11 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)10 AuthenticationDto (com.sequenceiq.environment.environment.dto.AuthenticationDto)10