Assert.assertNotNull("Expect host-level overrides", dc.getHostOverrides());
Assert.assertEquals("Expect one host-level override", 1, dc.getHostOverrides().size());
}
public ClusterEntity createDummyData() {
ClusterEntity clusterEntity = new ClusterEntity();
clusterEntity.setClusterName("test_cluster1");
clusterEntity.setClusterInfo("test_cluster_info1");
HostEntity host1 = new HostEntity();
HostEntity host2 = new HostEntity();
HostEntity host3 = new HostEntity();
host1.setHostName("test_host1");
host2.setHostName("test_host2");
host3.setHostName("test_host3");
host1.setIpv4("192.168.0.1");
host2.setIpv4("192.168.0.2");
host3.setIpv4("192.168.0.3");
List<HostEntity> hostEntities = new ArrayList<HostEntity>();
hostEntities.add(host1);
hostEntities.add(host2);
clusterEntity.setHostEntities(hostEntities);
clusterEntity.setClusterConfigEntities(Collections.EMPTY_LIST);
//both sides of relation should be set when modifying in runtime
host1.setClusterEntities(Arrays.asList(clusterEntity));
host2.setClusterEntities(Arrays.asList(clusterEntity));
HostStateEntity hostStateEntity1 = new HostStateEntity();
hostStateEntity1.setCurrentState(HostState.HEARTBEAT_LOST);
hostStateEntity1.setHostEntity(host1);
HostStateEntity hostStateEntity2 = new HostStateEntity();
hostStateEntity2.setCurrentState(HostState.HEALTHY);
hostStateEntity2.setHostEntity(host2);
host1.setHostStateEntity(hostStateEntity1);
host2.setHostStateEntity(hostStateEntity2);
ClusterServiceEntity clusterServiceEntity = new ClusterServiceEntity();
clusterServiceEntity.setServiceName("HDFS");
clusterServiceEntity.setClusterEntity(clusterEntity);
clusterServiceEntity.setServiceComponentDesiredStateEntities(
Collections.EMPTY_LIST);
clusterServiceEntity.setServiceConfigMappings(Collections.EMPTY_LIST);
ServiceDesiredStateEntity stateEntity = mock(ServiceDesiredStateEntity.class);
Gson gson = new Gson();
when(stateEntity.getDesiredStackVersion()).thenReturn(gson.toJson(new StackId("HDP-0.1"),
StackId.class));
clusterServiceEntity.setServiceDesiredStateEntity(stateEntity);
List<ClusterServiceEntity> clusterServiceEntities = new ArrayList<ClusterServiceEntity>();
clusterServiceEntities.add(clusterServiceEntity);
clusterEntity.setClusterServiceEntities(clusterServiceEntities);
return clusterEntity;
}