Search in sources :

Example 1 with ResponseGenerator

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();
}
Also used : ResponseGenerator(com.cloud.api.ResponseGenerator) ResourceService(com.cloud.resource.ResourceService) Cluster(com.cloud.org.Cluster) Test(org.junit.Test)

Example 2 with ResponseGenerator

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() {
    };
}
Also used : ResponseGenerator(com.cloud.api.ResponseGenerator) ResourceService(com.cloud.resource.ResourceService) AddHostCmd(com.cloud.api.command.admin.host.AddHostCmd) Before(org.junit.Before)

Example 3 with ResponseGenerator

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());
}
Also used : ResponseGenerator(com.cloud.api.ResponseGenerator) ImageStoreResponse(com.cloud.api.response.ImageStoreResponse) StorageService(com.cloud.storage.StorageService) ImageStore(com.cloud.storage.ImageStore) Test(org.junit.Test)

Example 4 with ResponseGenerator

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();
}
Also used : ResponseGenerator(com.cloud.api.ResponseGenerator) UpdateCfgCmd(com.cloud.api.command.admin.config.UpdateCfgCmd) ConfigurationService(com.cloud.configuration.ConfigurationService) Before(org.junit.Before)

Example 5 with ResponseGenerator

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();
}
Also used : UserVm(com.cloud.uservm.UserVm) UserVmService(com.cloud.vm.UserVmService) ResponseGenerator(com.cloud.api.ResponseGenerator) UpdateVmNicIpCmd(com.cloud.api.command.user.vm.UpdateVmNicIpCmd) UserVmResponse(com.cloud.api.response.UserVmResponse) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

ResponseGenerator (com.cloud.api.ResponseGenerator)10 Test (org.junit.Test)6 Before (org.junit.Before)4 ResourceService (com.cloud.resource.ResourceService)3 UserVmResponse (com.cloud.api.response.UserVmResponse)2 ManagementService (com.cloud.server.ManagementService)2 UserVm (com.cloud.uservm.UserVm)2 UserVmService (com.cloud.vm.UserVmService)2 LinkedList (java.util.LinkedList)2 ServerApiException (com.cloud.api.ServerApiException)1 ListCfgsByCmd (com.cloud.api.command.admin.config.ListCfgsByCmd)1 UpdateCfgCmd (com.cloud.api.command.admin.config.UpdateCfgCmd)1 AddHostCmd (com.cloud.api.command.admin.host.AddHostCmd)1 UpdateHostPasswordCmd (com.cloud.api.command.admin.host.UpdateHostPasswordCmd)1 AddIpToVmNicCmd (com.cloud.api.command.user.vm.AddIpToVmNicCmd)1 UpdateVmNicIpCmd (com.cloud.api.command.user.vm.UpdateVmNicIpCmd)1 ImageStoreResponse (com.cloud.api.response.ImageStoreResponse)1 NicSecondaryIpResponse (com.cloud.api.response.NicSecondaryIpResponse)1 RegionResponse (com.cloud.api.response.RegionResponse)1 ConfigurationService (com.cloud.configuration.ConfigurationService)1