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());
}
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());
}
Aggregations