Search in sources :

Example 1 with AnotherMutationType

use of com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationType in project graphql-maven-plugin-project by graphql-java-generator.

the class AbstractGraphQLRequest_fragmentTest method testBuild_Partial_createHuman_withDirectivesWithOnClause.

@Test
void testBuild_Partial_createHuman_withDirectivesWithOnClause() throws GraphQLRequestPreparationException, GraphQLRequestExecutionException, JsonProcessingException {
    // Preparation
    AnotherMutationType mutationType = new AnotherMutationType("http://localhost/graphql");
    params = new HashMap<>();
    params.put("anotherMutationTypeCreateHumanHuman", input);
    params.put("value", "the mutation value");
    params.put("anotherValue", "the other mutation value");
    params.put("expandedInfo", true);
    // Go, go, go
    @SuppressWarnings("deprecation") AbstractGraphQLRequest graphQLRequest = mutationType.getCreateHumanResponseBuilder().withQueryResponseDef("{id name ... on Human @include(if: &expandedInfo) {friends {id name} appearsIn @testDirective(value:&value,anotherValue:?anotherValue)}}}").build();
    // Verification
    assertEquals(0, graphQLRequest.aliasFields.size());
    assertEquals(// 
    "{\"query\":\"mutation" + // 
    "{createHuman(human:{name:\\\"a new name\\\",appearsIn:[JEDI,EMPIRE,NEWHOPE]})" + // 
    "{id name ... on Human @include(if:true){friends{id name __typename} appearsIn @testDirective(value:\\\"the mutation value\\\",anotherValue:\\\"the other mutation value\\\") __typename}}}" + // 
    "\"}", graphQLRequest.buildRequestAsString(params));
    QueryExecutorImpl_allGraphqlCases_Test.checkRequestMap(graphQLRequest.buildRequestAsMap(params), // 
    "" + // 
    "mutation" + // 
    "{createHuman(human:{name:\"a new name\",appearsIn:[JEDI,EMPIRE,NEWHOPE]})" + // 
    "{id name ... on Human @include(if:true){friends{id name __typename} appearsIn @testDirective(value:\"the mutation value\",anotherValue:\"the other mutation value\") __typename}}}", null, null);
}
Also used : AnotherMutationType(com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationType) QueryExecutorImpl_allGraphqlCases_Test(com.graphql_java_generator.client.QueryExecutorImpl_allGraphqlCases_Test) Test(org.junit.jupiter.api.Test)

Example 2 with AnotherMutationType

use of com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationType in project graphql-maven-plugin-project by graphql-java-generator.

the class AliasesTest method testBuild_Partial_createHuman.

@Test
@Execution(ExecutionMode.CONCURRENT)
void testBuild_Partial_createHuman() throws GraphQLRequestPreparationException, GraphQLRequestExecutionException, JsonProcessingException {
    // Preparation
    AnotherMutationType mutationType = new AnotherMutationType("http://localhost/graphql");
    params = new HashMap<>();
    params.put("anotherMutationTypeCreateHumanHuman", input);
    params.put("value", "the mutation value");
    params.put("anotherValue", "the other mutation value");
    // Go, go, go
    @SuppressWarnings("deprecation") AbstractGraphQLRequest graphQLRequest = mutationType.getCreateHumanResponseBuilder().withQueryResponseDef("{aliasId:id \taliasName: name aliasAppearsIn :appearsIn aliasFriends : friends {aliasId2:id aliasName2:name}}}").build();
    // Verification
    assertEquals(// 
    "{\"query\":\"mutation" + // 
    "{createHuman(human:{name:\\\"a new name\\\",appearsIn:[JEDI,EMPIRE,NEWHOPE]})" + // 
    "{aliasId:id aliasName:name aliasAppearsIn:appearsIn aliasFriends:friends{aliasId2:id aliasName2:name __typename} __typename}}" + // 
    "\"}", graphQLRequest.buildRequestAsString(params));
    QueryExecutorImpl_allGraphqlCases_Test.checkRequestMap(graphQLRequest.buildRequestAsMap(params), // 
    "" + // 
    "mutation" + // 
    "{createHuman(human:{name:\"a new name\",appearsIn:[JEDI,EMPIRE,NEWHOPE]})" + // 
    "{aliasId:id aliasName:name aliasAppearsIn:appearsIn aliasFriends:friends{aliasId2:id aliasName2:name __typename} __typename}}", null, null);
}
Also used : AnotherMutationType(com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationType) Execution(org.junit.jupiter.api.parallel.Execution) QueryExecutorImpl_allGraphqlCases_Test(com.graphql_java_generator.client.QueryExecutorImpl_allGraphqlCases_Test) Test(org.junit.jupiter.api.Test)

