diff --git a/aws-app-sync/src/main/java/com/baeldung/awsappsync/AppSyncClientHelper.java b/aws-app-sync/src/main/java/com/baeldung/awsappsync/AppSyncClientHelper.java index fcbc0aa275..b310e60748 100644 --- a/aws-app-sync/src/main/java/com/baeldung/awsappsync/AppSyncClientHelper.java +++ b/aws-app-sync/src/main/java/com/baeldung/awsappsync/AppSyncClientHelper.java @@ -11,7 +11,7 @@ import java.util.Map; public class AppSyncClientHelper { static String apiUrl = "https://m4i3b6icrrb7livfbypfspiifi.appsync-api.us-east-2.amazonaws.com"; - static String apiKey = "da2-es2s6oj4mzhbxk5yu26ss2ruj4"; + static String apiKey = "da2-bm4rpatkkrc5jfyhvvq7itjeke"; static String API_KEY_HEADER = "x-api-key"; public static WebClient.ResponseSpec getResponseBodySpec(Map requestBody) { diff --git a/aws-app-sync/src/main/java/com/baeldung/awsappsync/AwsAppSyncApplication.java b/aws-app-sync/src/main/java/com/baeldung/awsappsync/AwsAppSyncApplication.java index ae012c91a5..19fffd2994 100644 --- a/aws-app-sync/src/main/java/com/baeldung/awsappsync/AwsAppSyncApplication.java +++ b/aws-app-sync/src/main/java/com/baeldung/awsappsync/AwsAppSyncApplication.java @@ -6,8 +6,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class AwsAppSyncApplication { - public static void main(String[] args) { - SpringApplication.run(AwsAppSyncApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(AwsAppSyncApplication.class, args); + } } diff --git a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java index cd14bcd5b2..6e94651789 100644 --- a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java +++ b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java @@ -12,42 +12,61 @@ import static org.junit.jupiter.api.Assertions.*; @SpringBootTest class AwsAppSyncApplicationTests { - @Test - void givenGraphQuery_whenListEvents_thenReturnAllEvents() { + @Test + void givenGraphQuery_whenListEvents_thenReturnAllEvents() { - Map requestBody = new HashMap<>(); - requestBody.put("query", "query ListEvents { listEvents { items { id name where when description } } }"); - requestBody.put("variables", ""); - requestBody.put("operationName", "ListEvents"); + Map requestBody = new HashMap<>(); + requestBody.put("query", "query ListEvents {" + + " listEvents {" + + " items {" + + " id" + + " name" + + " where" + + " when" + + " description" + + " }" + + " }" + + "}"); + requestBody.put("variables", ""); + requestBody.put("operationName", "ListEvents"); - String bodyString = AppSyncClientHelper.getResponseBodySpec(requestBody) - .bodyToMono(String.class).block(); + String bodyString = AppSyncClientHelper.getResponseBodySpec(requestBody) + .bodyToMono(String.class).block(); - assertNotNull(bodyString); - assertTrue(bodyString.contains("My First Event")); - assertTrue(bodyString.contains("where")); - assertTrue(bodyString.contains("when")); - } + assertNotNull(bodyString); + assertTrue(bodyString.contains("My First Event")); + assertTrue(bodyString.contains("where")); + assertTrue(bodyString.contains("when")); + } - @Test - void givenGraphAdd_whenMutation_thenReturnIdNameDesc() { + @Test + void givenGraphAdd_whenMutation_thenReturnIdNameDesc() { - String queryString = "mutation add { createEvent( name:\"My added GraphQL event\" where:\"Day 2\"" + - " when:\"Saturday night\" description:\"Studying GraphQL\" ){ id name description } }"; + String queryString = "mutation add {" + + " createEvent(" + + " name:\"My added GraphQL event\"" + + " where:\"Day 2\"" + + " when:\"Saturday night\"" + + " description:\"Studying GraphQL\"" + + " ){" + + " id" + + " name" + + " description" + + " }" + + "}"; + Map requestBody = new HashMap<>(); + requestBody.put("query", queryString); + requestBody.put("variables", ""); + requestBody.put("operationName", "add"); - Map requestBody = new HashMap<>(); - requestBody.put("query", queryString); - requestBody.put("variables", ""); - requestBody.put("operationName", "add"); + WebClient.ResponseSpec response = AppSyncClientHelper.getResponseBodySpec(requestBody); - WebClient.ResponseSpec response = AppSyncClientHelper.getResponseBodySpec(requestBody); + String bodyString = response.bodyToMono(String.class).block(); - String bodyString = response.bodyToMono(String.class).block(); - - assertNotNull(bodyString); - assertTrue(bodyString.contains("My added GraphQL event")); - assertFalse(bodyString.contains("where")); - assertFalse(bodyString.contains("when")); - } + assertNotNull(bodyString); + assertTrue(bodyString.contains("My added GraphQL event")); + assertFalse(bodyString.contains("where")); + assertFalse(bodyString.contains("when")); + } } diff --git a/pom.xml b/pom.xml index 22d73f3a9e..8f2cc8e902 100644 --- a/pom.xml +++ b/pom.xml @@ -1015,7 +1015,7 @@ asm atomix aws - aws-app-sync + aws-app-sync aws-lambda axon azure