diff --git a/graphql-java-support/src/test/java/com/apollographql/federation/graphqljava/FederatedTracingInstrumentationTest.java b/graphql-java-support/src/test/java/com/apollographql/federation/graphqljava/FederatedTracingInstrumentationTest.java index a618b9ea..c3673022 100644 --- a/graphql-java-support/src/test/java/com/apollographql/federation/graphqljava/FederatedTracingInstrumentationTest.java +++ b/graphql-java-support/src/test/java/com/apollographql/federation/graphqljava/FederatedTracingInstrumentationTest.java @@ -37,6 +37,15 @@ void setupSchema() { objects.add(new Object()); objects.add(new Object()); return objects; + }).dataFetcher("listOfLists", env -> { + ArrayList> lists = new ArrayList<>(2); + lists.add(new ArrayList<>(2)); + lists.add(new ArrayList<>(2)); + lists.get(0).add(new Object()); + lists.get(0).add(new Object()); + lists.get(1).add(new Object()); + lists.get(1).add(new Object()); + return lists; })) .type("Widget", builder -> // Widget.foo works normally, Widget.bar always throws an error @@ -58,7 +67,7 @@ void setupSchema() { @Test void testTracing() throws InvalidProtocolBufferException { - Map result = graphql.execute("{ widgets { foo, baz: bar } }").toSpecification(); + Map result = graphql.execute("{ widgets { foo, baz: bar }, listOfLists { foo } }").toSpecification(); Object extensions = result.get("extensions"); assertTrue(extensions instanceof Map); @@ -72,7 +81,9 @@ void testTracing() throws InvalidProtocolBufferException { assertTrue(trace.getEndTime().getSeconds() > 0, "End time has seconds"); assertTrue(trace.getEndTime().getNanos() > 0, "End time has nanoseconds"); assertTrue(trace.getDurationNs() > 0, "DurationNs is greater than zero"); - assertEquals(1, trace.getRoot().getChildCount()); + assertEquals(2, trace.getRoot().getChildCount()); + + // widgets Reports.Trace.Node widgets = trace.getRoot().getChild(0); assertTrue(widgets.getStartTime() > 0, "Field start time is greater than zero"); @@ -110,5 +121,24 @@ void testTracing() throws InvalidProtocolBufferException { assertEquals(18, error.getLocation(0).getColumn()); assertEquals(1, error.getLocation(0).getLine()); + // listOfLists + Reports.Trace.Node listOfLists = trace.getRoot().getChild(1); + assertEquals(0, listOfLists.getChild(0).getIndex()); + assertEquals(2, listOfLists.getChild(0).getChildCount()); + assertEquals(1, listOfLists.getChild(1).getIndex()); + assertEquals(2, listOfLists.getChild(1).getChildCount()); + + assertEquals(0, listOfLists.getChild(0).getChild(0).getIndex()); + assertEquals(1, listOfLists.getChild(0).getChild(0).getChildCount()); + assertEquals(0, listOfLists.getChild(0).getChild(1).getIndex()); + assertEquals(1, listOfLists.getChild(0).getChild(1).getChildCount()); + + Reports.Trace.Node deeplyNestedFoo = listOfLists.getChild(0).getChild(0).getChild(0); + assertTrue(deeplyNestedFoo.getStartTime() > 0, "Field start time is greater than zero"); + assertTrue(deeplyNestedFoo.getEndTime() > 0, "Field end time is greater than zero"); + assertEquals("Widget", deeplyNestedFoo.getParentType()); + assertEquals("String", deeplyNestedFoo.getType()); + assertEquals("foo", deeplyNestedFoo.getResponseName()); + assertEquals(0, deeplyNestedFoo.getErrorCount()); } }