Search in sources :

Example 1 with Episode

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

the class AbstractGraphQLRequest_fragmentTest method setup.

@BeforeEach
void setup() {
    // Default configuration for GraphQLRequest
    GraphQLRequest.setStaticConfiguration(new GraphQLConfiguration("http://localhost"));
    // A useful init for some tests
    input = new HumanInput();
    input.setName("a new name");
    List<Episode> episodes = new ArrayList<>();
    episodes.add(Episode.JEDI);
    episodes.add(Episode.EMPIRE);
    episodes.add(Episode.NEWHOPE);
    input.setAppearsIn(episodes);
    params.put("humanInput", input);
    params.put("value", "the mutation value");
    params.put("anotherValue", "the other mutation value");
    params.put("uppercaseFalse", false);
    params.put("uppercaseTrue", true);
}
Also used : Episode(com.graphql_java_generator.domain.client.allGraphQLCases.Episode) HumanInput(com.graphql_java_generator.domain.client.allGraphQLCases.HumanInput) ArrayList(java.util.ArrayList) GraphQLConfiguration(com.graphql_java_generator.client.GraphQLConfiguration) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with Episode

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

the class AbstractGraphQLRequest_allGraphQLCasesTest method setup.

@BeforeEach
void setup() {
    input = new HumanInput();
    input.setName("a new name");
    List<Episode> episodes = new ArrayList<>();
    episodes.add(Episode.JEDI);
    episodes.add(Episode.EMPIRE);
    episodes.add(Episode.NEWHOPE);
    input.setAppearsIn(episodes);
    params.put("humanInput", input);
    params.put("value", "the mutation value");
    params.put("anotherValue", "the other mutation value");
}
Also used : Episode(com.graphql_java_generator.domain.client.allGraphQLCases.Episode) HumanInput(com.graphql_java_generator.domain.client.allGraphQLCases.HumanInput) ArrayList(java.util.ArrayList) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with Episode

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

the class AbstractGraphQLRepositoryInvocationHandlerTest method testInvoke_partialRequest_subscription.

@SuppressWarnings("unchecked")
@Test
void testInvoke_partialRequest_subscription() throws GraphQLRequestExecutionException, NoSuchMethodException, SecurityException {
    // Preparation
    SubscriptionCallback<Human> callback = new SubscriptionCallback<Human>() {

        @Override
        public void onConnect() {
        }

        @Override
        public void onMessage(Human t) {
        }

        @Override
        public void onClose(int statusCode, String reason) {
        }

        @Override
        public void onError(Throwable cause) {
        }
    };
    Episode episode = Episode.JEDI;
    SubscriptionClient subscriptionClient = new SubscriptionClientReactiveImpl(null, null);
    doReturn(subscriptionClient).when(spySubscriptionExecutor).subscribeNewHumanForEpisodeWithBindValues(any(ObjectResponse.class), any(SubscriptionCallback.class), any(Episode.class), any(Map.class));
    // Go, go, go
    SubscriptionClient verif = graphQLRepository.subscribeNewHumanForEpisode(callback, episode);
    // Verification
    assertEquals(subscriptionClient, verif);
    assertEquals("{ id   appearsIn }", GraphQLRepositoryTestHelper.getRegisteredGraphQLRequest(invocationHandler, GraphQLRepositoryTestCase.class, "subscribeNewHumanForEpisode", SubscriptionCallback.class, Episode.class));
}
Also used : Human(com.graphql_java_generator.domain.client.allGraphQLCases.Human) Episode(com.graphql_java_generator.domain.client.allGraphQLCases.Episode) SubscriptionClientReactiveImpl(com.graphql_java_generator.client.SubscriptionClientReactiveImpl) SubscriptionClient(com.graphql_java_generator.client.SubscriptionClient) SubscriptionCallback(com.graphql_java_generator.client.SubscriptionCallback) ObjectResponse(com.graphql_java_generator.client.request.ObjectResponse) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 4 with Episode

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

the class AliasesTest method setup.

@BeforeEach
void setup() {
    input = new HumanInput();
    input.setName("a new name");
    List<Episode> episodes = new ArrayList<>();
    episodes.add(Episode.JEDI);
    episodes.add(Episode.EMPIRE);
    episodes.add(Episode.NEWHOPE);
    input.setAppearsIn(episodes);
    params.put("humanInput", input);
    params.put("value", "the mutation value");
    params.put("anotherValue", "the other mutation value");
}
Also used : Episode(com.graphql_java_generator.domain.client.allGraphQLCases.Episode) HumanInput(com.graphql_java_generator.domain.client.allGraphQLCases.HumanInput) ArrayList(java.util.ArrayList) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with Episode

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

the class AbstractCustomJacksonDeserializerTest method test_deserialize.

