Skip to content

Commit 9aaa63d

Browse files
authored
Kotlin Updated the SDK build number in Gradle Build file and include fromEnvironment() (#7514)
1 parent 6cf888b commit 9aaa63d

File tree

423 files changed

+1018
-1484
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

423 files changed

+1018
-1484
lines changed
Lines changed: 126 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,126 @@
1-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2-
// SPDX-License-Identifier: Apache-2.0
3-
4-
import com.example.comprehend.*;
5-
import com.google.gson.Gson;
6-
import org.junit.jupiter.api.*;
7-
import org.slf4j.Logger;
8-
import org.slf4j.LoggerFactory;
9-
import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
10-
import software.amazon.awssdk.regions.Region;
11-
import software.amazon.awssdk.services.comprehend.ComprehendClient;
12-
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
13-
import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest;
14-
import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse;
15-
import java.io.*;
16-
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
17-
18-
/**
19-
* To run these integration tests, you must set the required values
20-
* in the config.properties file or AWS Secrets Manager.
21-
*/
22-
@TestInstance(TestInstance.Lifecycle.PER_METHOD)
23-
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
24-
public class AmazonComprehendTest {
25-
private static final Logger logger = LoggerFactory.getLogger(AmazonComprehendTest.class);
26-
private static ComprehendClient comClient;
27-
private static String text = "Amazon.com, Inc. is located in Seattle, WA and was founded July 5th, 1994 by Jeff Bezos, allowing customers to buy everything from books to blenders. Seattle is north of Portland and south of Vancouver, BC. Other notable Seattle - based companies are Starbucks and Boeing";
28-
private static String frText = "Il pleut aujourd'hui à Seattle";
29-
private static String dataAccessRoleArn;
30-
private static String s3Uri;
31-
private static String documentClassifierName;
32-
33-
@BeforeAll
34-
public static void setUp() throws IOException {
35-
comClient = ComprehendClient.builder()
36-
.region(Region.US_EAST_1)
37-
.build();
38-
39-
// Get the values to run these tests from AWS Secrets Manager.
40-
Gson gson = new Gson();
41-
String json = getSecretValues();
42-
SecretValues values = gson.fromJson(json, SecretValues.class);
43-
dataAccessRoleArn = values.getDataAccessRoleArn();
44-
s3Uri = values.getS3Uri();
45-
documentClassifierName = values.getDocumentClassifier();
46-
}
47-
48-
@Test
49-
@Tag("weathertop")
50-
@Tag("IntegrationTest")
51-
@Order(1)
52-
public void testDetectEntities() {
53-
assertDoesNotThrow(() -> DetectEntities.detectAllEntities(comClient, text));
54-
logger.info("Test 1 passed");
55-
}
56-
57-
@Test
58-
@Tag("weathertop")
59-
@Tag("IntegrationTest")
60-
@Order(2)
61-
public void testDetectKeyPhrases() {
62-
assertDoesNotThrow(() -> DetectKeyPhrases.detectAllKeyPhrases(comClient, text));
63-
logger.info("Test 2 passed");
64-
}
65-
66-
@Test
67-
@Tag("weathertop")
68-
@Tag("IntegrationTest")
69-
@Order(3)
70-
public void testDetectLanguage() {
71-
assertDoesNotThrow(() -> DetectLanguage.detectTheDominantLanguage(comClient, frText));
72-
logger.info("Test 3 passed");
73-
}
74-
75-
@Test
76-
@Tag("weathertop")
77-
@Tag("IntegrationTest")
78-
@Order(4)
79-
public void testDetectSentiment() {
80-
assertDoesNotThrow(() -> DetectSentiment.detectSentiments(comClient, text));
81-
logger.info("Test 4 passed");
82-
}
83-
84-
@Test
85-
@Tag("weathertop")
86-
@Tag("IntegrationTest")
87-
@Order(5)
88-
public void testDetectSyntax() {
89-
assertDoesNotThrow(() -> DetectSyntax.detectAllSyntax(comClient, text));
90-
logger.info("Test 5 passed");
91-
}
92-
93-
private static String getSecretValues() {
94-
SecretsManagerClient secretClient = SecretsManagerClient.builder()
95-
.region(Region.US_EAST_1)
96-
.build();
97-
String secretName = "test/comprehend";
98-
99-
GetSecretValueRequest valueRequest = GetSecretValueRequest.builder()
100-
.secretId(secretName)
101-
.build();
102-
103-
GetSecretValueResponse valueResponse = secretClient.getSecretValue(valueRequest);
104-
return valueResponse.secretString();
105-
}
106-
107-
@Nested
108-
@DisplayName("A class used to get test values from test/comprehend (an AWS Secrets Manager secret)")
109-
class SecretValues {
110-
private String dataAccessRoleArn;
111-
private String s3Uri;
112-
private String documentClassifier;
113-
114-
public String getDataAccessRoleArn() {
115-
return dataAccessRoleArn;
116-
}
117-
118-
public String getS3Uri() {
119-
return s3Uri;
120-
}
121-
122-
public String getDocumentClassifier() {
123-
return documentClassifier;
124-
}
125-
}
126-
}
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import com.example.comprehend.*;
5+
import com.google.gson.Gson;
6+
import org.junit.jupiter.api.*;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
10+
import software.amazon.awssdk.regions.Region;
11+
import software.amazon.awssdk.services.comprehend.ComprehendClient;
12+
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
13+
import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest;
14+
import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse;
15+
import java.io.*;
16+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
17+
18+
/**
19+
* To run these integration tests, you must set the required values
20+
* in the config.properties file or AWS Secrets Manager.
21+
*/
22+
@TestInstance(TestInstance.Lifecycle.PER_METHOD)
23+
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
24+
public class AmazonComprehendTest {
25+
private static final Logger logger = LoggerFactory.getLogger(AmazonComprehendTest.class);
26+
private static ComprehendClient comClient;
27+
private static String text = "Amazon.com, Inc. is located in Seattle, WA and was founded July 5th, 1994 by Jeff Bezos, allowing customers to buy everything from books to blenders. Seattle is north of Portland and south of Vancouver, BC. Other notable Seattle - based companies are Starbucks and Boeing";
28+
private static String frText = "Il pleut aujourd'hui à Seattle";
29+
private static String dataAccessRoleArn;
30+
private static String s3Uri;
31+
private static String documentClassifierName;
32+
33+
@BeforeAll
34+
public static void setUp() throws IOException {
35+
comClient = ComprehendClient.builder()
36+
.region(Region.US_EAST_1)
37+
.build();
38+
39+
// Get the values to run these tests from AWS Secrets Manager.
40+
Gson gson = new Gson();
41+
String json = getSecretValues();
42+
SecretValues values = gson.fromJson(json, SecretValues.class);
43+
dataAccessRoleArn = values.getDataAccessRoleArn();
44+
s3Uri = values.getS3Uri();
45+
documentClassifierName = values.getDocumentClassifier();
46+
}
47+
48+
@Test
49+
@Tag("weathertop2")
50+
@Tag("IntegrationTest")
51+
@Order(1)
52+
public void testDetectEntities() {
53+
assertDoesNotThrow(() -> DetectEntities.detectAllEntities(comClient, text));
54+
logger.info("Test 1 passed");
55+
}
56+
57+
@Test
58+
@Tag("weathertop")
59+
@Tag("IntegrationTest")
60+
@Order(2)
61+
public void testDetectKeyPhrases() {
62+
assertDoesNotThrow(() -> DetectKeyPhrases.detectAllKeyPhrases(comClient, text));
63+
logger.info("Test 2 passed");
64+
}
65+
66+
@Test
67+
@Tag("weathertop")
68+
@Tag("IntegrationTest")
69+
@Order(3)
70+
public void testDetectLanguage() {
71+
assertDoesNotThrow(() -> DetectLanguage.detectTheDominantLanguage(comClient, frText));
72+
logger.info("Test 3 passed");
73+
}
74+
75+
@Test
76+
@Tag("weathertop")
77+
@Tag("IntegrationTest")
78+
@Order(4)
79+
public void testDetectSentiment() {
80+
assertDoesNotThrow(() -> DetectSentiment.detectSentiments(comClient, text));
81+
logger.info("Test 4 passed");
82+
}
83+
84+
@Test
85+
@Tag("weathertop")
86+
@Tag("IntegrationTest")
87+
@Order(5)
88+
public void testDetectSyntax() {
89+
assertDoesNotThrow(() -> DetectSyntax.detectAllSyntax(comClient, text));
90+
logger.info("Test 5 passed");
91+
}
92+
93+
private static String getSecretValues() {
94+
SecretsManagerClient secretClient = SecretsManagerClient.builder()
95+
.region(Region.US_EAST_1)
96+
.build();
97+
String secretName = "test/comprehend";
98+
99+
GetSecretValueRequest valueRequest = GetSecretValueRequest.builder()
100+
.secretId(secretName)
101+
.build();
102+
103+
GetSecretValueResponse valueResponse = secretClient.getSecretValue(valueRequest);
104+
return valueResponse.secretString();
105+
}
106+
107+
@Nested
108+
@DisplayName("A class used to get test values from test/comprehend (an AWS Secrets Manager secret)")
109+
class SecretValues {
110+
private String dataAccessRoleArn;
111+
private String s3Uri;
112+
private String documentClassifier;
113+
114+
public String getDataAccessRoleArn() {
115+
return dataAccessRoleArn;
116+
}
117+
118+
public String getS3Uri() {
119+
return s3Uri;
120+
}
121+
122+
public String getDocumentClassifier() {
123+
return documentClassifier;
124+
}
125+
}
126+
}

kotlin/services/apigateway/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22

33
plugins {
4-
kotlin("jvm") version "1.9.0"
4+
kotlin("jvm") version "2.1.0"
55
application
66
}
77

@@ -27,7 +27,7 @@ repositories {
2727
}
2828
apply(plugin = "org.jlleitschuh.gradle.ktlint")
2929
dependencies {
30-
implementation(platform("aws.sdk.kotlin:bom:1.3.112"))
30+
implementation(platform("aws.sdk.kotlin:bom:1.4.119"))
3131
implementation("aws.sdk.kotlin:apigateway")
3232
implementation("aws.sdk.kotlin:secretsmanager")
3333
implementation("aws.smithy.kotlin:http-client-engine-okhttp")

kotlin/services/apigateway/src/main/kotlin/com/kotlin/gateway/CreateDeployment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ suspend fun createNewDeployment(restApiIdVal: String?, stageNameVal: String?): S
3737
stageName = stageNameVal
3838
}
3939

40-
ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
40+
ApiGatewayClient.fromEnvironment { region = "us-east-1" }.use { apiGateway ->
4141
val response = apiGateway.createDeployment(request)
4242
println("The id of the deployment is " + response.id)
4343
return response.id

kotlin/services/apigateway/src/main/kotlin/com/kotlin/gateway/CreateRestApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ suspend fun createAPI(restApiName: String?): String? {
3535
name = restApiName
3636
}
3737

38-
ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
38+
ApiGatewayClient.fromEnvironment { region = "us-east-1" }.use { apiGateway ->
3939
val response = apiGateway.createRestApi(request)
4040
println("The id of the new api is ${response.id}")
4141
return response.id

kotlin/services/apigateway/src/main/kotlin/com/kotlin/gateway/DeleteRestApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ suspend fun deleteAPI(restApiIdVal: String?) {
3333
restApiId = restApiIdVal
3434
}
3535

36-
ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
36+
ApiGatewayClient.fromEnvironment { region = "us-east-1" }.use { apiGateway ->
3737
apiGateway.deleteRestApi(request)
3838
println("The API was successfully deleted")
3939
}

kotlin/services/apigateway/src/main/kotlin/com/kotlin/gateway/GetAPIKeys.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ suspend fun main() {
1414

1515
// snippet-start:[apigateway.kotlin.get_apikeys.main]
1616
suspend fun getKeys() {
17-
ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
17+
ApiGatewayClient.fromEnvironment { region = "us-east-1" }.use { apiGateway ->
1818
val response = apiGateway.getApiKeys(GetApiKeysRequest { })
1919
response.items?.forEach { key ->
2020
println("Key is $key")

kotlin/services/apigateway/src/main/kotlin/com/kotlin/gateway/GetDeployments.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ suspend fun getAllDeployments(restApiIdVal: String?) {
3333
restApiId = restApiIdVal
3434
}
3535

36-
ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
36+
ApiGatewayClient.fromEnvironment { region = "us-east-1" }.use { apiGateway ->
3737
val response = apiGateway.getDeployments(request)
3838
response.items?.forEach { deployment ->
3939
println("The deployment id is ${deployment.id}")

kotlin/services/apigateway/src/main/kotlin/com/kotlin/gateway/GetMethod.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ suspend fun getSpecificMethod(restApiIdVal: String?, resourceIdVal: String?, htt
3939
resourceId = resourceIdVal
4040
}
4141

42-
ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
42+
ApiGatewayClient.fromEnvironment { region = "us-east-1" }.use { apiGateway ->
4343
val response = apiGateway.getMethod(methodRequest)
4444

4545
// Retrieve a method response associated with a given HTTP status code.

kotlin/services/apigateway/src/main/kotlin/com/kotlin/gateway/GetStages.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ suspend fun getAllStages(restApiIdVal: String?) {
3333
restApiId = restApiIdVal
3434
}
3535

36-
ApiGatewayClient { region = "us-east-1" }.use { apiGateway ->
36+
ApiGatewayClient.fromEnvironment { region = "us-east-1" }.use { apiGateway ->
3737
val response = apiGateway.getStages(stagesRequest)
3838
response.item?.forEach { stage ->
3939
println("Stage name is ${stage.stageName}")

kotlin/services/appsync/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22

33
plugins {
4-
kotlin("jvm") version "1.9.0"
4+
kotlin("jvm") version "2.1.0"
55
application
66
}
77

@@ -27,7 +27,7 @@ repositories {
2727
}
2828
apply(plugin = "org.jlleitschuh.gradle.ktlint")
2929
dependencies {
30-
implementation(platform("aws.sdk.kotlin:bom:1.3.112"))
30+
implementation(platform("aws.sdk.kotlin:bom:1.4.119"))
3131
implementation("aws.sdk.kotlin:appsync")
3232
implementation("aws.sdk.kotlin:sts")
3333
implementation("aws.sdk.kotlin:s3")

0 commit comments

Comments
 (0)