com.vmware.vim25.RuntimeFault Java Examples

The following examples show how to use com.vmware.vim25.RuntimeFault. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClusterComputeResourceServiceTest.java    From cs-actions with Apache License 2.0 6 votes vote down vote up
@Test
public void createAffinityRuleVmGroupNotFoundException() throws Exception {
    VmInputs vmInputs = getVmInputs();
    doReturn(clusterConfigInfoExMock).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    doReturn(false).when(clusterComputeResourceServiceSpy, RULE_EXISTS,
            any(ClusterConfigInfoEx.class), any(String.class));
    whenNew(ClusterVmHostRuleInfo.class).withNoArguments().thenReturn(clusterVmHostRuleInfoMock);
    doReturn(clusterVmHostRuleInfoMock).when(clusterComputeResourceServiceSpy, ADD_AFFINE_GROUP_TO_RULE,
            any(ClusterVmHostRuleInfo.class), any(ClusterConfigInfoEx.class), any(String.class));
    doThrow(new RuntimeFaultFaultMsg(VM_GROUP_DOES_NOT_EXIST, new RuntimeFault()))
            .when(clusterComputeResourceServiceSpy, EXISTS_GROUP,
                    any(ClusterConfigInfoEx.class), any(String.class), any(Class.class));
    thrownException.expectMessage(VM_GROUP_DOES_NOT_EXIST);

    clusterComputeResourceServiceSpy.createAffinityRule(httpInputsMock, vmInputs, "affineHostGroupName", "");
}
 
Example #2
Source File: ClusterComputeResourceServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@Test
public void createVmGroupThrowsException() throws Exception {
    vmGroupMockInitializationOnExceptionThrown();
    VmInputs vmInputs = getVmInputs();
    List<String> vmList = getList();
    when(vimPortMock.reconfigureComputeResourceTask(any(ManagedObjectReference.class), any(ClusterConfigSpecEx.class), any(Boolean.class)))
            .thenThrow(new RuntimeFaultFaultMsg(CLUSTER_CONFIGURATION_FAILED, new RuntimeFault()));
    thrownException.expectMessage(CLUSTER_CONFIGURATION_FAILED);

    clusterComputeResourceService.createVmGroup(httpInputsMock, vmInputs, vmList);
}
 
Example #3
Source File: ClusterComputeResourceServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@Test
public void deleteVmGroupThrowsException() throws Exception {
    vmGroupMockInitializationOnExceptionThrown();
    VmInputs vmInputs = getVmInputs();
    when(vimPortMock.reconfigureComputeResourceTask(any(ManagedObjectReference.class), any(ClusterConfigSpecEx.class), any(Boolean.class)))
            .thenThrow(new RuntimeFaultFaultMsg(CLUSTER_CONFIGURATION_FAILED, new RuntimeFault()));
    thrownException.expectMessage(CLUSTER_CONFIGURATION_FAILED);

    clusterComputeResourceService.deleteVmGroup(httpInputsMock, vmInputs);
}
 
Example #4
Source File: ClusterComputeResourceServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@Test
public void listVmGroupsThrowsException() 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", "", ClusterVmGroup.class);
}
 
Example #5
Source File: ClusterComputeResourceServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@Test
public void createHostGroupThrowsException() throws Exception {
    hostGroupMockInitializationOnExceptionThrown();
    VmInputs vmInputs = getVmInputs();
    List<String> hostList = getList();
    when(vimPortMock.reconfigureComputeResourceTask(any(ManagedObjectReference.class), any(ClusterConfigSpecEx.class), any(Boolean.class)))
            .thenThrow(new RuntimeFaultFaultMsg(CLUSTER_CONFIGURATION_FAILED, new RuntimeFault()));
    thrownException.expectMessage(CLUSTER_CONFIGURATION_FAILED);

    clusterComputeResourceService.createHostGroup(httpInputsMock, vmInputs, hostList);
}
 
Example #6
Source File: ClusterComputeResourceServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@Test
public void deleteHostGroupThrowsException() throws Exception {
    hostGroupMockInitializationOnExceptionThrown();
    VmInputs vmInputs = getVmInputs();
    when(vimPortMock.reconfigureComputeResourceTask(any(ManagedObjectReference.class), any(ClusterConfigSpecEx.class), any(Boolean.class)))
            .thenThrow(new RuntimeFaultFaultMsg(CLUSTER_CONFIGURATION_FAILED, new RuntimeFault()));

    thrownException.expectMessage(CLUSTER_CONFIGURATION_FAILED);
    clusterComputeResourceService.deleteHostGroup(httpInputsMock, vmInputs);
}
 