Example 3 with AnotherMutationType

use of com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationType in project graphql-maven-plugin-project by graphql-java-generator.

the class AbstractGraphQLRequest_fragmentTest method testBuild_Partial_createHuman_withDirectivesWithoutOnClause.

@Test
void testBuild_Partial_createHuman_withDirectivesWithoutOnClause() throws GraphQLRequestPreparationException, GraphQLRequestExecutionException, JsonProcessingException {
    // Preparation
    AnotherMutationType mutationType = new AnotherMutationType("http://localhost/graphql");
    params = new HashMap<>();
    params.put("anotherMutationTypeCreateHumanHuman", input);
    params.put("value", "the mutation value");
    params.put("anotherValue", "the other mutation value");
    params.put("expandedInfo", false);
    // Go, go, go
    @SuppressWarnings("deprecation") AbstractGraphQLRequest graphQLRequest = mutationType.getCreateHumanResponseBuilder().withQueryResponseDef("{id name ...  @include(if: &expandedInfo) {friends {id name} appearsIn @testDirective(value:&value,anotherValue:?anotherValue)}}}").build();
    // Verification
    assertEquals(0, graphQLRequest.aliasFields.size());
    assertEquals(// 
    "{\"query\":\"mutation" + // 
    "{createHuman(human:{name:\\\"a new name\\\",appearsIn:[JEDI,EMPIRE,NEWHOPE]})" + // 
    "{id name ... @include(if:false){friends{id name __typename} appearsIn @testDirective(value:\\\"the mutation value\\\",anotherValue:\\\"the other mutation value\\\") __typename}}}" + // 
    "\"}", graphQLRequest.buildRequestAsString(params));
    QueryExecutorImpl_allGraphqlCases_Test.checkRequestMap(graphQLRequest.buildRequestAsMap(params), // 
    "" + // 
    "mutation" + // 
    "{createHuman(human:{name:\"a new name\",appearsIn:[JEDI,EMPIRE,NEWHOPE]})" + // 
    "{id name ... @include(if:false){friends{id name __typename} appearsIn @testDirective(value:\"the mutation value\",anotherValue:\"the other mutation value\") __typename}}}", null, null);
}
Also used : AnotherMutationType(com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationType) QueryExecutorImpl_allGraphqlCases_Test(com.graphql_java_generator.client.QueryExecutorImpl_allGraphqlCases_Test) Test(org.junit.jupiter.api.Test)

Example 4 with AnotherMutationType

use of com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationType in project graphql-maven-plugin-project by graphql-java-generator.

the class AbstractGraphQLRequest_allGraphQLCasesTest method testBuild_Partial_createHuman_Alias_Errors.

