use of com.amazonaws.mobile.client.DeviceOperations in project amplify-android by aws-amplify.
the class AuthComponentTest method forgetCurrentDevice.
/**
* Tests that forgetDevice calls the AWSMobileClient forget device method to forget
* the current device.
* @throws AuthException test fails if this gets thrown since method should succeed
*/
@Test
public void forgetCurrentDevice() throws AuthException {
DeviceOperations deviceOps = mock(DeviceOperations.class);
when(mobileClient.getDeviceOperations()).thenReturn(deviceOps);
doAnswer(invocation -> {
Callback<Void> callback = invocation.getArgument(0);
callback.onResult(null);
return null;
}).when(deviceOps).forget(Mockito.<Callback<Void>>any());
synchronousAuth.forgetDevice();
verify(mobileClient.getDeviceOperations()).forget(Mockito.<Callback<Void>>any());
}
use of com.amazonaws.mobile.client.DeviceOperations in project amplify-android by aws-amplify.
the class AuthComponentTest method forgetDevice.
/**
* Tests that forgetDevice calls the AWSMobileClient forget device method to forget
* a device with matching ID.
* @throws AuthException test fails if this gets thrown since method should succeed
*/
@Test
public void forgetDevice() throws AuthException {
DeviceOperations deviceOps = mock(DeviceOperations.class);
when(mobileClient.getDeviceOperations()).thenReturn(deviceOps);
doAnswer(invocation -> {
Callback<Void> callback = invocation.getArgument(1);
callback.onResult(null);
return null;
}).when(deviceOps).forget(any(), any());
AuthDevice device = AuthDevice.fromId(RandomString.string());
synchronousAuth.forgetDevice(device);
verify(mobileClient.getDeviceOperations()).forget(eq(device.getDeviceId()), any());
}
use of com.amazonaws.mobile.client.DeviceOperations in project amplify-android by aws-amplify.
the class AuthComponentTest method rememberCurrentDevice.
/**
* Tests that rememberDevice calls the AWSMobileClient device update status method to set
* remember status to true.
* @throws AuthException test fails if this gets thrown since method should succeed
*/
@Test
public void rememberCurrentDevice() throws AuthException {
DeviceOperations deviceOps = mock(DeviceOperations.class);
when(mobileClient.getDeviceOperations()).thenReturn(deviceOps);
doAnswer(invocation -> {
Callback<Void> callback = invocation.getArgument(1);
callback.onResult(null);
return null;
}).when(deviceOps).updateStatus(anyBoolean(), any());
synchronousAuth.rememberDevice();
verify(mobileClient.getDeviceOperations()).updateStatus(eq(true), any());
}
use of com.amazonaws.mobile.client.DeviceOperations in project amplify-android by aws-amplify.
the class AuthComponentTest method fetchDevices.
/**
* Tests that fetchDevices calls the AWSMobileClient list devices method to obtain
* a list of remembered devices.
* @throws AuthException test fails if this gets thrown since method should succeed
*/
@Test
public void fetchDevices() throws AuthException {
ListDevicesResult listResult = new ListDevicesResult(new ArrayList<>(), null);
DeviceOperations deviceOps = mock(DeviceOperations.class);
when(mobileClient.getDeviceOperations()).thenReturn(deviceOps);
doAnswer(invocation -> {
Callback<ListDevicesResult> callback = invocation.getArgument(0);
callback.onResult(listResult);
return null;
}).when(deviceOps).list(any());
synchronousAuth.fetchDevices();
verify(mobileClient.getDeviceOperations()).list(any());
}
Aggregations