Bael 3893 - Code review updates
This commit is contained in:
parent
8b6c667ce0
commit
c10208b4d9
@ -11,7 +11,7 @@ import java.util.Map;
|
|||||||
public class AppSyncClientHelper {
|
public class AppSyncClientHelper {
|
||||||
|
|
||||||
static String apiUrl = "https://m4i3b6icrrb7livfbypfspiifi.appsync-api.us-east-2.amazonaws.com";
|
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";
|
static String API_KEY_HEADER = "x-api-key";
|
||||||
|
|
||||||
public static WebClient.ResponseSpec getResponseBodySpec(Map<String, Object> requestBody) {
|
public static WebClient.ResponseSpec getResponseBodySpec(Map<String, Object> requestBody) {
|
||||||
|
@ -6,8 +6,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class AwsAppSyncApplication {
|
public class AwsAppSyncApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(AwsAppSyncApplication.class, args);
|
SpringApplication.run(AwsAppSyncApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,42 +12,61 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class AwsAppSyncApplicationTests {
|
class AwsAppSyncApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenGraphQuery_whenListEvents_thenReturnAllEvents() {
|
void givenGraphQuery_whenListEvents_thenReturnAllEvents() {
|
||||||
|
|
||||||
Map<String, Object> requestBody = new HashMap<>();
|
Map<String, Object> requestBody = new HashMap<>();
|
||||||
requestBody.put("query", "query ListEvents { listEvents { items { id name where when description } } }");
|
requestBody.put("query", "query ListEvents {" +
|
||||||
requestBody.put("variables", "");
|
" listEvents {" +
|
||||||
requestBody.put("operationName", "ListEvents");
|
" items {" +
|
||||||
|
" id" +
|
||||||
|
" name" +
|
||||||
|
" where" +
|
||||||
|
" when" +
|
||||||
|
" description" +
|
||||||
|
" }" +
|
||||||
|
" }" +
|
||||||
|
"}");
|
||||||
|
requestBody.put("variables", "");
|
||||||
|
requestBody.put("operationName", "ListEvents");
|
||||||
|
|
||||||
String bodyString = AppSyncClientHelper.getResponseBodySpec(requestBody)
|
String bodyString = AppSyncClientHelper.getResponseBodySpec(requestBody)
|
||||||
.bodyToMono(String.class).block();
|
.bodyToMono(String.class).block();
|
||||||
|
|
||||||
assertNotNull(bodyString);
|
assertNotNull(bodyString);
|
||||||
assertTrue(bodyString.contains("My First Event"));
|
assertTrue(bodyString.contains("My First Event"));
|
||||||
assertTrue(bodyString.contains("where"));
|
assertTrue(bodyString.contains("where"));
|
||||||
assertTrue(bodyString.contains("when"));
|
assertTrue(bodyString.contains("when"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenGraphAdd_whenMutation_thenReturnIdNameDesc() {
|
void givenGraphAdd_whenMutation_thenReturnIdNameDesc() {
|
||||||
|
|
||||||
String queryString = "mutation add { createEvent( name:\"My added GraphQL event\" where:\"Day 2\"" +
|
String queryString = "mutation add {" +
|
||||||
" when:\"Saturday night\" description:\"Studying GraphQL\" ){ id name description } }";
|
" createEvent(" +
|
||||||
|
" name:\"My added GraphQL event\"" +
|
||||||
|
" where:\"Day 2\"" +
|
||||||
|
" when:\"Saturday night\"" +
|
||||||
|
" description:\"Studying GraphQL\"" +
|
||||||
|
" ){" +
|
||||||
|
" id" +
|
||||||
|
" name" +
|
||||||
|
" description" +
|
||||||
|
" }" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
Map<String, Object> requestBody = new HashMap<>();
|
||||||
|
requestBody.put("query", queryString);
|
||||||
|
requestBody.put("variables", "");
|
||||||
|
requestBody.put("operationName", "add");
|
||||||
|
|
||||||
Map<String, Object> requestBody = new HashMap<>();
|
WebClient.ResponseSpec response = AppSyncClientHelper.getResponseBodySpec(requestBody);
|
||||||
requestBody.put("query", queryString);
|
|
||||||
requestBody.put("variables", "");
|
|
||||||
requestBody.put("operationName", "add");
|
|
||||||
|
|
||||||
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"));
|
||||||
assertNotNull(bodyString);
|
assertFalse(bodyString.contains("where"));
|
||||||
assertTrue(bodyString.contains("My added GraphQL event"));
|
assertFalse(bodyString.contains("when"));
|
||||||
assertFalse(bodyString.contains("where"));
|
}
|
||||||
assertFalse(bodyString.contains("when"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
2
pom.xml
2
pom.xml
@ -1015,7 +1015,7 @@
|
|||||||
<module>asm</module>
|
<module>asm</module>
|
||||||
<module>atomix</module>
|
<module>atomix</module>
|
||||||
<module>aws</module>
|
<module>aws</module>
|
||||||
<module>aws-app-sync</module>
|
<module>aws-app-sync</module>
|
||||||
<module>aws-lambda</module>
|
<module>aws-lambda</module>
|
||||||
<module>axon</module>
|
<module>axon</module>
|
||||||
<module>azure</module>
|
<module>azure</module>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user