Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
merging bytes test into all fields test
Browse files Browse the repository at this point in the history
  • Loading branch information
siderakis committed Mar 29, 2020
1 parent 27ab22b commit 4c7e1b3
Showing 1 changed file with 8 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ public Map<String, Object> getExtensions() {

static class GreetingsSchemaModule extends SchemaModule {

GreetingsSchemaModule(){
GreetingsSchemaModule() {
super(SchemaOptions.builder().useProtoScalarTypes(true).build());
}

@Query("proto1")
ListenableFuture<TestProto.Proto1> proto1() {
return Futures.immediateFuture(
Expand Down Expand Up @@ -249,7 +250,11 @@ public void executionQueryWithAllFields() {
ExecutionInput executionInput =
ExecutionInput.newExecutionInput()
.query(
"query { proto1 { mapField { key value } camelCaseName id intField RenamedField testInnerProto {foo} }}")
"query { proto1 { "
+ "mapField { key value } "
+ "camelCaseName id intField RenamedField bytesField "
+ "testInnerProto {foo} "
+ "}}")
.build();
ExecutionResult executionResult = graphQL.execute(executionInput);
assertThat(executionResult.getErrors()).isEmpty();
Expand All @@ -271,28 +276,9 @@ public void executionQueryWithAllFields() {
.put("intField", (long) 1)
.put("RenamedField", "name")
.put("testInnerProto", ImmutableMap.of("foo", "foooo"))
.put("bytesField", ByteString.copyFromUtf8("b-y-t-e-s"))
.build())));
}
@Test
public void executionQueryWithBytesFields() {
GraphQL graphQL =
GraphQL.newGraphQL(schema)
.instrumentation(GuavaListenableFutureSupport.listenableFutureInstrumentation())
.build();
ExecutionInput executionInput =
ExecutionInput.newExecutionInput()
.query(
"query { proto1 { bytesField } }")
.build();
ExecutionResult executionResult = graphQL.execute(executionInput);
assertThat(executionResult.getErrors()).isEmpty();
ByteString result =
((ByteString)
((Map<String, Object>)
((Map<String, Object>) executionResult.toSpecification().get("data")).get("proto1")).get("bytesField"));

assertThat(result).isEqualTo(ByteString.copyFromUtf8("b-y-t-e-s"));
}

@Test
public void handlesRuntimeExceptionMessage() {
Expand Down

0 comments on commit 4c7e1b3

Please sign in to comment.