use of com.cloud.vm.UserVmService in project cloudstack by apache.
the class UpdateVmNicIpTest method testFailure.
@Test
public void testFailure() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
UserVmService userVmService = Mockito.mock(UserVmService.class);
updateVmNicIpCmd = Mockito.mock(UpdateVmNicIpCmd.class);
Mockito.when(userVmService.updateNicIpForVirtualMachine(Mockito.any(UpdateVmNicIpCmd.class))).thenReturn(null);
updateVmNicIpCmd._userVmService = userVmService;
updateVmNicIpCmd._responseGenerator = responseGenerator;
try {
updateVmNicIpCmd.execute();
} catch (ServerApiException exception) {
Assert.assertEquals("Failed to update ip address on vm NIC. Refer to server logs for details.", exception.getDescription());
}
}
use of com.cloud.vm.UserVmService in project cloudstack by apache.
the class ScaleVMCmdTest method testCreateSuccess.
@Test
public void testCreateSuccess() {
UserVmService userVmService = Mockito.mock(UserVmService.class);
UserVm userVm = Mockito.mock(UserVm.class);
try {
Mockito.when(userVmService.upgradeVirtualMachine(scaleVMCmd)).thenReturn(userVm);
} catch (Exception e) {
Assert.fail("Received exception when success expected " + e.getMessage());
}
ResponseGenerator responseGenerator = Mockito.mock(ResponseGenerator.class);
scaleVMCmd._responseGenerator = responseGenerator;
UserVmResponse userVmResponse = Mockito.mock(UserVmResponse.class);
//List<UserVmResponse> list = Mockito.mock(UserVmResponse.class);
//list.add(userVmResponse);
//LinkedList<UserVmResponse> mockedList = Mockito.mock(LinkedList.class);
//Mockito.when(mockedList.get(0)).thenReturn(userVmResponse);
List<UserVmResponse> list = new LinkedList<UserVmResponse>();
list.add(userVmResponse);
Mockito.when(responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", userVm)).thenReturn(list);
scaleVMCmd._userVmService = userVmService;
scaleVMCmd.execute();
}
use of com.cloud.vm.UserVmService in project cloudstack by apache.
the class ScaleVMCmdTest method testCreateFailure.
@Test
public void testCreateFailure() {
UserVmService userVmService = Mockito.mock(UserVmService.class);
try {
Mockito.when(userVmService.upgradeVirtualMachine(scaleVMCmd)).thenReturn(null);
} catch (Exception e) {
Assert.fail("Received exception when success expected " + e.getMessage());
}
scaleVMCmd._userVmService = userVmService;
try {
scaleVMCmd.execute();
} catch (ServerApiException exception) {
Assert.assertEquals("Failed to scale vm", exception.getDescription());
}
}
use of com.cloud.vm.UserVmService in project cloudstack by apache.
the class UpdateVmNicIpTest method testSuccess.
@Test
public void testSuccess() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
UserVmService userVmService = Mockito.mock(UserVmService.class);
updateVmNicIpCmd = Mockito.mock(UpdateVmNicIpCmd.class);
UserVm userVm = Mockito.mock(UserVm.class);
Mockito.when(userVmService.updateNicIpForVirtualMachine(Mockito.any(UpdateVmNicIpCmd.class))).thenReturn(userVm);
updateVmNicIpCmd._userVmService = userVmService;
responseGenerator = Mockito.mock(ResponseGenerator.class);
List<UserVmResponse> list = new LinkedList<UserVmResponse>();
UserVmResponse userVmResponse = Mockito.mock(UserVmResponse.class);
list.add(userVmResponse);
Mockito.when(responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", userVm)).thenReturn(list);
updateVmNicIpCmd._responseGenerator = responseGenerator;
updateVmNicIpCmd.execute();
}
Aggregations