use of com.cloud.storage.StorageService in project cloudstack by apache.
the class AddSecondaryStorageCmdTest method testExecuteForNullResult.
@Test
public void testExecuteForNullResult() throws Exception {
StorageService resourceService = Mockito.mock(StorageService.class);
addImageStoreCmd._storageService = resourceService;
Mockito.when(resourceService.discoverImageStore(anyString(), anyString(), anyString(), anyLong(), (Map) anyObject())).thenReturn(null);
try {
addImageStoreCmd.execute();
} catch (ServerApiException exception) {
assertEquals("Failed to add secondary storage", exception.getDescription());
}
}
use of com.cloud.storage.StorageService 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(isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(store);
ResponseGenerator responseGenerator = Mockito.mock(ResponseGenerator.class);
addImageStoreCmd._responseGenerator = responseGenerator;
ImageStoreResponse responseHost = new ImageStoreResponse();
responseHost.setName("Test");
Mockito.doReturn(responseHost).when(responseGenerator).createImageStoreResponse(store);
addImageStoreCmd.execute();
Mockito.verify(responseGenerator).createImageStoreResponse(store);
ImageStoreResponse actualResponse = (ImageStoreResponse) addImageStoreCmd.getResponseObject();
assertEquals(responseHost, actualResponse);
assertEquals("addimagestoreresponse", actualResponse.getResponseName());
}
use of com.cloud.storage.StorageService in project cosmic by MissionCriticalCloud.
the class AddSecondaryStorageCmdTest method testExecuteForNullResult.
@Test
public void testExecuteForNullResult() throws Exception {
final StorageService resourceService = Mockito.mock(StorageService.class);
addImageStoreCmd._storageService = resourceService;
Mockito.when(resourceService.discoverImageStore(anyString(), anyString(), anyString(), anyLong(), (Map) anyObject())).thenReturn(null);
try {
addImageStoreCmd.execute();
} catch (final ServerApiException exception) {
Assert.assertEquals("Failed to add secondary storage", exception.getDescription());
}
}
use of com.cloud.storage.StorageService in project cosmic by MissionCriticalCloud.
the class AddSecondaryStorageCmdTest method testExecuteForResult.
@Test
public void testExecuteForResult() throws Exception {
final StorageService resourceService = Mockito.mock(StorageService.class);
addImageStoreCmd._storageService = resourceService;
final ImageStore store = Mockito.mock(ImageStore.class);
Mockito.when(resourceService.discoverImageStore(anyString(), anyString(), anyString(), anyLong(), (Map) anyObject())).thenReturn(store);
final ResponseGenerator responseGenerator = Mockito.mock(ResponseGenerator.class);
addImageStoreCmd._responseGenerator = responseGenerator;
final ImageStoreResponse responseHost = new ImageStoreResponse();
responseHost.setName("Test");
Mockito.when(responseGenerator.createImageStoreResponse(store)).thenReturn(responseHost);
addImageStoreCmd.execute();
Mockito.verify(responseGenerator).createImageStoreResponse(store);
final ImageStoreResponse actualResponse = (ImageStoreResponse) addImageStoreCmd.getResponseObject();
Assert.assertEquals(responseHost, actualResponse);
Assert.assertEquals("addimagestoreresponse", actualResponse.getResponseName());
}
Aggregations