Search in sources :

Example 1 with StackApiView

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

the class StackApiViewServiceTest method testCanChangeCredentialWithNullStatus.

@Test
public void testCanChangeCredentialWithNullStatus() {
    StackApiView stackApiView = new StackApiView();
    stackApiView.setStackStatus(null);
    boolean result = stackApiViewService.canChangeCredential(stackApiView);
    assertFalse(result);
}
Also used : StackApiView(com.sequenceiq.cloudbreak.domain.view.StackApiView) Test(org.junit.Test)

Example 2 with StackApiView

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

the class StackApiViewServiceTest method testCanChangeCredentialWithStatusIsNotAvailable.

@Test
public void testCanChangeCredentialWithStatusIsNotAvailable() {
    StackApiView stackApiView = new StackApiView();
    StackStatusView stackStatusView = Mockito.mock(StackStatusView.class);
    when(stackStatusView.getStatus()).thenReturn(Status.CREATE_IN_PROGRESS);
    stackApiView.setStackStatus(stackStatusView);
    boolean result = stackApiViewService.canChangeCredential(stackApiView);
    assertFalse(result);
}
Also used : StackApiView(com.sequenceiq.cloudbreak.domain.view.StackApiView) StackStatusView(com.sequenceiq.cloudbreak.domain.view.StackStatusView) Test(org.junit.Test)

Example 3 with StackApiView

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

the class StackApiViewServiceTest method testCanChangeCredentialWithOngoingFlowOperation.

@Test
public void testCanChangeCredentialWithOngoingFlowOperation() {
    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(true);
    boolean result = stackApiViewService.canChangeCredential(stackApiView);
    assertFalse(result);
}
Also used : StackApiView(com.sequenceiq.cloudbreak.domain.view.StackApiView) StackStatusView(com.sequenceiq.cloudbreak.domain.view.StackStatusView) Test(org.junit.Test)

Example 4 with StackApiView

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

the class StackOperations method getForInternalCrn.

public StackViewV4Response getForInternalCrn(NameOrCrn nameOrCrn, StackType stackType) {
    LOGGER.info("Validate stack against internal user.");
    StackApiView stackApiView = stackApiViewService.retrieveStackByCrnAndType(nameOrCrn.getCrn(), stackType);
    LOGGER.info("Query Stack (view) successfully finished with crn {}", nameOrCrn.getCrn());
    StackViewV4Response stackViewV4Response = stackApiViewToStackViewV4ResponseConverter.convert(stackApiView);
    LOGGER.info("Adding environment name to the response.");
    environmentServiceDecorator.prepareEnvironment(stackViewV4Response);
    return stackViewV4Response;
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) StackApiView(com.sequenceiq.cloudbreak.domain.view.StackApiView)

Example 5 with StackApiView

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

the class StackListItemToStackApiViewConverter method convert.

public StackApiView convert(StackListItem item, Map<Long, Integer> stackInstanceCounts, List<HostGroupView> hostGroupViews) {
    StackApiView response = new StackApiView();
    response.setId(item.getId());
    response.setResourceCrn(item.getResourceCrn());
    response.setName(item.getName());
    response.setCloudPlatform(item.getCloudPlatform());
    response.setPlatformVariant(item.getPlatformVariant());
    response.setCreated(item.getCreated());
    StackStatusView stackStatusView = new StackStatusView();
    stackStatusView.setStatus(item.getStackStatus());
    response.setStackStatus(stackStatusView);
    response.setCluster(getClusterApiView(item, hostGroupViews));
    response.setNodeCount(stackInstanceCounts.get(item.getId()));
    response.setTunnel(item.getTunnel());
    response.setEnvironmentCrn(item.getEnvironmentCrn());
    response.setType(item.getType());
    response.setDatalakeCrn(item.getDatalakeCrn());
    response.setUserView(getUserView(item));
    response.setTerminated(item.getTerminated());
    response.setStackVersion(item.getStackVersion());
    response.getCluster().setStack(response);
    return response;
}
Also used : StackApiView(com.sequenceiq.cloudbreak.domain.view.StackApiView) StackStatusView(com.sequenceiq.cloudbreak.domain.view.StackStatusView)

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