Search in sources :

Example 6 with StackApiView

use of com.sequenceiq.cloudbreak.domain.view.StackApiView in project cloudbreak by hortonworks.

the class StackOperationsTest method testGetForInternalCrn.

@Test
public void testGetForInternalCrn() {
    when(cloudbreakUser.getUserCrn()).thenReturn("crn:altus:iam:us-west-1:altus:user:__internal__actor__");
    when(stackApiViewService.retrieveStackByCrnAndType(anyString(), any(StackType.class))).thenReturn(new StackApiView());
    when(stackApiViewToStackViewV4ResponseConverter.convert(any(StackApiView.class))).thenReturn(new StackViewV4Response());
    doNothing().when(environmentServiceDecorator).prepareEnvironment(any(StackViewV4Response.class));
    StackViewV4Response response = underTest.getForInternalCrn(NameOrCrn.ofCrn("myCrn"), STACK_TYPE);
    assertNotNull(response);
    verify(stackApiViewService, times(1)).retrieveStackByCrnAndType(anyString(), any(StackType.class));
    verify(stackApiViewToStackViewV4ResponseConverter, times(1)).convert(any(StackApiView.class));
    verify(environmentServiceDecorator, times(1)).prepareEnvironment(any(StackViewV4Response.class));
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) StackApiView(com.sequenceiq.cloudbreak.domain.view.StackApiView) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) Test(org.junit.Test)

Example 7 with StackApiView

use of com.sequenceiq.cloudbreak.domain.view.StackApiView in project cloudbreak by hortonworks.

the class StackApiViewServiceTest method testCanChangeCredentialHappyPath.

@Test
public void testCanChangeCredentialHappyPath() {
    Long stackId = 1L;
    StackApiView stackApiView = new StackApiView();
    stackApiView.setId(stackId);
    StackStatusView stackStatusView = Mockito.mock(StackStatusView.class);
    when(stackStatusView.getStatus()).thenReturn(Status.AVAILABLE);
    stackApiView.setStackStatus(stackStatusView);
    when(flowLogService.isOtherNonTerminationFlowRunning(stackId)).thenReturn(false);
    boolean result = stackApiViewService.canChangeCredential(stackApiView);
    assertTrue(result);
}
Also used : StackApiView(com.sequenceiq.cloudbreak.domain.view.StackApiView) StackStatusView(com.sequenceiq.cloudbreak.domain.view.StackStatusView) Test(org.junit.Test)

Aggregations

StackApiView (com.sequenceiq.cloudbreak.domain.view.StackApiView)7 Test (org.junit.Test)5 StackStatusView (com.sequenceiq.cloudbreak.domain.view.StackStatusView)4 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)2 StackType (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType)1