You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2020/09/22 10:41:13 UTC

[sling-org-apache-sling-graphql-core] branch master updated: Add schema introspection test

This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-graphql-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 4db773a  Add schema introspection test
4db773a is described below

commit 4db773a27ef732ebadedc00d26b015b38bb7fa5d
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Sep 22 12:40:57 2020 +0200

    Add schema introspection test
---
 .../core/engine/IntrospectionQueryTest.java        | 40 ++++++++++++++++++++++
 .../graphql/core/engine/ResourceQueryTestBase.java |  6 ----
 2 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/src/test/java/org/apache/sling/graphql/core/engine/IntrospectionQueryTest.java b/src/test/java/org/apache/sling/graphql/core/engine/IntrospectionQueryTest.java
new file mode 100644
index 0000000..4c4d476
--- /dev/null
+++ b/src/test/java/org/apache/sling/graphql/core/engine/IntrospectionQueryTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.graphql.core.engine;
+
+import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
+
+import static org.junit.Assert.assertThat;
+import static org.hamcrest.Matchers.contains;
+
+import org.junit.Test;
+
+public class IntrospectionQueryTest extends ResourceQueryTestBase {
+    
+    @Test
+    public void schemaIntrospectionTest() throws Exception {
+        final String json = queryJSON("{ __schema { types { name } directives { description }}}");
+        assertThat(json, hasJsonPath("$.data.__schema"));
+        assertThat(json, hasJsonPath("$.data.__schema.types"));
+        assertThat(json, hasJsonPath("$.data.__schema.types..name"));
+        assertThat(json, hasJsonPath("$.data.__schema.directives"));
+        assertThat(json, hasJsonPath("$.data.__schema.directives..description"));
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/graphql/core/engine/ResourceQueryTestBase.java b/src/test/java/org/apache/sling/graphql/core/engine/ResourceQueryTestBase.java
index b36174b..d9bfb0a 100644
--- a/src/test/java/org/apache/sling/graphql/core/engine/ResourceQueryTestBase.java
+++ b/src/test/java/org/apache/sling/graphql/core/engine/ResourceQueryTestBase.java
@@ -21,8 +21,6 @@ package org.apache.sling.graphql.core.engine;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Hashtable;
 import java.util.UUID;
 
 import org.apache.sling.api.resource.Resource;
@@ -30,12 +28,8 @@ import org.apache.sling.api.servlets.ServletResolver;
 import org.apache.sling.graphql.api.SchemaProvider;
 import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
 import org.apache.sling.graphql.core.json.JsonSerializer;
-import org.apache.sling.graphql.core.mocks.DigestDataFetcher;
-import org.apache.sling.graphql.core.mocks.EchoDataFetcher;
-import org.apache.sling.graphql.core.mocks.FailingDataFetcher;
 import org.apache.sling.graphql.core.mocks.MockSchemaProvider;
 import org.apache.sling.graphql.core.mocks.MockScriptServlet;
-import org.apache.sling.graphql.core.mocks.TestUtil;
 import org.apache.sling.graphql.core.scalars.SlingScalarsProvider;
 import org.junit.Before;
 import org.junit.Rule;