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();
}
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());
}
}
Aggregations