Search in sources :

Example 11 with AutoscaleStackV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response in project cloudbreak by hortonworks.

the class AutoscaleClusterCommonServiceTest method testGetClusterByNameWhenNotPresentInDBThenCBSyncByName.

@Test
public void testGetClusterByNameWhenNotPresentInDBThenCBSyncByName() {
    AutoscaleStackV4Response autoscaleStackV4Response = mock(AutoscaleStackV4Response.class);
    when(clusterService.findOneByStackNameAndTenant(TEST_CLUSTER_NAME, tenant)).thenReturn(Optional.empty());
    when(cloudbreakCommunicator.getAutoscaleClusterByName(TEST_CLUSTER_NAME, tenant)).thenReturn(autoscaleStackV4Response);
    when(autoscaleStackV4Response.getStackType()).thenReturn(StackType.WORKLOAD);
    when(clusterService.create(autoscaleStackV4Response)).thenReturn(getACluster().get());
    Cluster cluster = underTest.getClusterByCrnOrName(NameOrCrn.ofName(TEST_CLUSTER_NAME));
    assertEquals("Cluster Name should match", TEST_CLUSTER_NAME, cluster.getStackName());
    assertEquals("Cluster CRN should match", TEST_CLUSTER_CRN, cluster.getStackCrn());
}
Also used : AutoscaleStackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response) Cluster(com.sequenceiq.periscope.domain.Cluster) Test(org.junit.Test)

Example 12 with AutoscaleStackV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response in project cloudbreak by hortonworks.

the class AutoscaleClusterCommonServiceTest method testGetClusterByCRNWhenNotPresentInDBThenCBSyncByCrn.

@Test
public void testGetClusterByCRNWhenNotPresentInDBThenCBSyncByCrn() {
    AutoscaleStackV4Response autoscaleStackV4Response = mock(AutoscaleStackV4Response.class);
    when(clusterService.findOneByStackCrnAndTenant(TEST_CLUSTER_CRN, tenant)).thenReturn(Optional.empty());
    when(cloudbreakCommunicator.getAutoscaleClusterByCrn(TEST_CLUSTER_CRN)).thenReturn(autoscaleStackV4Response);
    when(autoscaleStackV4Response.getStackType()).thenReturn(StackType.WORKLOAD);
    when(clusterService.create(autoscaleStackV4Response)).thenReturn(getACluster().get());
    Cluster cluster = underTest.getClusterByCrnOrName(NameOrCrn.ofCrn(TEST_CLUSTER_CRN));
    assertEquals("Cluster Name should match", TEST_CLUSTER_NAME, cluster.getStackName());
    assertEquals("Cluster CRN should match", TEST_CLUSTER_CRN, cluster.getStackCrn());
}
Also used : AutoscaleStackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response) Cluster(com.sequenceiq.periscope.domain.Cluster) Test(org.junit.Test)

Aggregations

AutoscaleStackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.AutoscaleStackV4Response)12 Test (org.junit.Test)7 RejectedThread (com.sequenceiq.periscope.model.RejectedThread)4 Cluster (com.sequenceiq.periscope.domain.Cluster)3 AutoscaleStack (com.sequenceiq.cloudbreak.domain.projection.AutoscaleStack)2 EvaluatorExecutor (com.sequenceiq.periscope.monitor.evaluator.EvaluatorExecutor)2 Supplier (java.util.function.Supplier)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Strings (com.google.common.base.Strings)1 AuthorizationResourceNamesProvider (com.sequenceiq.authorization.service.AuthorizationResourceNamesProvider)1 ResourceWithId (com.sequenceiq.authorization.service.list.ResourceWithId)1 StackType (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType)1 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)1 DELETE_IN_PROGRESS (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.DELETE_IN_PROGRESS)1 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)1 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)1 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)1 StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)1 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)1 Measure (com.sequenceiq.cloudbreak.aspect.Measure)1