Skip to content

Commit be50acb

Browse files
committed
modified the tests
1 parent c3eb1c0 commit be50acb

File tree

5 files changed

+124
-89
lines changed

5 files changed

+124
-89
lines changed

javav2/example_code/entityresolution/pom.xml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
<type>pom</type>
3636
<scope>import</scope>
3737
</dependency>
38+
<dependency>
39+
<groupId>org.apache.logging.log4j</groupId>
40+
<artifactId>log4j-bom</artifactId>
41+
<version>2.23.1</version>
42+
<type>pom</type>
43+
<scope>import</scope>
44+
</dependency>
3845
</dependencies>
3946
</dependencyManagement>
4047
<dependencies>
@@ -82,19 +89,26 @@
8289
<groupId>software.amazon.awssdk</groupId>
8390
<artifactId>netty-nio-client</artifactId>
8491
</dependency>
92+
<dependency>
93+
<groupId>software.amazon.awssdk</groupId>
94+
<artifactId>cloudformation</artifactId>
95+
</dependency>
96+
<dependency>
97+
<groupId>org.apache.logging.log4j</groupId>
98+
<artifactId>log4j-core</artifactId>
99+
</dependency>
85100
<dependency>
86101
<groupId>org.slf4j</groupId>
87102
<artifactId>slf4j-api</artifactId>
88103
<version>2.0.13</version>
89104
</dependency>
90105
<dependency>
91-
<groupId>software.amazon.awssdk</groupId>
92-
<artifactId>cloudformation</artifactId>
106+
<groupId>org.apache.logging.log4j</groupId>
107+
<artifactId>log4j-slf4j2-impl</artifactId>
93108
</dependency>
94109
<dependency>
95110
<groupId>org.apache.logging.log4j</groupId>
96-
<artifactId>log4j-slf4j2-impl</artifactId>
111+
<artifactId>log4j-1.2-api</artifactId>
97112
</dependency>
98-
99113
</dependencies>
100114
</project>

javav2/example_code/entityresolution/src/main/java/com/example/entity/scenario/EntityResActions.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
1010
import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;
1111
import software.amazon.awssdk.regions.Region;
12-
import software.amazon.awssdk.services.entityresolution.EntityResolutionClient;
1312
import software.amazon.awssdk.services.entityresolution.EntityResolutionAsyncClient;
14-
13+
import org.slf4j.Logger;
14+
import org.slf4j.LoggerFactory;
1515
import software.amazon.awssdk.services.entityresolution.model.CreateMatchingWorkflowRequest;
1616
import software.amazon.awssdk.services.entityresolution.model.CreateMatchingWorkflowResponse;
1717
import software.amazon.awssdk.services.entityresolution.model.CreateSchemaMappingRequest;
@@ -35,16 +35,14 @@
3535
import software.amazon.awssdk.services.s3.model.PutObjectResponse;
3636
import software.amazon.awssdk.services.s3.model.S3Exception;
3737
import software.amazon.awssdk.services.entityresolution.model.TagResourceRequest;
38-
3938
import java.time.Duration;
4039
import java.util.HashMap;
4140
import java.util.List;
4241
import java.util.Map;
4342
import java.util.concurrent.CompletableFuture;
4443

