Search in sources :

Example 21 with EnvironmentDeletionDto

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

the class FreeIpaDeletionHandlerTest method shouldNotCallFreeIpaServiceIfFreeIpaCreationIsDisabled.

@Test
public void shouldNotCallFreeIpaServiceIfFreeIpaCreationIsDisabled() {
    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(anEnvironmentWithoutParent(Boolean.FALSE)));
    victim.accept(new Event<>(environmentDeletionDto));
    verify(freeIpaService, never()).delete(ENVIRONMENT_CRN, true);
    verify(eventSender).sendEvent(any(BaseNamedFlowEvent.class), any(Event.Headers.class));
}
Also used : BaseNamedFlowEvent(com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto) Test(org.junit.jupiter.api.Test)

Example 22 with EnvironmentDeletionDto

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

the class FreeIpaDeletionHandlerTest method shouldDeleteFreeIpaIfParentDoesNotExist.

@Test
public void shouldDeleteFreeIpaIfParentDoesNotExist() {
    EnvironmentDto environmentDto = new EnvironmentDto();
    environmentDto.setId(CHILD_ENVIRONMENT_ID);
    EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(environmentDto).withForceDelete(true).withId(CHILD_ENVIRONMENT_ID).build();
    ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build();
    when(environmentService.findEnvironmentById(CHILD_ENVIRONMENT_ID)).thenReturn(of(anEnvironmentWithoutParent(Boolean.TRUE)));
    when(freeIpaService.describe(ENVIRONMENT_CRN)).thenReturn(of(new DescribeFreeIpaResponse()));
    when(freeIpaPollingService.pollWithTimeout(any(), any(), Mockito.eq(FreeIpaDeletionRetrievalTask.FREEIPA_RETRYING_INTERVAL), Mockito.eq(FreeIpaDeletionRetrievalTask.FREEIPA_RETRYING_COUNT), Mockito.eq(1))).thenReturn(extendedPollingResult);
    victim.accept(new Event<>(environmentDeletionDto));
    verify(freeIpaService).delete(ENVIRONMENT_CRN, true);
    verify(eventSender).sendEvent(any(BaseNamedFlowEvent.class), any(Event.Headers.class));
    verifyNoMoreInteractions(freeIpaService);
}
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) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto) Test(org.junit.jupiter.api.Test)

Example 23 with EnvironmentDeletionDto

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

the class FreeIpaDeletionHandlerTest method shouldNotDeleteDnsZoneWhenSiblingsExist.

@Test
public void shouldNotDeleteDnsZoneWhenSiblingsExist() throws Exception {
    EnvironmentDto environmentDto = new EnvironmentDto();
    environmentDto.setId(CHILD_ENVIRONMENT_ID);
    EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(environmentDto).withForceDelete(true).withId(CHILD_ENVIRONMENT_ID).build();
    Environment environment = anEnvironmentWithParent(CHILD_ENVIRONMENT_ID);
    when(environmentService.findEnvironmentById(CHILD_ENVIRONMENT_ID)).thenReturn(of(environment));
    when(environmentService.findAllByAccountIdAndParentEnvIdAndArchivedIsFalse(anyString(), eq(PARENT_ENVIRONMENT_ID))).thenReturn(List.of(environment, anEnvironmentWithParent(ANOTHER_CHILD_ENVIRONMENT_ID)));
    when(freeIpaService.describe(ENVIRONMENT_CRN)).thenReturn(of(new DescribeFreeIpaResponse()));
    victim.accept(new Event<>(environmentDeletionDto));
    verify(dnsV1Endpoint, never()).deleteDnsZoneBySubnet(eq(PARENT_ENVIRONMENT_CRN), any());
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) Environment(com.sequenceiq.environment.environment.domain.Environment) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto) Test(org.junit.jupiter.api.Test)

Example 24 with EnvironmentDeletionDto

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

the class NetworkDeleteHandlerTest 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)

Example 25 with EnvironmentDeletionDto

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

the class PublicKeyDeleteHandlerTest method setUp.

@BeforeEach
void setUp() {
    EnvironmentDto eventDto = EnvironmentDto.builder().withId(ENVIRONMENT_ID).withResourceCrn(ENVIRONMENT_CRN).withName(ENVIRONMENT_NAME).build();
    EnvironmentDeletionDto build = EnvironmentDeletionDto.builder().withId(ENVIRONMENT_ID).withForceDelete(false).withEnvironmentDto(eventDto).build();
    lenient().when(environmentDtoEvent.getData()).thenReturn(build);
    lenient().when(environmentDtoEvent.getHeaders()).thenReturn(headers);
    lenient().doAnswer(i -> null).when(eventSender).sendEvent(baseNamedFlowEvent.capture(), any(Headers.class));
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) Headers(reactor.bus.Event.Headers) 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