use of org.apache.cloudstack.api.ResponseGenerator in project cloudstack by apache.
the class CreateSnapshotCmdTest method testCreateSuccess.
@Test
public void testCreateSuccess() {
AccountService accountService = Mockito.mock(AccountService.class);
Account account = Mockito.mock(Account.class);
Mockito.when(accountService.getAccount(anyLong())).thenReturn(account);
VolumeApiService volumeApiService = Mockito.mock(VolumeApiService.class);
Snapshot snapshot = Mockito.mock(Snapshot.class);
try {
Mockito.when(volumeApiService.takeSnapshot(anyLong(), anyLong(), anyLong(), any(Account.class), anyBoolean(), isNull(Snapshot.LocationType.class))).thenReturn(snapshot);
} catch (Exception e) {
Assert.fail("Received exception when success expected " + e.getMessage());
}
responseGenerator = Mockito.mock(ResponseGenerator.class);
SnapshotResponse snapshotResponse = Mockito.mock(SnapshotResponse.class);
Mockito.when(responseGenerator.createSnapshotResponse(snapshot)).thenReturn(snapshotResponse);
Mockito.doNothing().when(snapshotResponse).setAccountName(anyString());
createSnapshotCmd._accountService = accountService;
createSnapshotCmd._responseGenerator = responseGenerator;
createSnapshotCmd._volumeService = volumeApiService;
try {
createSnapshotCmd.execute();
} catch (Exception e) {
Assert.fail("Received exception when success expected " + e.getMessage());
}
}
Aggregations