4544
public class EntityResActions {
46-
47-
private EntityResolutionClient resolutionClient;
45+
private static final Logger logger = LoggerFactory.getLogger(EntityResActions.class);
4846

4947
private static EntityResolutionAsyncClient entityResolutionAsyncClient;
5048

@@ -128,7 +126,7 @@ public void ListSchemaMappings() {
128126
// Iterate through the pages of results
129127
CompletableFuture<Void> future = paginator.subscribe(response -> {
130128
response.schemaList().forEach(schemaMapping ->
131-
System.out.println("Schema Mapping Name: " +schemaMapping.schemaName())
129+
logger.info("Schema Mapping Name: " +schemaMapping.schemaName())
132130
);
133131
});
134132

@@ -182,7 +180,7 @@ public CompletableFuture<CreateSchemaMappingResponse> createSchemaMappingAsync(S
182180
return getResolutionAsyncClient().createSchemaMapping(request)
183181
.whenComplete((response, exception) -> {
184182
if (response != null) {
185-
System.out.println("Schema Mapping Created Successfully!");
183+
logger.info("Schema Mapping Created Successfully!");
186184
} else {
187185
throw new RuntimeException("Failed to create schema mapping: " + exception.getMessage(), exception);
188186
}
@@ -207,7 +205,7 @@ public CompletableFuture<GetSchemaMappingResponse> getSchemaMappingAsync(String
207205
.whenComplete((response, exception) -> {
208206
if (response != null) {
209207
response.mappedInputFields().forEach(attribute ->
210-
System.out.println("Attribute Name: " + attribute.fieldName() +
208+
logger.info("Attribute Name: " + attribute.fieldName() +
211209
", Attribute Type: " + attribute.type().toString()));
212210
} else {
213211
throw new RuntimeException("Failed to get schema mapping: " + exception.getMessage(), exception);
@@ -232,8 +230,8 @@ public CompletableFuture<Void> getMatchingJobAsync(String jobId, String workflow
232230

233231
return getResolutionAsyncClient().getMatchingJob(request)
234232
.thenAccept(response -> {
235-
System.out.println("Job status: " + response.status());
236-
System.out.println("Job details: " + response.toString());
233+
logger.info("Job status: " + response.status());
234+
logger.info("Job details: " + response.toString());
237235
})
238236
.exceptionally(ex -> {
239237
throw new RuntimeException("Error fetching matching job: " + ex.getMessage(), ex);
@@ -258,7 +256,7 @@ public CompletableFuture<String> startMatchingJobAsync(String workflowName) {
258256
if (response != null) {
259257
// Get the job ID from the response
260258
String jobId = response.jobId();
261-
System.out.println("Job ID: " + jobId);
259+
logger.info("Job ID: " + jobId);
262260
} else {
263261
// Handle the exception if the response is null
264262
throw new RuntimeException("Failed to start matching job: " + exception.getMessage(), exception);
@@ -284,11 +282,11 @@ public CompletableFuture<Boolean> checkWorkflowStatusCompleteAsync(String jobId,
284282

285283
return getResolutionAsyncClient().getMatchingJob(request)
286284
.thenApply(response -> {
287-
System.out.println("\nJob status: " + response.status());
285+
logger.info("\nJob status: " + response.status());
288286
return "SUCCEEDED".equalsIgnoreCase(String.valueOf(response.status()));
289287
})
290288
.exceptionally(exception -> {
291-
System.out.println("Error checking workflow status: " + exception.getMessage());
289+
logger.info("Error checking workflow status: " + exception.getMessage());
292290
return false;
293291
});
294292
}
@@ -336,7 +334,7 @@ public CompletableFuture<String> createMatchingWorkflowAsync(String roleARN, Str
336334
return getResolutionAsyncClient().createMatchingWorkflow(workflowRequest)
337335
.whenComplete((response, exception) -> {
338336
if (response != null) {
339-
System.out.println("Workflow created successfully.");
337+
logger.info("Workflow created successfully.");
340338
} else {
341339
throw new RuntimeException("Failed to create workflow: " + exception.getMessage(), exception);
342340
}
@@ -362,7 +360,7 @@ public CompletableFuture<Void> tagEntityResource(String schemaMappingARN) {
362360
.build();
363361

364362
return getResolutionAsyncClient().tagResource(request)
365-
.thenAccept(response -> System.out.println("Successfully tagged the resource."))
363+
.thenAccept(response -> logger.info("Successfully tagged the resource."))
366364
.exceptionally(exception -> {
367365
throw new RuntimeException("Failed to tag the resource: " + exception.getMessage(), exception);
368366
});
@@ -414,6 +412,4 @@ public boolean doesObjectExist(String bucketName) {
414412
return false;
415413
}
416414
}
417-
418-
419415
}

0 commit comments

Comments
 (0)