Search in sources :

Example 1 with ExperienceOperationFailedException

use of com.sequenceiq.environment.exception.ExperienceOperationFailedException in project cloudbreak by hortonworks.

the class LiftieConnectorServiceDeleteClusterTest method testWhenResponseReaderReturnsEmptyResultWhichThrowsIllegalStateExceptionThenIllegalStateExceptionShouldInvoke.

@Test
void testWhenResponseReaderReturnsEmptyResultWhichThrowsIllegalStateExceptionThenIllegalStateExceptionShouldInvoke() {
    when(getMockRetryableWebTarget().delete(getMockInvocationBuilder())).thenReturn(getMockResponse());
    when(getMockResponseReader().read(LIFTIE_CLUSTER_ENDPOINT_PATH, getMockResponse(), DeleteClusterResponse.class)).thenReturn(Optional.empty());
    ExperienceOperationFailedException expectedException = Assertions.assertThrows(ExperienceOperationFailedException.class, () -> getUnderTest().deleteCluster(TEST_CLUSTER_ID));
    assertEquals(LIFTIE_RESPONSE_RESOLVE_EXCEPTION_MSG, expectedException.getMessage());
}
Also used : ExperienceOperationFailedException(com.sequenceiq.environment.exception.ExperienceOperationFailedException) Test(org.junit.jupiter.api.Test)

Example 2 with ExperienceOperationFailedException

use of com.sequenceiq.environment.exception.ExperienceOperationFailedException in project cloudbreak by hortonworks.

the class LiftieConnectorServiceFetchPolicyTest method testWhenCallExecutionReturnsResponseButItThrowsRuntimeExceptionThenIllegalStateExceptionShouldInvoke.

@Test
void testWhenCallExecutionReturnsResponseButItThrowsRuntimeExceptionThenIllegalStateExceptionShouldInvoke() {
    when(getMockInvocationBuilderProvider().createInvocationBuilderForInternalActor(getMockWebTarget())).thenReturn(getMockInvocationBuilder());
    when(getMockRetryableWebTarget().get(getMockInvocationBuilder())).thenReturn(getMockResponse());
    doThrow(RuntimeException.class).when(getMockResponseReader()).read(any(), any(), any());
    ExperienceOperationFailedException expectedException = assertThrows(ExperienceOperationFailedException.class, () -> getUnderTest().getPolicy(TEST_CLOUD_PLATFORM));
    assertEquals(LIFTIE_RESPONSE_RESOLVE_EXCEPTION_MSG, expectedException.getMessage());
}
Also used : ExperienceOperationFailedException(com.sequenceiq.environment.exception.ExperienceOperationFailedException) Test(org.junit.jupiter.api.Test)

Example 3 with ExperienceOperationFailedException

use of com.sequenceiq.environment.exception.ExperienceOperationFailedException in project cloudbreak by hortonworks.

the class CommonExperienceConnectorServiceTest method testDeleteWorkspaceForEnvironmentWhenCallResultIsEmptyThenIllegalStateExceptionShouldCome.

@Test
void testDeleteWorkspaceForEnvironmentWhenCallResultIsEmptyThenIllegalStateExceptionShouldCome() {
    when(mockCommonExperienceWebTargetProvider.createWebTargetForClusterFetch(TEST_XP_BASE_PATH, TEST_ENV_CRN)).thenReturn(mockWebTarget);
    when(mockInvocationBuilderProvider.createInvocationBuilder(mockWebTarget)).thenReturn(mockInvocationBuilder);
    when(mockRetryableWebTarget.delete(mockInvocationBuilder)).thenReturn(null);
    ExperienceOperationFailedException expectedException = assertThrows(ExperienceOperationFailedException.class, () -> underTest.deleteWorkspaceForEnvironment(TEST_XP_BASE_PATH, TEST_ENV_CRN, NO_FORCE_DELETE));
    assertNotNull(expectedException);
    assertEquals(COMMON_XP_RESPONSE_RESOLVE_ERROR_MSG, expectedException.getMessage());
}
Also used : ExperienceOperationFailedException(com.sequenceiq.environment.exception.ExperienceOperationFailedException) Test(org.junit.jupiter.api.Test)

Example 4 with ExperienceOperationFailedException

use of com.sequenceiq.environment.exception.ExperienceOperationFailedException in project cloudbreak by hortonworks.

