use of com.sequenceiq.environment.environment.domain.EnvironmentView in project cloudbreak by hortonworks.
the class EnvironmentResourceDeletionServiceTest method setup.
@BeforeEach
void setup() {
environment = new EnvironmentView();
environment.setId(1L);
environment.setName(ENVIRONMENT_NAME);
environment.setResourceCrn(ENVIRONMENT_CRN);
}
use of com.sequenceiq.environment.environment.domain.EnvironmentView in project cloudbreak by hortonworks.
the class DataLakeClustersDeleteHandlerTest method accept.
@Test
void accept() {
EnvironmentView environment = new EnvironmentView();
when(environmentViewService.getById(ENV_ID)).thenReturn(environment);
underTest.accept(environmentDtoEvent);
verify(sdxDeleteService).deleteSdxClustersForEnvironment(any(PollingConfig.class), eq(environment), eq(false));
verify(eventSender).sendEvent(any(EnvDeleteEvent.class), eq(headers));
verify(eventSender, never()).sendEvent(any(EnvClusterDeleteFailedEvent.class), any());
EnvDeleteEvent capturedDeleteEvent = (EnvDeleteEvent) baseNamedFlowEvent.getValue();
assertThat(capturedDeleteEvent.getResourceName()).isEqualTo(ENV_NAME);
assertThat(capturedDeleteEvent.getResourceId()).isEqualTo(ENV_ID);
assertThat(capturedDeleteEvent.getResourceCrn()).isEqualTo(RESOURCE_CRN);
assertThat(capturedDeleteEvent.selector()).isEqualTo("FINISH_ENV_CLUSTERS_DELETE_EVENT");
}
use of com.sequenceiq.environment.environment.domain.EnvironmentView in project cloudbreak by hortonworks.
the class SdxDeleteServiceTest method deleteSdxClustersForEnvironmentWhenSdxIsEmptyButDatalakeNot.
@Test
void deleteSdxClustersForEnvironmentWhenSdxIsEmptyButDatalakeNot() {
PollingConfig pollingConfig = getPollingConfig();
EnvironmentView environment = getEnvironmentView();
when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(emptySet());
when(environmentResourceDeletionService.getDatalakeClusterNames(environment)).thenReturn(Set.of("name"));
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
when(stackV4Endpoint.list(anyLong(), anyString(), anyBoolean())).thenReturn(new StackViewV4Responses());
underTest.deleteSdxClustersForEnvironment(pollingConfig, environment, true);
verify(stackV4Endpoint).deleteInternal(eq(0L), eq("name"), eq(true), nullable(String.class));
}
use of com.sequenceiq.environment.environment.domain.EnvironmentView in project cloudbreak by hortonworks.
the class SdxDeleteServiceTest method deleteSdxClustersForEnvironment.
@Test
void deleteSdxClustersForEnvironment() {
PollingConfig pollingConfig = getPollingConfig();
EnvironmentView environment = getEnvironmentView();
String sdxCrn1 = "crn:cdp:datalake:us-west-1:tenant:datalake:crn1";
String sdxCrn2 = "crn:cdp:sdxsvc:us-west-1:tenant:instance:crn2";
when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(Set.of(sdxCrn1, sdxCrn2));
when(platformAwareSdxConnector.getAttemptResultForDeletion(any(), any(), any())).thenReturn(AttemptResults.finishWith(null));
underTest.deleteSdxClustersForEnvironment(pollingConfig, environment, true);
verify(platformAwareSdxConnector).delete(eq(sdxCrn1), eq(true));
verify(platformAwareSdxConnector).delete(eq(sdxCrn2), eq(true));
verifyNoMoreInteractions(platformAwareSdxConnector);
}
use of com.sequenceiq.environment.environment.domain.EnvironmentView in project cloudbreak by hortonworks.
the class EnvironmentDeletionServiceTest method deleteMultipleByNames.
@Test
public void deleteMultipleByNames() {
Set<String> names = Set.of("name1", "name2");
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.findByNamesInAccount(eq(names), eq(ACCOUNT_ID))).thenReturn(envs);
assertEquals(expected, environmentDeletionServiceWired.deleteMultipleByNames(names, ACCOUNT_ID, USER, false, false).size());
verify(environmentDeletionServiceWired, times(expected)).delete(any(), eq(USER), anyBoolean(), anyBoolean());
}
Aggregations