use of com.amazonaws.mobile.client.results.ListDevicesResult in project aws-sdk-android by aws-amplify.
the class DeviceOperations method _listDevices.
private ReturningRunnable<ListDevicesResult> _listDevices(final Integer limit, final String paginationToken) {
return new ReturningRunnable<ListDevicesResult>() {
@Override
public ListDevicesResult run() throws Exception {
final ListDevicesRequest listDevicesRequest = new ListDevicesRequest();
listDevicesRequest.setAccessToken(mobileClient.getTokens().getAccessToken().getTokenString());
listDevicesRequest.setLimit(limit);
listDevicesRequest.setPaginationToken(paginationToken);
final com.amazonaws.services.cognitoidentityprovider.model.ListDevicesResult listDevicesResult = userpoolLL.listDevices(listDevicesRequest);
final ArrayList<Device> devices = new ArrayList<Device>(limit);
for (DeviceType deviceType : listDevicesResult.getDevices()) {
devices.add(marshallDeviceTypeToDevice(deviceType));
}
return new ListDevicesResult(devices, listDevicesResult.getPaginationToken());
}
};
}
use of com.amazonaws.mobile.client.results.ListDevicesResult 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