use of com.cloud.user.AccountService in project cloudstack by apache.
the class CreateSnapshotCmdTest method testCreateFailure.
@Test
public void testCreateFailure() {
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);
try {
Mockito.when(volumeApiService.takeSnapshot(nullable(Long.class), nullable(Long.class), nullable(Long.class), nullable(Account.class), nullable(Boolean.class), nullable(Snapshot.LocationType.class), nullable(Boolean.class), anyObject())).thenReturn(null);
} catch (Exception e) {
Assert.fail("Received exception when success expected " + e.getMessage());
}
createSnapshotCmd._accountService = accountService;
createSnapshotCmd._volumeService = volumeApiService;
try {
createSnapshotCmd.execute();
} catch (ServerApiException exception) {
Assert.assertEquals("Failed to create snapshot due to an internal error creating snapshot for volume 123", exception.getDescription());
}
}
use of com.cloud.user.AccountService in project cosmic by MissionCriticalCloud.
the class AddVpnUserCmdTest method testCreateFailure.
@Test
public void testCreateFailure() {
final AccountService accountService = Mockito.mock(AccountService.class);
final Account account = Mockito.mock(Account.class);
Mockito.when(accountService.getAccount(Matchers.anyLong())).thenReturn(account);
addVpnUserCmd._accountService = accountService;
final RemoteAccessVpnService ravService = Mockito.mock(RemoteAccessVpnService.class);
Mockito.when(ravService.addVpnUser(Matchers.anyLong(), Matchers.anyString(), Matchers.anyString())).thenReturn(null);
addVpnUserCmd._ravService = ravService;
try {
addVpnUserCmd.create();
} catch (final ServerApiException exception) {
Assert.assertEquals("Failed to add vpn user", exception.getDescription());
}
}
use of com.cloud.user.AccountService in project cosmic by MissionCriticalCloud.
the class AddVpnUserCmdTest method testCreateSuccess.
@Test
public void testCreateSuccess() {
final AccountService accountService = Mockito.mock(AccountService.class);
final Account account = Mockito.mock(Account.class);
Mockito.when(accountService.getAccount(Matchers.anyLong())).thenReturn(account);
addVpnUserCmd._accountService = accountService;
final RemoteAccessVpnService ravService = Mockito.mock(RemoteAccessVpnService.class);
final VpnUser vpnUser = Mockito.mock(VpnUser.class);
Mockito.when(ravService.addVpnUser(Matchers.anyLong(), Matchers.anyString(), Matchers.anyString())).thenReturn(vpnUser);
addVpnUserCmd._ravService = ravService;
addVpnUserCmd.create();
}
use of com.cloud.user.AccountService in project cloudstack by apache.
the class AddVpnUserCmdTest method testCreateSuccess.
@Test
public void testCreateSuccess() {
AccountService accountService = Mockito.mock(AccountService.class);
Account account = Mockito.mock(Account.class);
Mockito.when(accountService.getAccount(nullable(Long.class))).thenReturn(account);
addVpnUserCmd._accountService = accountService;
RemoteAccessVpnService ravService = Mockito.mock(RemoteAccessVpnService.class);
VpnUser vpnUser = Mockito.mock(VpnUser.class);
Mockito.when(ravService.addVpnUser(anyLong(), isNull(), isNull())).thenReturn(vpnUser);
addVpnUserCmd._ravService = ravService;
addVpnUserCmd.create();
}
use of com.cloud.user.AccountService 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(nullable(Long.class), nullable(Long.class), isNull(), nullable(Account.class), nullable(Boolean.class), nullable(Snapshot.LocationType.class), nullable(Boolean.class), nullable(Map.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