@org.junit.jupiter.api.Test
void test_deserialize() throws JsonProcessingException {
    // Preparation
    Test test = new Test();
    // 
    List<Date> dates = new ArrayList<>();
    dates.add(new GregorianCalendar(2020, 12 - 1, 21).getTime());
    dates.add(new GregorianCalendar(2020, 12 - 1, 22).getTime());
    dates.add(new GregorianCalendar(2020, 12 - 1, 23).getTime());
    test.dates = dates;
    // 
    List<String> comments = new ArrayList<>();
    comments.add("comment 1");
    comments.add("comment 2");
    test.comments = comments;
    // 
    List<Boolean> booleans = new ArrayList<>();
    booleans.add(true);
    booleans.add(false);
    test.booleans = booleans;
    // 
    List<Human> friends = new ArrayList<>();
    List<Character> friendsOfFirstHuman = new ArrayList<>();
    List<Episode> appearsIn = new ArrayList<>();
    appearsIn.add(Episode.EMPIRE);
    appearsIn.add(Episode.JEDI);
    friendsOfFirstHuman.add(Human.builder().withId("id friend 1").withName("friend 1").withNbComments(-1).withAppearsIn(appearsIn).build());
    friendsOfFirstHuman.add(Droid.builder().withId("id friend 2").withName("friend 2").build());
    friends.add(Human.builder().withId("id1").withName("human 1").withNbComments(1).withFriends(friendsOfFirstHuman).build());
    friends.add(Human.builder().withId("id2").withName("human 2").withNbComments(2).build());
    test.friends = friends;
    // 
    List<List<Character>> listOfListOfCharacters = new ArrayList<>();
    // An interesting test
    listOfListOfCharacters.add(null);
    // An empty list
    listOfListOfCharacters.add(new ArrayList<>());
    // A non empty list
    listOfListOfCharacters.add(friendsOfFirstHuman);
    test.listOfListOfCharacters = listOfListOfCharacters;
    // 
    List<List<Double>> matrix = new ArrayList<>();
    List<Double> sublist = new ArrayList<>();
    sublist.add(-61.203425);
    sublist.add(0.2343257);
    matrix.add(sublist);
    List<Double> sublist2 = new ArrayList<>();
    sublist2.add(-61.203425 * 2);
    sublist2.add(0.2343257 * 2);
    sublist2.add(234.567);
    matrix.add(sublist2);
    test.matrix = matrix;
    // 
    test.ids = new ArrayList<>();
    test.ids.add("11111111-1111-1111-1111-111111111111");
    test.ids.add("22222222-2222-2222-2222-222222222222");
    test.ids.add("33333333-3333-3333-3333-333333333333");
    String json = new ObjectMapper().writeValueAsString(test);
    // Go, go, go
    Test verify = new ObjectMapper().readValue(json, Test.class);
    // Verification
    assertEquals(3, verify.dates.size());
    assertEquals(new GregorianCalendar(2020, 12 - 1, 21).getTime(), verify.dates.get(0));
    assertEquals(new GregorianCalendar(2020, 12 - 1, 22).getTime(), verify.dates.get(1));
    assertEquals(new GregorianCalendar(2020, 12 - 1, 23).getTime(), verify.dates.get(2));
    // 
    assertEquals(2, verify.comments.size());
    assertEquals("comment 1", verify.comments.get(0));
    assertEquals("comment 2", verify.comments.get(1));
    // 
    assertEquals(2, verify.booleans.size());
    assertEquals(true, verify.booleans.get(0));
    assertEquals(false, verify.booleans.get(1));
    // 
    assertEquals(2, verify.friends.size());
    assertEquals(2, verify.friends.get(0).getFriends().size(), "embedded friends list");
    assertEquals("id friend 1", verify.friends.get(0).getFriends().get(0).getId(), "embedded list (id)");
    assertEquals(2, verify.friends.get(0).getFriends().get(0).getAppearsIn().size(), "embedded episodes (appearsIn)");
    assertEquals(Episode.EMPIRE, verify.friends.get(0).getFriends().get(0).getAppearsIn().get(0), "embedded episodes (appearsIn(0))");
    // 
    assertEquals(3, verify.listOfListOfCharacters.size());
    assertEquals(null, verify.listOfListOfCharacters.get(0));
    assertEquals(0, verify.listOfListOfCharacters.get(1).size());
    assertEquals(2, verify.listOfListOfCharacters.get(2).size());
    // 
    assertEquals(2, verify.matrix.size());
    // 
    assertEquals(2, verify.matrix.get(0).size());
    assertEquals(-61.203425, verify.matrix.get(0).get(0));
    assertEquals(0.2343257, verify.matrix.get(0).get(1));
    // 
    assertEquals(3, verify.matrix.get(1).size());
    assertEquals(-61.203425 * 2, verify.matrix.get(1).get(0));
    assertEquals(0.2343257 * 2, verify.matrix.get(1).get(1));
    assertEquals(234.567, verify.matrix.get(1).get(2));
    // 
    assertEquals(3, test.ids.size());
    assertEquals("11111111-1111-1111-1111-111111111111", test.ids.get(0));
    assertEquals("22222222-2222-2222-2222-222222222222", test.ids.get(1));
    assertEquals("33333333-3333-3333-3333-333333333333", test.ids.get(2));
}
Also used : Human(com.graphql_java_generator.domain.client.allGraphQLCases.Human) Character(com.graphql_java_generator.domain.client.allGraphQLCases.Character) ArrayList(java.util.ArrayList) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) Episode(com.graphql_java_generator.domain.client.allGraphQLCases.Episode) ArrayList(java.util.ArrayList) List(java.util.List) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

Episode (com.graphql_java_generator.domain.client.allGraphQLCases.Episode)5 ArrayList (java.util.ArrayList)4 HumanInput (com.graphql_java_generator.domain.client.allGraphQLCases.HumanInput)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 Human (com.graphql_java_generator.domain.client.allGraphQLCases.Human)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 GraphQLConfiguration (com.graphql_java_generator.client.GraphQLConfiguration)1 SubscriptionCallback (com.graphql_java_generator.client.SubscriptionCallback)1 SubscriptionClient (com.graphql_java_generator.client.SubscriptionClient)1 SubscriptionClientReactiveImpl (com.graphql_java_generator.client.SubscriptionClientReactiveImpl)1 ObjectResponse (com.graphql_java_generator.client.request.ObjectResponse)1 Character (com.graphql_java_generator.domain.client.allGraphQLCases.Character)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 List (java.util.List)1 Map (java.util.Map)1 Test (org.junit.jupiter.api.Test)1