use of com.cloud.api.ResponseGenerator in project cosmic by MissionCriticalCloud.
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;
final Cluster cluster = Mockito.mock(Cluster.class);
final Cluster[] clusterArray = new Cluster[] { cluster };
Mockito.doReturn(Arrays.asList(clusterArray)).when(resourceService).discoverCluster(addClusterCmd);
addClusterCmd.execute();
}
use of com.cloud.api.ResponseGenerator in project cosmic by MissionCriticalCloud.
the class AddHostCmdTest method setUp.
@Override
@Before
public void setUp() {
resourceService = Mockito.mock(ResourceService.class);
responseGenerator = Mockito.mock(ResponseGenerator.class);
addHostCmd = new AddHostCmd() {
};
}
use of com.cloud.api.ResponseGenerator in project cosmic by MissionCriticalCloud.
the class AddSecondaryStorageCmdTest method testExecuteForResult.
@Test
public void testExecuteForResult() throws Exception {
final StorageService resourceService = Mockito.mock(StorageService.class);
addImageStoreCmd._storageService = resourceService;
final ImageStore store = Mockito.mock(ImageStore.class);
Mockito.when(resourceService.discoverImageStore(anyString(), anyString(), anyString(), anyLong(), (Map) anyObject())).thenReturn(store);
final ResponseGenerator responseGenerator = Mockito.mock(ResponseGenerator.class);
addImageStoreCmd._responseGenerator = responseGenerator;
final ImageStoreResponse responseHost = new ImageStoreResponse();
responseHost.setName("Test");
Mockito.when(responseGenerator.createImageStoreResponse(store)).thenReturn(responseHost);
addImageStoreCmd.execute();
Mockito.verify(responseGenerator).createImageStoreResponse(store);
final ImageStoreResponse actualResponse = (ImageStoreResponse) addImageStoreCmd.getResponseObject();
Assert.assertEquals(responseHost, actualResponse);
Assert.assertEquals("addimagestoreresponse", actualResponse.getResponseName());
}
use of com.cloud.api.ResponseGenerator in project cosmic by MissionCriticalCloud.
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 com.cloud.api.ResponseGenerator in project cosmic by MissionCriticalCloud.
the class UpdateVmNicIpTest method testSuccess.
@Test
public void testSuccess() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
final UserVmService userVmService = Mockito.mock(UserVmService.class);
updateVmNicIpCmd = Mockito.mock(UpdateVmNicIpCmd.class);
final UserVm userVm = Mockito.mock(UserVm.class);
Mockito.when(userVmService.updateNicIpForVirtualMachine(Mockito.any(UpdateVmNicIpCmd.class))).thenReturn(userVm);
updateVmNicIpCmd._userVmService = userVmService;
responseGenerator = Mockito.mock(ResponseGenerator.class);
final List<UserVmResponse> list = new LinkedList<>();
final 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