use of com.sequenceiq.cloudbreak.domain.view.ClusterTemplateView in project cloudbreak by hortonworks.
the class BlueprintServiceTest method testDeletionWithTerminatedClustersNonTerminatedStacks.
@Test
public void testDeletionWithTerminatedClustersNonTerminatedStacks() {
Blueprint blueprint = getBlueprint("name", USER_MANAGED);
Set<Cluster> clusters = new HashSet<>();
clusters.add(getCluster("c1", 1L, blueprint, DetailedStackStatus.PRE_DELETE_IN_PROGRESS));
clusters.add(getCluster("c2", 1L, blueprint, DetailedStackStatus.DELETE_IN_PROGRESS));
clusters.add(getCluster("c3", 1L, blueprint, DetailedStackStatus.DELETE_COMPLETED));
ClusterTemplateView clusterTemplateView = new ClusterTemplateView();
clusterTemplateView.setName("ClusterDefinition");
when(clusterTemplateViewService.findAllByStackIds(any())).thenReturn(Set.of(clusterTemplateView));
when(clusterService.findByBlueprint(any())).thenReturn(clusters);
BadRequestException exception = Assertions.assertThrows(BadRequestException.class, () -> underTest.delete(blueprint));
assertEquals("There is a cluster ['ClusterDefinition'] which uses cluster template 'name'. " + "Please remove this cluster before deleting the cluster template.", exception.getMessage());
}
use of com.sequenceiq.cloudbreak.domain.view.ClusterTemplateView in project cloudbreak by hortonworks.
the class BlueprintServiceTest method testDeletionWithTerminatedAndNonTerminatedClusters.
@Test
public void testDeletionWithTerminatedAndNonTerminatedClusters() {
Blueprint blueprint = getBlueprint("name", USER_MANAGED);
Set<Cluster> clusters = new HashSet<>();
clusters.add(getCluster("c1", 1L, blueprint, DetailedStackStatus.PRE_DELETE_IN_PROGRESS));
clusters.add(getCluster("c2", 1L, blueprint, DetailedStackStatus.DELETE_COMPLETED));
ClusterTemplateView clusterTemplateView = new ClusterTemplateView();
clusterTemplateView.setName("ClusterDefinition1");
ClusterTemplateView clusterTemplateView2 = new ClusterTemplateView();
clusterTemplateView2.setName("ClusterDefinition2");
when(clusterTemplateViewService.findAllByStackIds(any())).thenReturn(Set.of(clusterTemplateView, clusterTemplateView2));
when(clusterService.findByBlueprint(any())).thenReturn(clusters);
try {
underTest.delete(blueprint);
} catch (BadRequestException e) {
assertTrue(e.getMessage().contains("ClusterDefinition1"));
assertFalse(e.getMessage().contains("ClusterDefinition2"));
}
verify(clusterService, times(1)).saveAll(anyCollection());
}
use of com.sequenceiq.cloudbreak.domain.view.ClusterTemplateView in project cloudbreak by hortonworks.
the class BlueprintServiceTest method testDeletionWithNonTerminatedClusterAndStack.
@Test
public void testDeletionWithNonTerminatedClusterAndStack() {
Blueprint blueprint = getBlueprint("name", USER_MANAGED);
Cluster cluster = getCluster("c1", 1L, blueprint, DetailedStackStatus.AVAILABLE);
ClusterTemplateView clusterTemplateView = new ClusterTemplateView();
clusterTemplateView.setName("ClusterDefinition");
when(clusterTemplateViewService.findAllByStackIds(any())).thenReturn(Set.of(clusterTemplateView));
when(clusterService.findByBlueprint(any())).thenReturn(Set.of(cluster));
BadRequestException exception = Assertions.assertThrows(BadRequestException.class, () -> underTest.delete(blueprint));
assertEquals("There is a cluster ['ClusterDefinition'] which uses cluster template 'name'. " + "Please remove this cluster before deleting the cluster template.", exception.getMessage());
}
use of com.sequenceiq.cloudbreak.domain.view.ClusterTemplateView in project cloudbreak by hortonworks.
the class BlueprintServiceTest method testPrepareDeletionWhenHasOneCluster.
@Test
public void testPrepareDeletionWhenHasOneCluster() {
Blueprint blueprint = new Blueprint();
blueprint.setName("TemplateName");
Cluster templateCluster = getCluster("Cluster Name", 0L, blueprint, DetailedStackStatus.AVAILABLE);
ClusterTemplateView clusterTemplateView = new ClusterTemplateView();
clusterTemplateView.setName("ClusterDefinition");
when(clusterService.findByBlueprint(blueprint)).thenReturn(Set.of(templateCluster));
when(clusterTemplateViewService.findAllByStackIds(any())).thenReturn(Set.of(clusterTemplateView));
BadRequestException actual = Assertions.assertThrows(BadRequestException.class, () -> underTest.prepareDeletion(blueprint));
Assertions.assertEquals("There is a cluster ['ClusterDefinition'] which uses cluster template 'TemplateName'. " + "Please remove this cluster before deleting the cluster template.", actual.getMessage());
}
use of com.sequenceiq.cloudbreak.domain.view.ClusterTemplateView in project cloudbreak by hortonworks.
the class ClusterTemplateViewServiceTest method testPrepareCreation.
@Test
public void testPrepareCreation() {
BadRequestException expectedException = assertThrows(BadRequestException.class, () -> underTest.prepareCreation(new ClusterTemplateView()));
assertEquals("Cluster template creation is not supported from ClusterTemplateViewService", expectedException.getMessage());
}
Aggregations