Example #7
Source File: ClusterComputeResourceServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #8
Source File: ClusterComputeResourceServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@Test
public void createAffinityRuleThrowsRuleAlreadyExistsException() throws Exception {
    VmInputs vmInputs = getVmInputs();
    ClusterConfigInfoEx clusterConfigInfoEx = new ClusterConfigInfoEx();
    doReturn(clusterConfigInfoEx).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    doThrow(new RuntimeFaultFaultMsg(String.format(RULE_ALREADY_EXISTS, vmInputs.getRuleName()), new RuntimeFault())).when(clusterComputeResourceServiceSpy, RULE_EXISTS,
            any(ClusterConfigInfoEx.class), any(String.class));
    thrownException.expectMessage(String.format(RULE_ALREADY_EXISTS, vmInputs.getRuleName()));

    clusterComputeResourceServiceSpy.createAffinityRule(httpInputsMock, vmInputs, "affineHostGroupName", "");
}
 
Example #9
Source File: ClusterComputeResourceServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@Test
public void createAffinityRuleThrowsAffineHostGroupNotFoundException() throws Exception {
    VmInputs vmInputs = getVmInputs();
    doReturn(clusterConfigInfoExMock).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    doReturn(false).when(clusterComputeResourceServiceSpy, RULE_EXISTS,
            any(ClusterConfigInfoEx.class), any(String.class));
    doThrow(new RuntimeFaultFaultMsg(AFFINE_HOST_GROUP_DOES_NOT_EXIST, new RuntimeFault()))
            .when(clusterComputeResourceServiceSpy, ADD_AFFINE_GROUP_TO_RULE,
                    any(ClusterVmHostRuleInfo.class), any(ClusterConfigInfoEx.class), any(String.class));
    thrownException.expectMessage(AFFINE_HOST_GROUP_DOES_NOT_EXIST);

    clusterComputeResourceServiceSpy.createAffinityRule(httpInputsMock, vmInputs, "affineHostGroupName", "");
}
 
Example #10
Source File: ClusterComputeResourceServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@Test
public void createAffinityRuleThrowsAntiAffineHostGroupNotFoundException() throws Exception {
    VmInputs vmInputs = getVmInputs();
    doReturn(clusterConfigInfoExMock).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    doReturn(false).when(clusterComputeResourceServiceSpy, RULE_EXISTS,
            any(ClusterConfigInfoEx.class), any(String.class));
    doThrow(new RuntimeFaultFaultMsg(ANTI_AFFINE_HOST_GROUP_DOES_NOT_EXIST, new RuntimeFault()))
            .when(clusterComputeResourceServiceSpy, ADD_ANTI_AFFINE_GROUP_TO_RULE,
                    any(ClusterVmHostRuleInfo.class), any(ClusterConfigInfoEx.class), any(String.class));
    thrownException.expectMessage(ANTI_AFFINE_HOST_GROUP_DOES_NOT_EXIST);

    clusterComputeResourceServiceSpy.createAffinityRule(httpInputsMock, vmInputs, "", "antiAffineHostGroup");
}
 
Example #11
Source File: ClusterComputeResourceServiceTest.java    From cs-actions with Apache License 2.0 5 votes vote down vote up
@Test
public void deleteClusterRuleThrowsException() throws Exception {
    VmInputs vmInputs = getVmInputs();
    doReturn(clusterConfigInfoExSpy).when(clusterComputeResourceServiceSpy, GET_CLUSTER_CONFIGURATION,
            any(ConnectionResources.class), any(ManagedObjectReference.class), any(String.class));
    doReturn(clusterRuleInfoListMock).when(clusterConfigInfoExSpy, GET_RULE);
    doThrow(new RuntimeFaultFaultMsg(String.format(CLUSTER_RULE_COULD_NOT_BE_FOUND, vmInputs.getRuleName()), new RuntimeFault()))
            .when(clusterComputeResourceServiceSpy, GET_CLUSTER_RULE_INFO,
                    any(List.class), any(String.class));

    thrownException.expectMessage(String.format(CLUSTER_RULE_COULD_NOT_BE_FOUND, vmInputs.getRuleName()));
    clusterComputeResourceServiceSpy.deleteClusterRule(httpInputsMock, vmInputs);
}