• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 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 software.amazon.awssdk.services.devicefarm;
17 
18 import static org.junit.Assert.assertNotNull;
19 
20 import org.junit.AfterClass;
21 import org.junit.BeforeClass;
22 import org.junit.Test;
23 import software.amazon.awssdk.core.exception.SdkServiceException;
24 import software.amazon.awssdk.regions.Region;
25 import software.amazon.awssdk.services.devicefarm.model.CreateProjectRequest;
26 import software.amazon.awssdk.services.devicefarm.model.CreateProjectResponse;
27 import software.amazon.awssdk.services.devicefarm.model.DeleteProjectRequest;
28 import software.amazon.awssdk.services.devicefarm.model.ListDevicePoolsRequest;
29 import software.amazon.awssdk.services.devicefarm.model.Project;
30 import software.amazon.awssdk.testutils.service.AwsTestBase;
31 
32 /**
33  * Smoke tests for device farm service.
34  */
35 public class DeviceFarmIntegrationTest extends AwsTestBase {
36 
37     private static final String PROJECT_NAME = "df-java-project-"
38                                                + System.currentTimeMillis();
39     private static DeviceFarmClient client;
40 
41     private static String projectArn;
42 
43     @BeforeClass
setup()44     public static void setup() throws Exception {
45         setUpCredentials();
46         client = DeviceFarmClient.builder()
47                                  .credentialsProvider(CREDENTIALS_PROVIDER_CHAIN)
48                                  .region(Region.US_WEST_2)
49                                  .build();
50     }
51 
52     @AfterClass
teardown()53     public static void teardown() {
54         client.deleteProject(DeleteProjectRequest.builder().arn(projectArn).build());
55     }
56 
57     @Test
testCreateProject()58     public void testCreateProject() {
59         CreateProjectResponse result = client
60                 .createProject(CreateProjectRequest.builder()
61                         .name(PROJECT_NAME)
62                         .build());
63         final Project project = result.project();
64         assertNotNull(project);
65         projectArn = project.arn();
66         assertNotNull(projectArn);
67     }
68 
69     @Test(expected = SdkServiceException.class)
testExceptionHandling()70     public void testExceptionHandling() {
71         client.listDevicePools(ListDevicePoolsRequest.builder().nextToken("fake-token").build());
72     }
73 }
74