Search in sources :

Example 1 with ListDevicesResult

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());
        }
    };
}
Also used : ListDevicesResult(com.amazonaws.mobile.client.results.ListDevicesResult) DeviceType(com.amazonaws.services.cognitoidentityprovider.model.DeviceType) ReturningRunnable(com.amazonaws.mobile.client.internal.ReturningRunnable) Device(com.amazonaws.mobile.client.results.Device) CognitoDevice(com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoDevice) ArrayList(java.util.ArrayList) ListDevicesRequest(com.amazonaws.services.cognitoidentityprovider.model.ListDevicesRequest)

Example 2 with ListDevicesResult

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());
}
Also used : ListDevicesResult(com.amazonaws.mobile.client.results.ListDevicesResult) DeviceOperations(com.amazonaws.mobile.client.DeviceOperations) Test(org.junit.Test)

Aggregations

ListDevicesResult (com.amazonaws.mobile.client.results.ListDevicesResult)2 DeviceOperations (com.amazonaws.mobile.client.DeviceOperations)1 ReturningRunnable (com.amazonaws.mobile.client.internal.ReturningRunnable)1 Device (com.amazonaws.mobile.client.results.Device)1 CognitoDevice (com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoDevice)1 DeviceType (com.amazonaws.services.cognitoidentityprovider.model.DeviceType)1 ListDevicesRequest (com.amazonaws.services.cognitoidentityprovider.model.ListDevicesRequest)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1