use of org.apache.cloudstack.api.ResponseGenerator 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 org.apache.cloudstack.api.ResponseGenerator in project cloudstack by apache.
the class AddClusterCmdTest method testExecuteForResult.
@Test
public void testExecuteForResult() throws Exception {
resourceService = Mockito.mock(ResourceService.class);
responseGenerator = Mockito.mock(ResponseGenerator.class);
addClusterCmd._resourceService = resourceService;
addClusterCmd._responseGenerator = responseGenerator;
Cluster cluster = Mockito.mock(Cluster.class);
Cluster[] clusterArray = new Cluster[] { cluster };
Mockito.doReturn(Arrays.asList(clusterArray)).when(resourceService).discoverCluster(addClusterCmd);
addClusterCmd.execute();
}
use of org.apache.cloudstack.api.ResponseGenerator in project cloudstack by apache.
the class UpdateCfgCmdTest method setUp.
@Override
@Before
public void setUp() {
responseGenerator = Mockito.mock(ResponseGenerator.class);
configService = Mockito.mock(ConfigurationService.class);
updateCfgCmd = new UpdateCfgCmd();
}
use of org.apache.cloudstack.api.ResponseGenerator 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();
}
use of org.apache.cloudstack.api.ResponseGenerator in project cloudstack by apache.
the class AddIpToVmNicTest method testCreateSuccess.
@Test
public void testCreateSuccess() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
NetworkService networkService = Mockito.mock(NetworkService.class);
AddIpToVmNicCmd ipTonicCmd = Mockito.mock(AddIpToVmNicCmd.class);
NicSecondaryIp secIp = Mockito.mock(NicSecondaryIp.class);
Mockito.when(networkService.allocateSecondaryGuestIP(Matchers.anyLong(), Matchers.anyString())).thenReturn(secIp);
ipTonicCmd._networkService = networkService;
responseGenerator = Mockito.mock(ResponseGenerator.class);
NicSecondaryIpResponse ipres = Mockito.mock(NicSecondaryIpResponse.class);
Mockito.when(responseGenerator.createSecondaryIPToNicResponse(secIp)).thenReturn(ipres);
ipTonicCmd._responseGenerator = responseGenerator;
ipTonicCmd.execute();
}
Aggregations