Search in sources :

Example 6 with ResponseGenerator

use of com.cloud.api.ResponseGenerator in project cosmic by MissionCriticalCloud.

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(com.cloud.api.ResponseGenerator) ListCfgsByCmd(com.cloud.api.command.admin.config.ListCfgsByCmd) Before(org.junit.Before)

Example 7 with ResponseGenerator

use of com.cloud.api.ResponseGenerator in project cosmic by MissionCriticalCloud.

the class RegionCmdTest method testCreateSuccess.

@Test
public void testCreateSuccess() {
    final RegionService regionService = Mockito.mock(RegionService.class);
    final 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);
    final RegionResponse regionResponse = Mockito.mock(RegionResponse.class);
    Mockito.when(responseGenerator.createRegionResponse(region)).thenReturn(regionResponse);
    addRegionCmd._responseGenerator = responseGenerator;
    addRegionCmd.execute();
}
Also used : RegionResponse(com.cloud.api.response.RegionResponse) ResponseGenerator(com.cloud.api.ResponseGenerator) Region(com.cloud.region.Region) RegionService(com.cloud.region.RegionService) Test(org.junit.Test)

Example 8 with ResponseGenerator

use of com.cloud.api.ResponseGenerator in project cosmic by MissionCriticalCloud.

the class ScaleVMCmdTest method testCreateSuccess.

@Test
public void testCreateSuccess() {
    final UserVmService userVmService = Mockito.mock(UserVmService.class);
    final UserVm userVm = Mockito.mock(UserVm.class);
    try {
        Mockito.when(userVmService.upgradeVirtualMachine(scaleVMCmd)).thenReturn(userVm);
    } catch (final Exception e) {
        Assert.fail("Received exception when success expected " + e.getMessage());
    }
    final ResponseGenerator responseGenerator = Mockito.mock(ResponseGenerator.class);
    scaleVMCmd._responseGenerator = responseGenerator;
    final 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);
    final List<UserVmResponse> list = new LinkedList<>();
    list.add(userVmResponse);
    Mockito.when(responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", userVm)).thenReturn(list);
    scaleVMCmd._userVmService = userVmService;
    scaleVMCmd.execute();
}
Also used : UserVm(com.cloud.uservm.UserVm) UserVmService(com.cloud.vm.UserVmService) ResponseGenerator(com.cloud.api.ResponseGenerator) UserVmResponse(com.cloud.api.response.UserVmResponse) ServerApiException(com.cloud.api.ServerApiException) ExpectedException(org.junit.rules.ExpectedException) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 9 with ResponseGenerator

use of com.cloud.api.ResponseGenerator in project cosmic by MissionCriticalCloud.

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

Example 10 with ResponseGenerator

use of com.cloud.api.ResponseGenerator in project cosmic by MissionCriticalCloud.

the class AddIpToVmNicTest method testCreateSuccess.

@Test
public void testCreateSuccess() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
    final NetworkService networkService = Mockito.mock(NetworkService.class);
    final AddIpToVmNicCmd ipTonicCmd = Mockito.mock(AddIpToVmNicCmd.class);
    final NicSecondaryIp secIp = Mockito.mock(NicSecondaryIp.class);
    Mockito.when(networkService.allocateSecondaryGuestIP(Matchers.anyLong(), Matchers.anyString())).thenReturn(secIp);
    ipTonicCmd._networkService = networkService;
    responseGenerator = Mockito.mock(ResponseGenerator.class);
    final NicSecondaryIpResponse ipres = Mockito.mock(NicSecondaryIpResponse.class);
    Mockito.when(responseGenerator.createSecondaryIPToNicResponse(secIp)).thenReturn(ipres);
    ipTonicCmd._responseGenerator = responseGenerator;
    ipTonicCmd.execute();
}
Also used : NicSecondaryIpResponse(com.cloud.api.response.NicSecondaryIpResponse) AddIpToVmNicCmd(com.cloud.api.command.user.vm.AddIpToVmNicCmd) ResponseGenerator(com.cloud.api.ResponseGenerator) NicSecondaryIp(com.cloud.vm.NicSecondaryIp) NetworkService(com.cloud.network.NetworkService) 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