Search in sources :

Example 1 with RemoteAccessVpnService

use of com.cloud.network.vpn.RemoteAccessVpnService 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());
    }
}
Also used : Account(com.cloud.user.Account) ServerApiException(com.cloud.api.ServerApiException) AccountService(com.cloud.user.AccountService) RemoteAccessVpnService(com.cloud.network.vpn.RemoteAccessVpnService) Test(org.junit.Test)

Example 2 with RemoteAccessVpnService

use of com.cloud.network.vpn.RemoteAccessVpnService 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();
}
Also used : Account(com.cloud.user.Account) VpnUser(com.cloud.network.VpnUser) AccountService(com.cloud.user.AccountService) RemoteAccessVpnService(com.cloud.network.vpn.RemoteAccessVpnService) Test(org.junit.Test)

Example 3 with RemoteAccessVpnService

use of com.cloud.network.vpn.RemoteAccessVpnService 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();
}
Also used : Account(com.cloud.user.Account) VpnUser(com.cloud.network.VpnUser) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) AccountService(com.cloud.user.AccountService) RemoteAccessVpnService(com.cloud.network.vpn.RemoteAccessVpnService) Test(org.junit.Test)

Example 4 with RemoteAccessVpnService

use of com.cloud.network.vpn.RemoteAccessVpnService in project cloudstack by apache.

the class AddVpnUserCmdTest method testCreateFailure.

@Test
public void testCreateFailure() {
    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);
    Mockito.when(ravService.addVpnUser(anyLong(), isNull(), isNull())).thenReturn(null);
    addVpnUserCmd._ravService = ravService;
    try {
        addVpnUserCmd.create();
    } catch (ServerApiException exception) {
        Assert.assertEquals("Failed to add vpn user", exception.getDescription());
    }
}
Also used : Account(com.cloud.user.Account) ServerApiException(org.apache.cloudstack.api.ServerApiException) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) AccountService(com.cloud.user.AccountService) RemoteAccessVpnService(com.cloud.network.vpn.RemoteAccessVpnService) Test(org.junit.Test)

Aggregations

RemoteAccessVpnService (com.cloud.network.vpn.RemoteAccessVpnService)4 Account (com.cloud.user.Account)4 AccountService (com.cloud.user.AccountService)4 Test (org.junit.Test)4 VpnUser (com.cloud.network.VpnUser)2 ArgumentMatchers.anyLong (org.mockito.ArgumentMatchers.anyLong)2 ServerApiException (com.cloud.api.ServerApiException)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1