From 6c5838e8101d1062a5d9beac90808385d158d713 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 19 Jan 2023 11:52:27 +0100 Subject: [PATCH] Adding test --- .../documentation/DocumentationGenerator.java | 13 ++++++++---- .../documentation/rst/table/RowType.java | 3 +++ .../utils/documentation/GenerateTest.java | 20 +++++++++++++++++++ src/test/resources/logback-test.xml | 19 ++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 src/test/java/org/gcube/informationsystem/utils/documentation/GenerateTest.java create mode 100644 src/test/resources/logback-test.xml diff --git a/src/main/java/org/gcube/informationsystem/utils/documentation/DocumentationGenerator.java b/src/main/java/org/gcube/informationsystem/utils/documentation/DocumentationGenerator.java index b0b0860..e7555fa 100644 --- a/src/main/java/org/gcube/informationsystem/utils/documentation/DocumentationGenerator.java +++ b/src/main/java/org/gcube/informationsystem/utils/documentation/DocumentationGenerator.java @@ -187,7 +187,7 @@ public class DocumentationGenerator { return row; } - public StringBuffer generatePropertySection(Type type) { + protected StringBuffer generatePropertySection(Type type) { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("\n"); String name = type.getName(); @@ -206,7 +206,7 @@ public class DocumentationGenerator { return stringBuffer; } - public StringBuffer generateResourceSection(Type type) { + protected StringBuffer generateResourceSection(Type type) { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("\n"); String name = type.getName(); @@ -225,7 +225,7 @@ public class DocumentationGenerator { return stringBuffer; } - public StringBuffer generateFacetSection(Type type) { + protected StringBuffer generateFacetSection(Type type) { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("\n"); String name = type.getName(); @@ -282,7 +282,12 @@ public class DocumentationGenerator { return stringBuffer; } - public void generate(List pkgs) throws Exception { + public void generate() throws Exception { + List pkgs = Discovery.discoverPackages(); + generate(pkgs); + } + + protected void generate(List pkgs) throws Exception { DocumentationSchemaAction schemaAction = new DocumentationSchemaAction(pkgs); Discovery.discover(schemaAction); diff --git a/src/main/java/org/gcube/informationsystem/utils/documentation/rst/table/RowType.java b/src/main/java/org/gcube/informationsystem/utils/documentation/rst/table/RowType.java index 0a9a909..bb3b4d1 100644 --- a/src/main/java/org/gcube/informationsystem/utils/documentation/rst/table/RowType.java +++ b/src/main/java/org/gcube/informationsystem/utils/documentation/rst/table/RowType.java @@ -1,5 +1,8 @@ package org.gcube.informationsystem.utils.documentation.rst.table; +/** + * @author Luca Frosini (ISTI - CNR) + */ public enum RowType { HEADING(Table.ROW_SEPARATOR_HEADING), NORMAL(Table.ROW_SEPARATOR); diff --git a/src/test/java/org/gcube/informationsystem/utils/documentation/GenerateTest.java b/src/test/java/org/gcube/informationsystem/utils/documentation/GenerateTest.java new file mode 100644 index 0000000..9e87dcf --- /dev/null +++ b/src/test/java/org/gcube/informationsystem/utils/documentation/GenerateTest.java @@ -0,0 +1,20 @@ +package org.gcube.informationsystem.utils.documentation; + +import java.io.File; +import java.net.URL; + +import org.junit.Test; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public class GenerateTest { + + @Test + public void testDocGeneration() throws Exception { + URL jsonFileURL = GenerateTest.class.getClassLoader().getResource("logback-test.xml"); + File file = new File(jsonFileURL.toURI()); + DocumentationGenerator documentationGenerator = new DocumentationGenerator(file.getParentFile()); + documentationGenerator.generate(); + } +} diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml new file mode 100644 index 0000000..bb8caef --- /dev/null +++ b/src/test/resources/logback-test.xml @@ -0,0 +1,19 @@ + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n + + + + + + + + + + + + \ No newline at end of file