Search in sources :

Example 1 with RegionService

use of com.cloud.region.RegionService 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 2 with RegionService

use of com.cloud.region.RegionService in project cosmic by MissionCriticalCloud.

the class RegionCmdTest method testCreateFailure.

@Test
public void testCreateFailure() {
    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(null);
    addRegionCmd._regionService = regionService;
    try {
        addRegionCmd.execute();
    } catch (final ServerApiException exception) {
        Assert.assertEquals("Failed to add Region", exception.getDescription());
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) Region(com.cloud.region.Region) RegionService(com.cloud.region.RegionService) Test(org.junit.Test)

Aggregations

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