Search in sources :

Example 1 with RegionService

use of org.apache.cloudstack.region.RegionService in project cloudstack by apache.

the class RegionCmdTest method testCreateFailure.

@Test
public void testCreateFailure() {
    RegionService regionService = Mockito.mock(RegionService.class);
    Region region = Mockito.mock(Region.class);
    Mockito.when(regionService.addRegion(anyInt(), anyString(), isNull())).thenReturn(null);
    addRegionCmd._regionService = regionService;
    try {
        addRegionCmd.execute();
    } catch (ServerApiException exception) {
        assertEquals("Failed to add Region", exception.getDescription());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) Region(org.apache.cloudstack.region.Region) RegionService(org.apache.cloudstack.region.RegionService) Test(org.junit.Test)

Example 2 with RegionService

use of org.apache.cloudstack.region.RegionService 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(anyInt(), anyString(), isNull())).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

Region (org.apache.cloudstack.region.Region)2 RegionService (org.apache.cloudstack.region.RegionService)2 Test (org.junit.Test)2 ResponseGenerator (org.apache.cloudstack.api.ResponseGenerator)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 RegionResponse (org.apache.cloudstack.api.response.RegionResponse)1