@Test
@Execution(ExecutionMode.CONCURRENT)
void testBuild_Partial_createHuman_Alias_Errors() throws GraphQLRequestPreparationException, GraphQLRequestExecutionException {
    // Preparation
    AnotherMutationTypeExecutor mutationType = new AnotherMutationType("http://localhost/graphql");
    GraphQLRequestPreparationException e;
    e = assertThrows(GraphQLRequestPreparationException.class, () -> mutationType.getCreateHumanGraphQLRequest("{alias:id alias:name}"));
    assertTrue(e.getMessage().contains(" 'alias' "));
    e = assertThrows(GraphQLRequestPreparationException.class, () -> mutationType.getCreateHumanGraphQLRequest("{aliasId:id friends {aliasId:name}}}"));
    assertTrue(e.getMessage().contains(" 'aliasId' "));
}
Also used : AnotherMutationTypeExecutor(com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationTypeExecutor) GraphQLRequestPreparationException(com.graphql_java_generator.exception.GraphQLRequestPreparationException) AnotherMutationType(com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationType) Execution(org.junit.jupiter.api.parallel.Execution) QueryExecutorImpl_allGraphqlCases_Test(com.graphql_java_generator.client.QueryExecutorImpl_allGraphqlCases_Test) Test(org.junit.jupiter.api.Test)

Example 5 with AnotherMutationType

use of com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationType in project graphql-maven-plugin-project by graphql-java-generator.

the class AbstractGraphQLRequest_allGraphQLCasesTest method testBuild_Full_createHuman_withBuilder.

@Test
@Execution(ExecutionMode.CONCURRENT)
void testBuild_Full_createHuman_withBuilder() throws GraphQLRequestPreparationException, GraphQLRequestExecutionException, JsonProcessingException {
    // Preparation
    AnotherMutationType mutationType = new AnotherMutationType("http://localhost/graphql");
    // Go, go, go
    @SuppressWarnings("deprecation") AbstractGraphQLRequest graphQLRequest = // 
    mutationType.getResponseBuilder().withQueryResponseDef(// 
    "mutation { createHuman (human: &humanInput) @testDirective(value:&value, anotherValue:?anotherValue)   " + // 
    "{id name appearsIn friends {id name}}}").build();
    // Verification
    assertEquals(0, graphQLRequest.aliasFields.size());
    assertEquals(// 
    "{\"query\":\"mutation" + // 
    "{createHuman(human:{name:\\\"a new name\\\",appearsIn:[JEDI,EMPIRE,NEWHOPE]}) @testDirective(value:\\\"the mutation value\\\",anotherValue:\\\"the other mutation value\\\")" + // 
    "{id name appearsIn friends{id name __typename} __typename}}" + // 
    "\"}", graphQLRequest.buildRequestAsString(params));
    QueryExecutorImpl_allGraphqlCases_Test.checkRequestMap(graphQLRequest.buildRequestAsMap(params), // 
    "" + // 
    "mutation" + // 
    "{createHuman(human:{name:\"a new name\",appearsIn:[JEDI,EMPIRE,NEWHOPE]}) @testDirective(value:\"the mutation value\",anotherValue:\"the other mutation value\")" + // 
    "{id name appearsIn friends{id name __typename} __typename}}", null, null);
}
Also used : AnotherMutationType(com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationType) Execution(org.junit.jupiter.api.parallel.Execution) QueryExecutorImpl_allGraphqlCases_Test(com.graphql_java_generator.client.QueryExecutorImpl_allGraphqlCases_Test) Test(org.junit.jupiter.api.Test)

Aggregations

AnotherMutationType (com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationType)11 Test (org.junit.jupiter.api.Test)11 QueryExecutorImpl_allGraphqlCases_Test (com.graphql_java_generator.client.QueryExecutorImpl_allGraphqlCases_Test)10 Execution (org.junit.jupiter.api.parallel.Execution)6 ObjectResponse (com.graphql_java_generator.client.request.ObjectResponse)1 AnotherMutationTypeExecutor (com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationTypeExecutor)1 AnotherMutationTypeResponse (com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationTypeResponse)1 HumanInput (com.graphql_java_generator.domain.client.allGraphQLCases.HumanInput)1 GraphQLRequestPreparationException (com.graphql_java_generator.exception.GraphQLRequestPreparationException)1 Map (java.util.Map)1