use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.
the class DatahubDeletionServiceTest method deleteDatahubClustersForEnvironmentNoDatahubFound.
@Test
void deleteDatahubClustersForEnvironmentNoDatahubFound() {
PollingConfig pollingConfig = PollingConfig.builder().withSleepTime(0).withSleepTimeUnit(TimeUnit.SECONDS).withTimeout(0).withTimeoutTimeUnit(TimeUnit.SECONDS).build();
Environment environment = new Environment();
environment.setResourceCrn(ENV_CRN);
StackViewV4Responses responses = new StackViewV4Responses(Set.of());
when(datahubService.list(anyString())).thenReturn(responses);
underTest.deleteDatahubClustersForEnvironment(pollingConfig, environment, true);
verify(datahubService, never()).deleteMultiple(anyString(), any(), anyBoolean());
}
use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.
the class EnvironmentExperienceDeletionActionTest method testForceDeleteWitExperienceConnectorArgumentErrorShouldRethrow.
@Test
void testForceDeleteWitExperienceConnectorArgumentErrorShouldRethrow() {
doThrow(new IllegalArgumentException()).when(mockExperienceConnectorService).deleteConnectedExperiences(any());
assertThatThrownBy(() -> underTest.execute(new Environment(), FORCE_DELETE)).isExactlyInstanceOf(IllegalArgumentException.class);
verify(mockExperiencePollingFailureResolver, never()).getMessageForFailure(any());
}
use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.
the class EnvironmentExperienceDeletionActionTest method testExecuteWhenPollingResultWasNotSuccessfulAndExceptionHasGivenInThePollingResultPairThenExperienceOperationFailedExceptionShouldCome.
@Test
void testExecuteWhenPollingResultWasNotSuccessfulAndExceptionHasGivenInThePollingResultPairThenExperienceOperationFailedExceptionShouldCome() {
String resolvedMessage = "Because of reasons...";
String expectedExceptionMessage = FAILURE_BASIC_MSG + " " + resolvedMessage;
ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().failure().withException(new Exception()).build();
when(mockExperiencePollingFailureResolver.getMessageForFailure(extendedPollingResult)).thenReturn(resolvedMessage);
when(mockExperiencePollingService.pollWithTimeout(any(ExperienceDeletionRetrievalTask.class), any(ExperiencePollerObject.class), eq(Long.valueOf(EXPERIENCE_RETRYING_INTERVAL_IN_MILLISECONDS)), eq(EXPERIENCE_RETRYING_COUNT), eq(1))).thenReturn(extendedPollingResult);
ExperienceOperationFailedException expectedException = assertThrows(ExperienceOperationFailedException.class, () -> underTest.execute(new Environment(), NO_FORCE_DELETE));
assertNotNull(expectedException);
assertEquals(expectedExceptionMessage, expectedException.getMessage());
verify(mockExperiencePollingFailureResolver, times(ONCE)).getMessageForFailure(extendedPollingResult);
}
use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.
the class EnvironmentExperienceDeletionActionTest method testForceDeleteWitPollingErrorShouldNotThrow.
@Test
void testForceDeleteWitPollingErrorShouldNotThrow() {
ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().failure().build();
when(mockExperiencePollingService.pollWithTimeout(any(ExperienceDeletionRetrievalTask.class), any(ExperiencePollerObject.class), eq(Long.valueOf(EXPERIENCE_RETRYING_INTERVAL_IN_MILLISECONDS)), eq(EXPERIENCE_RETRYING_COUNT), eq(1))).thenReturn(extendedPollingResult);
underTest.execute(new Environment(), FORCE_DELETE);
verify(mockExperiencePollingFailureResolver, never()).getMessageForFailure(any());
}
use of com.sequenceiq.environment.environment.domain.Environment in project cloudbreak by hortonworks.
the class EnvironmentExperienceDeletionActionTest method testExecuteWhenPollingResultWasGotBackWithExitThenReCheckShouldHappen.
@Test
void testExecuteWhenPollingResultWasGotBackWithExitThenReCheckShouldHappen() {
ExtendedPollingResult extendedPollingResult = new ExtendedPollingResult.ExtendedPollingResultBuilder().exit().build();
when(mockExperiencePollingService.pollWithTimeout(any(ExperienceDeletionRetrievalTask.class), any(ExperiencePollerObject.class), eq(Long.valueOf(EXPERIENCE_RETRYING_INTERVAL_IN_MILLISECONDS)), eq(EXPERIENCE_RETRYING_COUNT), eq(1))).thenReturn(extendedPollingResult);
when(mockExperienceConnectorService.getConnectedExperienceCount(any(EnvironmentExperienceDto.class))).thenReturn(0);
underTest.execute(new Environment(), NO_FORCE_DELETE);
verify(mockExperienceConnectorService, times(ONCE)).getConnectedExperienceCount(any(EnvironmentExperienceDto.class));
}
Aggregations