Search in sources :

Example 6 with EnvironmentView

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

the class EnvironmentDeletionService method deleteByCrnAndAccountId.

public EnvironmentViewDto deleteByCrnAndAccountId(String crn, String accountId, String actualUserCrn, boolean cascading, boolean forced) {
    EnvironmentView environment = environmentViewService.getByCrnAndAccountId(crn, accountId);
    MDCBuilder.buildMdcContext(environment);
    LOGGER.debug(String.format("Deleting  environment [name: %s]", environment.getName()));
    delete(environment, actualUserCrn, cascading, forced);
    return environmentDtoConverter.environmentViewToViewDto(environment);
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView)

Example 7 with EnvironmentView

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

the class GcpEnvironmentParametersConverterTest method convertToDtoTest.

@Test
void convertToDtoTest() {
    EnvironmentView environmentView = ENVIRONMENT_VIEW;
    GcpParameters parameters = new GcpParameters();
    parameters.setAccountId(ACCOUNT_ID);
    parameters.setEnvironment(environmentView);
    parameters.setId(ID);
    parameters.setName(ENV_NAME);
    parameters.setEncryptionKey(ENCRYPTION_KEY);
    ParametersDto result = underTest.convertToDto(parameters);
    assertEquals(ACCOUNT_ID, result.getAccountId());
    assertEquals(ID, result.getId());
    assertEquals(ENV_NAME, result.getName());
    assertEquals(ENCRYPTION_KEY, result.getGcpParametersDto().getGcpResourceEncryptionParametersDto().getEncryptionKey());
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) GcpResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.GcpResourceEncryptionParametersDto) GcpParametersDto(com.sequenceiq.environment.parameter.dto.GcpParametersDto) GcpParameters(com.sequenceiq.environment.parameters.dao.domain.GcpParameters) Test(org.junit.jupiter.api.Test)

Example 8 with EnvironmentView

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

the class AwsEnvironmentNetworkConverterTest method testConvertToNetwork.

@Test
void testConvertToNetwork() {
    EnvironmentView environment = new EnvironmentView();
    environment.setLocation(LOCATION);
    AwsNetwork awsNetwork = new AwsNetwork();
    awsNetwork.setVpcId(VPC_ID);
    awsNetwork.setEnvironments(Set.of(environment));
    Network network = underTest.convertToNetwork(awsNetwork);
    assertEquals(VPC_ID, network.getStringParameter(NetworkConstants.VPC_ID));
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) CreatedCloudNetwork(com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) Network(com.sequenceiq.cloudbreak.cloud.model.Network) BaseNetwork(com.sequenceiq.environment.network.dao.domain.BaseNetwork) Test(org.junit.jupiter.api.Test)

Example 9 with EnvironmentView

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

the class EnvironmentViewConverterTest method convertTest.

@Test
void convertTest() {
    Environment environment = newTestEnvironment();
    EnvironmentView result = underTest.convert(environment);
    assertEquals(ACCOUNT_ID, result.getAccountId());
    assertEquals(false, result.isArchived());
    assertEquals(CLOUD_PLATFORM, result.getCloudPlatform());
    assertEquals(DESCRIPTION, result.getDescription());
    assertEquals(1L, result.getId());
    assertEquals(LATITUDE, result.getLatitude());
    assertEquals(LOCATION, result.getLocation());
    assertEquals(LOCATION_DISPLAY_NAME, result.getLocationDisplayName());
    assertEquals(LONGITUDE, result.getLongitude());
    assertEquals(ENVIRONMENT_NAME, result.getName());
    assertEquals(NETWORK_ID, result.getNetwork().getNetworkId());
    assertEquals(REGIONS, result.getRegions());
    assertEquals(CRN, result.getResourceCrn());
    assertEquals(EnvironmentStatus.AVAILABLE, result.getStatus());
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) Environment(com.sequenceiq.environment.environment.domain.Environment) EnvironmentTestData.newTestEnvironment(com.sequenceiq.environment.environment.service.EnvironmentTestData.newTestEnvironment) Test(org.junit.jupiter.api.Test)

Example 10 with EnvironmentView

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

the class EnvironmentDeletionServiceTest method deleteMultipleByCrns.

@Test
public void deleteMultipleByCrns() {
    environmentDeletionService.deleteMultipleByCrns(Set.of("crn1", "crn2"), ACCOUNT_ID, USER, false, false);
    Set<String> names = Set.of("crn1", "crn2");
    EnvironmentView e1 = new EnvironmentView();
    e1.setId(0L);
    EnvironmentView e2 = new EnvironmentView();
    e2.setId(1L);
    Set<EnvironmentView> envs = Set.of(e1, e2);
    int expected = envs.size();
    EnvironmentDeletionService environmentDeletionServiceWired = spy(environmentDeletionService);
    when(environmentService.findByResourceCrnsInAccount(eq(names), eq(ACCOUNT_ID))).thenReturn(envs);
    assertEquals(expected, environmentDeletionServiceWired.deleteMultipleByCrns(names, ACCOUNT_ID, USER, false, false).size());
    verify(environmentDeletionServiceWired, times(expected)).delete(any(), eq(USER), anyBoolean(), anyBoolean());
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EnvironmentView (com.sequenceiq.environment.environment.domain.EnvironmentView)19 Test (org.junit.jupiter.api.Test)12 PollingConfig (com.sequenceiq.environment.util.PollingConfig)6 ParametersDto (com.sequenceiq.environment.parameter.dto.ParametersDto)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 EnvClusterDeleteFailedEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvClusterDeleteFailedEvent)2 EnvDeleteEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 UserBreakException (com.dyngr.exception.UserBreakException)1 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)1 Network (com.sequenceiq.cloudbreak.cloud.model.Network)1 CreatedCloudNetwork (com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 ExceptionResponse (com.sequenceiq.cloudbreak.common.exception.ExceptionResponse)1 Environment (com.sequenceiq.environment.environment.domain.Environment)1 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 EnvironmentViewDto (com.sequenceiq.environment.environment.dto.EnvironmentViewDto)1 EnvironmentTestData.newTestEnvironment (com.sequenceiq.environment.environment.service.EnvironmentTestData.newTestEnvironment)1