Search in sources :

Example 1 with ResponseGenerator

use of org.apache.cloudstack.api.ResponseGenerator in project cloudstack by apache.

the class UpdateHostPasswordCmdTest method setUp.

@Override
@Before
public void setUp() {
    responseGenerator = Mockito.mock(ResponseGenerator.class);
    managementServer = Mockito.mock(ManagementService.class);
    resourceService = Mockito.mock(ResourceService.class);
    updateHostPasswordCmd = new UpdateHostPasswordCmd();
}
Also used : ManagementService(com.cloud.server.ManagementService) ResponseGenerator(org.apache.cloudstack.api.ResponseGenerator) ResourceService(com.cloud.resource.ResourceService) UpdateHostPasswordCmd(org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd) Before(org.junit.Before)

Example 2 with ResponseGenerator

use of org.apache.cloudstack.api.ResponseGenerator in project cloudstack by apache.

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(org.apache.cloudstack.api.ResponseGenerator) ResourceService(com.cloud.resource.ResourceService) AddHostCmd(org.apache.cloudstack.api.command.admin.host.AddHostCmd) Before(org.junit.Before)

Example 3 with ResponseGenerator

use of org.apache.cloudstack.api.ResponseGenerator in project cloudstack by apache.

the class AddSecondaryStorageCmdTest method testExecuteForResult.

@Test
public void testExecuteForResult() throws Exception {
    StorageService resourceService = Mockito.mock(StorageService.class);
    addImageStoreCmd._storageService = resourceService;
    ImageStore store = Mockito.mock(ImageStore.class);
    Mockito.when(resourceService.discoverImageStore(anyString(), anyString(), anyString(), anyLong(), (Map) anyObject())).thenReturn(store);
    ResponseGenerator responseGenerator = Mockito.mock(ResponseGenerator.class);
    addImageStoreCmd._responseGenerator = responseGenerator;
    ImageStoreResponse responseHost = new ImageStoreResponse();
    responseHost.setName("Test");
    Mockito.when(responseGenerator.createImageStoreResponse(store)).thenReturn(responseHost);
    addImageStoreCmd.execute();
    Mockito.verify(responseGenerator).createImageStoreResponse(store);
    ImageStoreResponse actualResponse = (ImageStoreResponse) addImageStoreCmd.getResponseObject();
    Assert.assertEquals(responseHost, actualResponse);
    Assert.assertEquals("addimagestoreresponse", actualResponse.getResponseName());
}
Also used : ResponseGenerator(org.apache.cloudstack.api.ResponseGenerator) ImageStoreResponse(org.apache.cloudstack.api.response.ImageStoreResponse) StorageService(com.cloud.storage.StorageService) ImageStore(com.cloud.storage.ImageStore) Test(org.junit.Test)

Example 4 with ResponseGenerator

use of org.apache.cloudstack.api.ResponseGenerator in project cloudstack by apache.

the class ListCfgCmdTest method setUp.

@Override
@Before
public void setUp() {
    responseGenerator = Mockito.mock(ResponseGenerator.class);
    mgr = Mockito.mock(ManagementService.class);
    listCfgsByCmd = new ListCfgsByCmd();
}
Also used : ManagementService(com.cloud.server.ManagementService) ResponseGenerator(org.apache.cloudstack.api.ResponseGenerator) ListCfgsByCmd(org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd) Before(org.junit.Before)

Example 5 with ResponseGenerator

use of org.apache.cloudstack.api.ResponseGenerator in project cloudstack by apache.

the class RegionCmdTest method testCreateSuccess.

@Test
public void testCreateSuccess() {
    RegionService regionService = Mockito.mock(RegionService.class);
    Region region = Mockito.mock(Region.class);
    Mockito.when(regionService.addRegion(Matchers.anyInt(), Matchers.anyString(), Matchers.anyString())).thenReturn(region);
    addRegionCmd._regionService = regionService;
    responseGenerator = Mockito.mock(ResponseGenerator.class);
    RegionResponse regionResponse = Mockito.mock(RegionResponse.class);
    Mockito.when(responseGenerator.createRegionResponse(region)).thenReturn(regionResponse);
    addRegionCmd._responseGenerator = responseGenerator;
    addRegionCmd.execute();
}
Also used : RegionResponse(org.apache.cloudstack.api.response.RegionResponse) ResponseGenerator(org.apache.cloudstack.api.ResponseGenerator) Region(org.apache.cloudstack.region.Region) RegionService(org.apache.cloudstack.region.RegionService) Test(org.junit.Test)

Aggregations

ResponseGenerator (org.apache.cloudstack.api.ResponseGenerator)11 Test (org.junit.Test)7 Before (org.junit.Before)4 ResourceService (com.cloud.resource.ResourceService)3 ManagementService (com.cloud.server.ManagementService)2 UserVm (com.cloud.uservm.UserVm)2 UserVmService (com.cloud.vm.UserVmService)2 LinkedList (java.util.LinkedList)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 UserVmResponse (org.apache.cloudstack.api.response.UserVmResponse)2 ExpectedException (org.junit.rules.ExpectedException)2 ConfigurationService (com.cloud.configuration.ConfigurationService)1 NetworkService (com.cloud.network.NetworkService)1 Cluster (com.cloud.org.Cluster)1 ImageStore (com.cloud.storage.ImageStore)1 Snapshot (com.cloud.storage.Snapshot)1 StorageService (com.cloud.storage.StorageService)1 VolumeApiService (com.cloud.storage.VolumeApiService)1 Account (com.cloud.user.Account)1 AccountService (com.cloud.user.AccountService)1