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));
}
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);
}
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());
}
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));
}
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));
}
Aggregations