|
| 1 | +/* |
| 2 | + * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | + * You may not use this file except in compliance with the License. |
| 6 | + * A copy of the License is located at |
| 7 | + * |
| 8 | + * http://aws.amazon.com/apache2.0 |
| 9 | + * |
| 10 | + * or in the "license" file accompanying this file. This file is distributed |
| 11 | + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | + * express or implied. See the License for the specific language governing |
| 13 | + * permissions and limitations under the License. |
| 14 | + */ |
| 15 | + |
| 16 | +package com.amazonaws.servces.connect; |
| 17 | + |
| 18 | +import android.content.Context; |
| 19 | +import android.support.test.InstrumentationRegistry; |
| 20 | +import android.support.test.runner.AndroidJUnit4; |
| 21 | +import android.util.Log; |
| 22 | + |
| 23 | +import com.amazonaws.services.connect.AmazonConnectClient; |
| 24 | +import com.amazonaws.services.connect.model.ListUsersRequest; |
| 25 | +import com.amazonaws.services.connect.model.ListUsersResult; |
| 26 | +import com.amazonaws.services.connect.model.UserSummary; |
| 27 | +import com.amazonaws.testutils.AWSTestBase; |
| 28 | + |
| 29 | +import org.junit.Before; |
| 30 | +import org.junit.Test; |
| 31 | +import org.junit.runner.RunWith; |
| 32 | + |
| 33 | +import java.io.IOException; |
| 34 | +import java.util.ArrayList; |
| 35 | +import java.util.List; |
| 36 | + |
| 37 | +import static org.junit.Assert.*; |
| 38 | + |
| 39 | +/** |
| 40 | + * Instrumented test, which will execute on an Android device. |
| 41 | + * |
| 42 | + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> |
| 43 | + */ |
| 44 | +@RunWith(AndroidJUnit4.class) |
| 45 | +public class ConnectInstrumentedTest extends AWSTestBase { |
| 46 | + |
| 47 | + private AmazonConnectClient connectClient; |
| 48 | + private String instanceId; |
| 49 | + private String adminUserName; |
| 50 | + |
| 51 | + private String TAG = ConnectInstrumentedTest.class.getSimpleName(); |
| 52 | + |
| 53 | + @Before |
| 54 | + public void setUp() throws Exception { |
| 55 | + setUpCredentials(); |
| 56 | + connectClient = new AmazonConnectClient(credentials); |
| 57 | + |
| 58 | + instanceId = getPackageConfigure("connect").getString("instanceId"); |
| 59 | + adminUserName = getPackageConfigure("connect").getString("adminUserName"); |
| 60 | + } |
| 61 | + |
| 62 | + @Test |
| 63 | + public void testListUsers() { |
| 64 | + ListUsersRequest listUsersRequest = new ListUsersRequest(); |
| 65 | + listUsersRequest.setInstanceId(instanceId); |
| 66 | + ListUsersResult listUsersResult = connectClient.listUsers(listUsersRequest); |
| 67 | + |
| 68 | + assert listUsersResult.getUserSummaryList().size() > 0; |
| 69 | + List<String> userNames = new ArrayList<>(); |
| 70 | + for (UserSummary userSummary : listUsersResult.getUserSummaryList()) { |
| 71 | + userNames.add(userSummary.getUsername()); |
| 72 | + } |
| 73 | + |
| 74 | + assertTrue("UserSummaryList should have admin username.", userNames.contains(adminUserName)); |
| 75 | + } |
| 76 | +} |
0 commit comments