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 2021/07/13 16:29:30 UTC
[sling-whiteboard] branch master updated (1448d69 -> a22f112)
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git.
from 1448d69 Renaming to remove commons
new 912c457 SLING-10551 - section names must be capitalized in schema
new 0696c3c SLING-10551 - section names must be capitalized in schema
new a22f112 Merge commit '0696c3c0'
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../aggregator/impl/DefaultSchemaAggregator.java | 12 ++++++++++-
...artialProviderTest.java => CapitalizeTest.java} | 25 +++++++++++++++-------
.../impl/DefaultSchemaAggregatorTest.java | 8 +++----
.../test/resources/several-providers-output.txt | 2 +-
4 files changed, 33 insertions(+), 14 deletions(-)
copy sling-org-apache-sling-graphql-schema/src/test/java/org/apache/sling/graphql/schema/aggregator/impl/{BundleEntryPartialProviderTest.java => CapitalizeTest.java} (60%)
[sling-whiteboard] 02/03: SLING-10551 - section names must be
capitalized in schema
Posted by bd...@apache.org.
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-whiteboard.git
commit 912c4575ea7ab879a8aed29757dcd162f17ee884
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Jul 13 18:24:27 2021 +0200
SLING-10551 - section names must be capitalized in schema
---
.../schema/aggregator/impl/CapitalizeTest.java | 43 ++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/sling-org-apache-sling-graphql-schema/src/test/java/org/apache/sling/graphql/schema/aggregator/impl/CapitalizeTest.java b/sling-org-apache-sling-graphql-schema/src/test/java/org/apache/sling/graphql/schema/aggregator/impl/CapitalizeTest.java
new file mode 100644
index 0000000..aaca60d
--- /dev/null
+++ b/sling-org-apache-sling-graphql-schema/src/test/java/org/apache/sling/graphql/schema/aggregator/impl/CapitalizeTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.schema.aggregator.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class CapitalizeTest {
+ @Test
+ public void normalStrings() throws Exception {
+ assertEquals("Voici", DefaultSchemaAggregator.capitalize("voici"));
+ assertEquals("Ou bien", DefaultSchemaAggregator.capitalize("OU BIEN"));
+ }
+
+ @Test
+ public void emptyStrings() throws Exception {
+ assertEquals("", DefaultSchemaAggregator.capitalize(""));
+ assertEquals(null, DefaultSchemaAggregator.capitalize(null));
+ }
+
+ @Test
+ public void shortStrings() throws Exception {
+ assertEquals("A", DefaultSchemaAggregator.capitalize("a"));
+ assertEquals("B", DefaultSchemaAggregator.capitalize("B"));
+ }
+}
\ No newline at end of file
[sling-whiteboard] 01/03: SLING-10551 - section names must be
capitalized in schema
Posted by bd...@apache.org.
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-whiteboard.git
commit 0696c3c01b640907e29eb446f2294e09b11999be
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Jul 13 18:23:30 2021 +0200
SLING-10551 - section names must be capitalized in schema
---
.../aggregator/impl/DefaultSchemaAggregator.java | 12 +++++-
.../schema/aggregator/impl/CapitalizeTest.java | 43 ++++++++++++++++++++++
.../impl/DefaultSchemaAggregatorTest.java | 8 ++--
.../test/resources/several-providers-output.txt | 2 +-
4 files changed, 59 insertions(+), 6 deletions(-)
diff --git a/sling-org-apache-sling-graphql-schema/src/main/java/org/apache/sling/graphql/schema/aggregator/impl/DefaultSchemaAggregator.java b/sling-org-apache-sling-graphql-schema/src/main/java/org/apache/sling/graphql/schema/aggregator/impl/DefaultSchemaAggregator.java
index 1b47804..164fdc0 100644
--- a/sling-org-apache-sling-graphql-schema/src/main/java/org/apache/sling/graphql/schema/aggregator/impl/DefaultSchemaAggregator.java
+++ b/sling-org-apache-sling-graphql-schema/src/main/java/org/apache/sling/graphql/schema/aggregator/impl/DefaultSchemaAggregator.java
@@ -66,8 +66,18 @@ public class DefaultSchemaAggregator implements SchemaAggregator {
}
}
+ static String capitalize(String s) {
+ if(s == null) {
+ return null;
+ } else if(s.length() > 1) {
+ return String.format("%s%s", s.substring(0, 1).toUpperCase(), s.substring(1, s.length()).toLowerCase());
+ } else {
+ return s.toUpperCase();
+ }
+ }
+
private void copySection(Set<Partial> selected, String sectionName, boolean inBlock, Writer target) throws IOException {
- String prefixToWrite = inBlock ? String.format("%ntype %s {%n", sectionName) : null;
+ String prefixToWrite = inBlock ? String.format("%ntype %s {%n", capitalize(sectionName)) : null;
boolean anyOutput = false;
for(Partial p : selected) {
final Optional<Partial.Section> section = p.getSection(sectionName);
diff --git a/sling-org-apache-sling-graphql-schema/src/test/java/org/apache/sling/graphql/schema/aggregator/impl/CapitalizeTest.java b/sling-org-apache-sling-graphql-schema/src/test/java/org/apache/sling/graphql/schema/aggregator/impl/CapitalizeTest.java
new file mode 100644
index 0000000..aaca60d
--- /dev/null
+++ b/sling-org-apache-sling-graphql-schema/src/test/java/org/apache/sling/graphql/schema/aggregator/impl/CapitalizeTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.schema.aggregator.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class CapitalizeTest {
+ @Test
+ public void normalStrings() throws Exception {
+ assertEquals("Voici", DefaultSchemaAggregator.capitalize("voici"));
+ assertEquals("Ou bien", DefaultSchemaAggregator.capitalize("OU BIEN"));
+ }
+
+ @Test
+ public void emptyStrings() throws Exception {
+ assertEquals("", DefaultSchemaAggregator.capitalize(""));
+ assertEquals(null, DefaultSchemaAggregator.capitalize(null));
+ }
+
+ @Test
+ public void shortStrings() throws Exception {
+ assertEquals("A", DefaultSchemaAggregator.capitalize("a"));
+ assertEquals("B", DefaultSchemaAggregator.capitalize("B"));
+ }
+}
\ No newline at end of file
diff --git a/sling-org-apache-sling-graphql-schema/src/test/java/org/apache/sling/graphql/schema/aggregator/impl/DefaultSchemaAggregatorTest.java b/sling-org-apache-sling-graphql-schema/src/test/java/org/apache/sling/graphql/schema/aggregator/impl/DefaultSchemaAggregatorTest.java
index cf7e79c..cd4f26a 100644
--- a/sling-org-apache-sling-graphql-schema/src/test/java/org/apache/sling/graphql/schema/aggregator/impl/DefaultSchemaAggregatorTest.java
+++ b/sling-org-apache-sling-graphql-schema/src/test/java/org/apache/sling/graphql/schema/aggregator/impl/DefaultSchemaAggregatorTest.java
@@ -112,13 +112,13 @@ public class DefaultSchemaAggregatorTest {
assertTrue(reg.getType("SlingResourceConnection").isPresent());
assertTrue(reg.getType("PageInfo").isPresent());
- final Optional<TypeDefinition> query = reg.getType("QUERY");
- assertTrue("Expecting QUERY", query.isPresent());
+ final Optional<TypeDefinition> query = reg.getType("Query");
+ assertTrue("Expecting Query", query.isPresent());
assertTrue(query.get().getChildren().toString().contains("oneSchemaResource"));
assertTrue(query.get().getChildren().toString().contains("oneSchemaQuery"));
- final Optional<TypeDefinition> mutation = reg.getType("MUTATION");
- assertTrue("Expecting MUTATION", mutation.isPresent());
+ final Optional<TypeDefinition> mutation = reg.getType("Mutation");
+ assertTrue("Expecting Mutation", mutation.isPresent());
assertTrue(mutation.get().getChildren().toString().contains("someMutation"));
}
diff --git a/sling-org-apache-sling-graphql-schema/src/test/resources/several-providers-output.txt b/sling-org-apache-sling-graphql-schema/src/test/resources/several-providers-output.txt
index 2b2c828..b3fa1f7 100644
--- a/sling-org-apache-sling-graphql-schema/src/test/resources/several-providers-output.txt
+++ b/sling-org-apache-sling-graphql-schema/src/test/resources/several-providers-output.txt
@@ -1,6 +1,6 @@
# Schema aggregated by DefaultSchemaAggregator
-type QUERY {
+type Query {
# DefaultSchemaAggregator.source=B1a
Fake query for B1a.txt
[sling-whiteboard] 03/03: Merge commit '0696c3c0'
Posted by bd...@apache.org.
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-whiteboard.git
commit a22f112d8896e54923357df0bc00c289a186608e
Merge: 912c457 0696c3c
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Jul 13 18:27:00 2021 +0200
Merge commit '0696c3c0'
.../schema/aggregator/impl/DefaultSchemaAggregator.java | 12 +++++++++++-
.../schema/aggregator/impl/DefaultSchemaAggregatorTest.java | 8 ++++----
.../src/test/resources/several-providers-output.txt | 2 +-
3 files changed, 16 insertions(+), 6 deletions(-)