use of com.graphql_java_generator.domain.client.allGraphQLCases.AllFieldCases in project graphql-maven-plugin-project by graphql-java-generator.
the class GraphQLObjectMapperTest method testListOneString.
@Test
void testListOneString() throws JsonMappingException, JsonProcessingException, NoSuchFieldException {
// Preparation
GraphQLObjectMapper objectMapper = new GraphQLObjectMapper(AllFieldCases.class.getPackage().getName(), getAliasFields(AllFieldCases.class, "commentsAlias", "comments"));
// Go, go, go
AllFieldCases test = objectMapper.readValue("{\"commentsAlias\":[\"my str\"], \"__typename\":\"AllFieldCases\"}", AllFieldCases.class);
// Verification
assertEquals(1, test.aliasValues.keySet().size());
assertTrue(test.aliasValues.get("commentsAlias") instanceof List);
assertEquals(1, ((List<?>) test.aliasValues.get("commentsAlias")).size());
assertTrue(((List<?>) test.aliasValues.get("commentsAlias")).get(0) instanceof String);
assertEquals("my str", ((List<?>) test.aliasValues.get("commentsAlias")).get(0));
}
use of com.graphql_java_generator.domain.client.allGraphQLCases.AllFieldCases in project graphql-maven-plugin-project by graphql-java-generator.
the class GraphQLObjectMapperTest method testObject.
@Test
void testObject() throws JsonMappingException, JsonProcessingException, NoSuchFieldException {
// Preparation
GraphQLObjectMapper objectMapper = new GraphQLObjectMapper(AllFieldCases.class.getPackage().getName(), getAliasFields(AllFieldCases.class, "oneWithIdSubTypeAlias", "oneWithIdSubType"));
// Go, go, go
AllFieldCases test = objectMapper.readValue(//
"" + //
"{" + //
" \"forname\":\"the root str value\", " + " \"oneWithIdSubTypeAlias\": {\"name\":\"the alias's str value\", \"__typename\":\"AllFieldCasesWithIdSubtype\"}," + //
" \"__typename\":\"AllFieldCases\" " + "}", AllFieldCases.class);
// Verification
assertEquals("the root str value", test.getForname());
assertEquals(1, test.aliasValues.keySet().size());
assertTrue(test.aliasValues.get("oneWithIdSubTypeAlias") instanceof AllFieldCasesWithIdSubtype);
AllFieldCasesWithIdSubtype verif = (AllFieldCasesWithIdSubtype) test.aliasValues.get("oneWithIdSubTypeAlias");
assertEquals("the alias's str value", verif.getName());
}
use of com.graphql_java_generator.domain.client.allGraphQLCases.AllFieldCases in project graphql-maven-plugin-project by graphql-java-generator.
the class GraphQLObjectMapperTest method testListTwoStrings.
@Test
void testListTwoStrings() throws JsonMappingException, JsonProcessingException, NoSuchFieldException {
// Preparation
GraphQLObjectMapper objectMapper = new GraphQLObjectMapper(AllFieldCases.class.getPackage().getName(), getAliasFields(AllFieldCases.class, "commentsAlias", "comments"));
// Go, go, go
AllFieldCases test = objectMapper.readValue("{\"commentsAlias\":[\"my str1\", \"my str2\"], \"__typename\":\"AllFieldCases\"}", AllFieldCases.class);
// Verification
assertEquals(1, test.aliasValues.keySet().size());
assertTrue(test.aliasValues.get("commentsAlias") instanceof List);
//
assertEquals(2, ((List<?>) test.aliasValues.get("commentsAlias")).size());
//
assertTrue(((List<?>) test.aliasValues.get("commentsAlias")).get(0) instanceof String);
assertEquals("my str1", ((List<?>) test.aliasValues.get("commentsAlias")).get(0));
//
assertTrue(((List<?>) test.aliasValues.get("commentsAlias")).get(1) instanceof String);
assertEquals("my str2", ((List<?>) test.aliasValues.get("commentsAlias")).get(1));
}
use of com.graphql_java_generator.domain.client.allGraphQLCases.AllFieldCases in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractGraphQLRepositoryInvocationHandlerTest method testInvoke_partialRequest_withListParam.
@SuppressWarnings("unchecked")
@Test
void testInvoke_partialRequest_withListParam() throws GraphQLRequestExecutionException, NoSuchMethodException, SecurityException {
// Preparation
AllFieldCases expected = new AllFieldCases();
doReturn(expected).when(spyQueryExecutor).withListOfListWithBindValues(any(ObjectResponse.class), any(List.class), any(Map.class));
// Go, go, go
AllFieldCases verif = graphQLRepository.withListParam(Arrays.asList(Arrays.asList((float) 1.1)));
// Verification
assertEquals(expected, verif);
assertEquals("", GraphQLRepositoryTestHelper.getRegisteredGraphQLRequest(invocationHandler, GraphQLRepositoryTestCase.class, "withListParam", List.class));
}
use of com.graphql_java_generator.domain.client.allGraphQLCases.AllFieldCases in project graphql-maven-plugin-project by graphql-java-generator.
the class GraphQLObjectMapperTest method testListListList.
@SuppressWarnings("unchecked")
@Test
void testListListList() throws JsonMappingException, JsonProcessingException, NoSuchFieldException {
// Preparation
GraphQLObjectMapper objectMapper = new GraphQLObjectMapper(AllFieldCases.class.getPackage().getName(), getAliasFields(AllFieldCases.class, "matrixAlias", "matrix"));
// Go, go, go
AllFieldCases test = objectMapper.readValue("{\"matrixAlias\":[[11.11, 222.222],[],[3333.3333]], \"__typename\":\"AllFieldCases\"}", AllFieldCases.class);
// Verification
assertEquals(1, test.aliasValues.keySet().size());
assertTrue(test.aliasValues.get("matrixAlias") instanceof List);
List<?> mainList = (List<?>) test.aliasValues.get("matrixAlias");
//
assertEquals(3, mainList.size(), "3 subsublists");
//
List<Double> list = (List<Double>) mainList.get(0);
assertEquals(2, list.size());
assertEquals(11.11, list.get(0));
assertEquals(222.222, list.get(1));
//
list = (List<Double>) mainList.get(1);
assertEquals(0, list.size());
//
list = (List<Double>) mainList.get(2);
assertEquals(1, list.size());
assertEquals(3333.3333, list.get(0));
}
Aggregations