the class CommonExperienceConnectorServiceTest method testCollectPolicyWhenCallResultIsEmptyThenIllegalStateExceptionShouldCome.

@Test
void testCollectPolicyWhenCallResultIsEmptyThenIllegalStateExceptionShouldCome() {
    when(mockCommonExperienceWebTargetProvider.createWebTargetForPolicyFetch(TEST_XP_BASE_PATH, TEST_CLOUD_PLATFORM)).thenReturn(mockWebTarget);
    when(mockInvocationBuilderProvider.createInvocationBuilderForInternalActor(mockWebTarget)).thenReturn(mockInvocationBuilder);
    when(mockRetryableWebTarget.get(mockInvocationBuilder)).thenReturn(null);
    ExperienceOperationFailedException expectedException = assertThrows(ExperienceOperationFailedException.class, () -> underTest.collectPolicy(TEST_XP_BASE_PATH, TEST_CLOUD_PLATFORM));
    assertNotNull(expectedException);
    assertEquals(COMMON_XP_RESPONSE_RESOLVE_ERROR_MSG, expectedException.getMessage());
}
Also used : ExperienceOperationFailedException(com.sequenceiq.environment.exception.ExperienceOperationFailedException) Test(org.junit.jupiter.api.Test)

Example 5 with ExperienceOperationFailedException

use of com.sequenceiq.environment.exception.ExperienceOperationFailedException in project cloudbreak by hortonworks.

the class CommonExperienceConnectorServiceTest method testCollectPolicyWhenResponseReaderUnableToResolveResponseThenIllegalStateExceptionShouldCome.

@Test
@MockitoSettings(strictness = Strictness.LENIENT)
void testCollectPolicyWhenResponseReaderUnableToResolveResponseThenIllegalStateExceptionShouldCome() {
    when(mockCommonExperienceWebTargetProvider.createWebTargetForPolicyFetch(TEST_XP_BASE_PATH, TEST_CLOUD_PLATFORM)).thenReturn(mockWebTarget);
    when(mockInvocationBuilderProvider.createInvocationBuilderForInternalActor(mockWebTarget)).thenReturn(mockInvocationBuilder);
    when(mockRetryableWebTarget.get(mockInvocationBuilder)).thenReturn(mockResponse);
    when(mockCommonExperienceResponseReader.read(TEST_URI.toString(), mockResponse, ExperiencePolicyResponse.class)).thenReturn(Optional.empty());
    ExperienceOperationFailedException expectedException = assertThrows(ExperienceOperationFailedException.class, () -> underTest.collectPolicy(TEST_XP_BASE_PATH, TEST_CLOUD_PLATFORM));
    assertNotNull(expectedException);
    assertEquals(COMMON_XP_RESPONSE_RESOLVE_ERROR_MSG, expectedException.getMessage());
}
Also used : ExperienceOperationFailedException(com.sequenceiq.environment.exception.ExperienceOperationFailedException) Test(org.junit.jupiter.api.Test) MockitoSettings(org.mockito.junit.jupiter.MockitoSettings)

Aggregations

ExperienceOperationFailedException (com.sequenceiq.environment.exception.ExperienceOperationFailedException)25 Test (org.junit.jupiter.api.Test)16 ExperiencePolicyResponse (com.sequenceiq.environment.experience.policy.response.ExperiencePolicyResponse)7 RetryableWebTarget (com.sequenceiq.environment.experience.RetryableWebTarget)5 Invocation (javax.ws.rs.client.Invocation)5 WebTarget (javax.ws.rs.client.WebTarget)5 Response (javax.ws.rs.core.Response)5 NotNull (javax.validation.constraints.NotNull)4 DeleteClusterResponse (com.sequenceiq.environment.experience.liftie.responses.DeleteClusterResponse)3 ListClustersResponse (com.sequenceiq.environment.experience.liftie.responses.ListClustersResponse)3 LinkedHashMap (java.util.LinkedHashMap)3 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)2 Environment (com.sequenceiq.environment.environment.domain.Environment)2 EnvironmentExperienceDto (com.sequenceiq.environment.environment.dto.EnvironmentExperienceDto)2 ExperienceCluster (com.sequenceiq.environment.experience.ExperienceCluster)2 ExperienceConnectorService (com.sequenceiq.environment.experience.ExperienceConnectorService)2 CpInternalEnvironmentResponse (com.sequenceiq.environment.experience.common.responses.CpInternalEnvironmentResponse)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Logger (org.slf4j.Logger)2