Search in sources :

Example 1 with EnvironmentDeletionDto

use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.

the class EnvClustersDeleteActionsTest method verifyDeleteActionSuccessEvent.

private void verifyDeleteActionSuccessEvent(EnvDeleteHandlerSelectors eventSelector) {
    assertThat(selectorArgumentCaptor.getValue()).isEqualTo(eventSelector.selector());
    verifyEventFactoryAndHeaders();
    Object payload = payloadArgumentCaptor.getValue();
    assertThat(payload).isInstanceOf(EnvironmentDeletionDto.class);
    EnvironmentDeletionDto environmentDto = (EnvironmentDeletionDto) payload;
    assertThat(environmentDto.getEnvironmentDto().getResourceCrn()).isEqualTo(ENVIRONMENT_CRN);
    assertThat(environmentDto.getEnvironmentDto().getName()).isEqualTo(ENVIRONMENT_NAME);
    assertThat(environmentDto.getEnvironmentDto().getId()).isEqualTo(ENVIRONMENT_ID);
}
Also used : EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)

Example 2 with EnvironmentDeletionDto

use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.

the class FreeIpaDeletionHandlerTest method shouldDetachChildEnvironmentIfParentExists.

@Test
public void shouldDetachChildEnvironmentIfParentExists() throws Exception {
    EnvironmentDto environmentDto = new EnvironmentDto();
    environmentDto.setId(CHILD_ENVIRONMENT_ID);
    EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(environmentDto).withForceDelete(true).withId(CHILD_ENVIRONMENT_ID).build();
    when(environmentService.findEnvironmentById(CHILD_ENVIRONMENT_ID)).thenReturn(of(anEnvironmentWithParent(CHILD_ENVIRONMENT_ID)));
    when(freeIpaService.describe(ENVIRONMENT_CRN)).thenReturn(of(new DescribeFreeIpaResponse()));
    victim.accept(new Event<>(environmentDeletionDto));
    ArgumentCaptor<DetachChildEnvironmentRequest> detachChildEnvironmentRequestArgumentCaptor = ArgumentCaptor.forClass(DetachChildEnvironmentRequest.class);
    verify(freeIpaService).detachChildEnvironment(detachChildEnvironmentRequestArgumentCaptor.capture());
    verifyNoMoreInteractions(freeIpaService);
    verify(eventSender).sendEvent(any(BaseNamedFlowEvent.class), any(Event.Headers.class));
    verify(dnsV1Endpoint).deleteDnsZoneBySubnet(eq(PARENT_ENVIRONMENT_CRN), any());
    assertEquals(PARENT_ENVIRONMENT_CRN, detachChildEnvironmentRequestArgumentCaptor.getValue().getParentEnvironmentCrn());
    assertEquals(ENVIRONMENT_CRN, detachChildEnvironmentRequestArgumentCaptor.getValue().getChildEnvironmentCrn());
}
Also used : BaseNamedFlowEvent(com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) DetachChildEnvironmentRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.detachchildenv.DetachChildEnvironmentRequest) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto) Test(org.junit.jupiter.api.Test)

Example 3 with EnvironmentDeletionDto

use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.

the class DataLakeClustersDeleteHandlerTest method setUp.

@BeforeEach
void setUp() {
    EnvironmentDto eventDto = EnvironmentDto.builder().withId(ENV_ID).withResourceCrn(RESOURCE_CRN).withName(ENV_NAME).build();
    EnvironmentDeletionDto build = EnvironmentDeletionDto.builder().withId(ENV_ID).withForceDelete(false).withEnvironmentDto(eventDto).build();
    when(environmentDtoEvent.getData()).thenReturn(build);
    when(environmentDtoEvent.getHeaders()).thenReturn(headers);
    doAnswer(i -> null).when(eventSender).sendEvent(baseNamedFlowEvent.capture(), any(Event.Headers.class));
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with EnvironmentDeletionDto

use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.

the class IdBrokerMappingsDeleteHandlerTest method setUp.

@BeforeEach
void setUp() {
    environmentDto = createEnvironmentDto();
    EnvironmentDeletionDto build = EnvironmentDeletionDto.builder().withId(ENVIRONMENT_ID).withForceDelete(false).withEnvironmentDto(environmentDto).build();
    environmentDtoEvent = new Event<>(headers, build);
    eventArgumentCaptor = ArgumentCaptor.forClass(BaseNamedFlowEvent.class);
    headersArgumentCaptor = ArgumentCaptor.forClass(Event.Headers.class);
}
Also used : BaseNamedFlowEvent(com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with EnvironmentDeletionDto

use of com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto in project cloudbreak by hortonworks.

the class RdbmsDeleteHandlerTest method setUp.

@BeforeEach
void setUp() {
    EnvironmentDto eventDto = EnvironmentDto.builder().withId(ENVIRONMENT_ID).withResourceCrn(ENVIRONMENT_CRN).withName(ENVIRONMENT_NAME).withCloudPlatform("AZURE").build();
    EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withId(ENVIRONMENT_ID).withForceDelete(false).withEnvironmentDto(eventDto).build();
    lenient().when(environmentDtoEvent.getData()).thenReturn(environmentDeletionDto);
    lenient().when(environmentDtoEvent.getHeaders()).thenReturn(headers);
    lenient().doAnswer(i -> null).when(eventSender).sendEvent(baseNamedFlowEventCaptor.capture(), any(Event.Headers.class));
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)38 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)34 EnvDeleteEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent)23 CommonContext (com.sequenceiq.flow.core.CommonContext)12 Map (java.util.Map)12 Bean (org.springframework.context.annotation.Bean)12 BeforeEach (org.junit.jupiter.api.BeforeEach)8 BaseNamedFlowEvent (com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent)4 Test (org.junit.jupiter.api.Test)4 Environment (com.sequenceiq.environment.environment.domain.Environment)3 EnvClusterDeleteFailedEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvClusterDeleteFailedEvent)3 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)3 ResourceEvent (com.sequenceiq.cloudbreak.event.ResourceEvent)2 EnvironmentStatus (com.sequenceiq.environment.environment.EnvironmentStatus)2 PollingConfig (com.sequenceiq.environment.util.PollingConfig)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Headers (reactor.bus.Event.Headers)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 ExceptionResponse (com.sequenceiq.cloudbreak.common.exception.ExceptionResponse)1