@Test public void listHostGroupsThrowsException() throws Exception { List<ClusterGroupInfo> clusterGroupInfoList = new ArrayList<>(); ClusterConfigInfoEx clusterConfigInfoEx = new ClusterConfigInfoEx(); clusterConfigInfoEx.getGroup().addAll(clusterGroupInfoList); doThrow(new RuntimeFaultFaultMsg(String.format(ErrorMessages.ANOTHER_FAILURE_MSG, "Cluster1"), new RuntimeFault())) .when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION, any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class)); thrownException.expectMessage(String.format(ErrorMessages.ANOTHER_FAILURE_MSG, "Cluster1")); clusterComputeResourceServiceSpy.listGroups(httpInputsMock, "Cluster1", "", ClusterHostGroup.class); }
public String listGroups(HttpInputs httpInputs, String clusterName, String delimiter, Class clazz) throws Exception { ConnectionResources connectionResources = new ConnectionResources(httpInputs); try { ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), clusterName); ClusterConfigInfoEx clusterConfigInfoEx = getClusterConfiguration(connectionResources, clusterMor, clusterName); List<String> groupNameList = new ArrayList<>(); for (ClusterGroupInfo clusterGroupInfo : clusterConfigInfoEx.getGroup()) { if (clusterGroupInfo.getClass().isAssignableFrom(clazz)) { groupNameList.add(clusterGroupInfo.getName()); } } return StringUtilities.join(groupNameList, delimiter); } finally { if (httpInputs.isCloseSession()) { connectionResources.getConnection().disconnect(); clearConnectionFromContext(httpInputs.getGlobalSessionObject()); } } }
ClusterComputeResourceService { public String listGroups(HttpInputs httpInputs, String clusterName, String delimiter, Class clazz) throws Exception { ConnectionResources connectionResources = new ConnectionResources(httpInputs); try { ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), clusterName); ClusterConfigInfoEx clusterConfigInfoEx = getClusterConfiguration(connectionResources, clusterMor, clusterName); List<String> groupNameList = new ArrayList<>(); for (ClusterGroupInfo clusterGroupInfo : clusterConfigInfoEx.getGroup()) { if (clusterGroupInfo.getClass().isAssignableFrom(clazz)) { groupNameList.add(clusterGroupInfo.getName()); } } return StringUtilities.join(groupNameList, delimiter); } finally { if (httpInputs.isCloseSession()) { connectionResources.getConnection().disconnect(); clearConnectionFromContext(httpInputs.getGlobalSessionObject()); } } } }
ClusterComputeResourceService { public String listGroups(HttpInputs httpInputs, String clusterName, String delimiter, Class clazz) throws Exception { ConnectionResources connectionResources = new ConnectionResources(httpInputs); try { ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), clusterName); ClusterConfigInfoEx clusterConfigInfoEx = getClusterConfiguration(connectionResources, clusterMor, clusterName); List<String> groupNameList = new ArrayList<>(); for (ClusterGroupInfo clusterGroupInfo : clusterConfigInfoEx.getGroup()) { if (clusterGroupInfo.getClass().isAssignableFrom(clazz)) { groupNameList.add(clusterGroupInfo.getName()); } } return StringUtilities.join(groupNameList, delimiter); } finally { if (httpInputs.isCloseSession()) { connectionResources.getConnection().disconnect(); clearConnectionFromContext(httpInputs.getGlobalSessionObject()); } } }  }
ClusterComputeResourceService { public String listGroups(HttpInputs httpInputs, String clusterName, String delimiter, Class clazz) throws Exception { ConnectionResources connectionResources = new ConnectionResources(httpInputs); try { ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), clusterName); ClusterConfigInfoEx clusterConfigInfoEx = getClusterConfiguration(connectionResources, clusterMor, clusterName); List<String> groupNameList = new ArrayList<>(); for (ClusterGroupInfo clusterGroupInfo : clusterConfigInfoEx.getGroup()) { if (clusterGroupInfo.getClass().isAssignableFrom(clazz)) { groupNameList.add(clusterGroupInfo.getName()); } } return StringUtilities.join(groupNameList, delimiter); } finally { if (httpInputs.isCloseSession()) { connectionResources.getConnection().disconnect(); clearConnectionFromContext(httpInputs.getGlobalSessionObject()); } } }  Map<String, String> updateOrAddVmOverride(final HttpInputs httpInputs, final VmInputs vmInputs, final String restartPriority); String getVmOverride(final HttpInputs httpInputs, final VmInputs vmInputs); Map<String, String> createVmGroup(HttpInputs httpInputs, VmInputs vmInputs, List<String> vmNameList); Map<String, String> deleteVmGroup(HttpInputs httpInputs, VmInputs vmInputs); String listGroups(HttpInputs httpInputs, String clusterName, String delimiter, Class clazz); Map<String, String> createHostGroup(HttpInputs httpInputs, VmInputs vmInputs, List<String> hostNameList); Map<String, String> deleteHostGroup(HttpInputs httpInputs, VmInputs vmInputs); Map<String, String> createAffinityRule(HttpInputs httpInputs, VmInputs vmInputs,
                                                  String affineHostGroupName, String antiAffineHostGroupName); Map<String, String> deleteClusterRule(HttpInputs httpInputs, VmInputs vmInputs); }
ClusterComputeResourceService { public String listGroups(HttpInputs httpInputs, String clusterName, String delimiter, Class clazz) throws Exception { ConnectionResources connectionResources = new ConnectionResources(httpInputs); try { ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), clusterName); ClusterConfigInfoEx clusterConfigInfoEx = getClusterConfiguration(connectionResources, clusterMor, clusterName); List<String> groupNameList = new ArrayList<>(); for (ClusterGroupInfo clusterGroupInfo : clusterConfigInfoEx.getGroup()) { if (clusterGroupInfo.getClass().isAssignableFrom(clazz)) { groupNameList.add(clusterGroupInfo.getName()); } } return StringUtilities.join(groupNameList, delimiter); } finally { if (httpInputs.isCloseSession()) { connectionResources.getConnection().disconnect(); clearConnectionFromContext(httpInputs.getGlobalSessionObject()); } } }  Map<String, String> updateOrAddVmOverride(final HttpInputs httpInputs, final VmInputs vmInputs, final String restartPriority); String getVmOverride(final HttpInputs httpInputs, final VmInputs vmInputs); Map<String, String> createVmGroup(HttpInputs httpInputs, VmInputs vmInputs, List<String> vmNameList); Map<String, String> deleteVmGroup(HttpInputs httpInputs, VmInputs vmInputs); String listGroups(HttpInputs httpInputs, String clusterName, String delimiter, Class clazz); Map<String, String> createHostGroup(HttpInputs httpInputs, VmInputs vmInputs, List<String> hostNameList); Map<String, String> deleteHostGroup(HttpInputs httpInputs, VmInputs vmInputs); Map<String, String> createAffinityRule(HttpInputs httpInputs, VmInputs vmInputs,
                                                  String affineHostGroupName, String antiAffineHostGroupName); Map<String, String> deleteClusterRule(HttpInputs httpInputs, VmInputs vmInputs);  }