diff --git a/pom.xml b/pom.xml index f967ff1..65bf676 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ UTF-8 UTF-8 -Xdoclint:none - + https://sonarcloud.io navit navikt_fp-nare @@ -100,24 +100,6 @@ com.fasterxml.jackson.datatype jackson-datatype-jdk8 - - ca.szc.thirdparty.nl.jworks.markdown_to_asciidoc - markdown_to_asciidoc - - 1.0 - - - - io.github.swagger2markup - markup-document-builder - 1.1.2 - - - nl.jworks.markdown_to_asciidoc - markdown_to_asciidoc - - - diff --git a/src/main/java/no/nav/fpsak/nare/doc/doclet/AsciidocMapper.java b/src/main/java/no/nav/fpsak/nare/doc/doclet/AsciidocMapper.java deleted file mode 100644 index 802fba1..0000000 --- a/src/main/java/no/nav/fpsak/nare/doc/doclet/AsciidocMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package no.nav.fpsak.nare.doc.doclet; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; - -import io.github.swagger2markup.markup.builder.MarkupDocBuilder; -import io.github.swagger2markup.markup.builder.MarkupDocBuilders; -import io.github.swagger2markup.markup.builder.MarkupLanguage; - -class AsciidocMapper { - - void writeTo(Path path, MarkupOutput model) { - MarkupDocBuilder documentBuilder = MarkupDocBuilders.documentBuilder(MarkupLanguage.ASCIIDOC); - - model.apply(1, documentBuilder); - - documentBuilder.writeToFile(path, StandardCharsets.UTF_8, StandardOpenOption.CREATE, - StandardOpenOption.TRUNCATE_EXISTING); - } -} diff --git a/src/main/java/no/nav/fpsak/nare/doc/doclet/GrunnlagInterfaceModell.java b/src/main/java/no/nav/fpsak/nare/doc/doclet/GrunnlagInterfaceModell.java deleted file mode 100644 index 0e6763f..0000000 --- a/src/main/java/no/nav/fpsak/nare/doc/doclet/GrunnlagInterfaceModell.java +++ /dev/null @@ -1,81 +0,0 @@ -package no.nav.fpsak.nare.doc.doclet; - -import java.util.ArrayList; -import java.util.List; - -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.type.TypeKind; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; - -import io.github.swagger2markup.markup.builder.MarkupDocBuilder; -import io.github.swagger2markup.markup.builder.MarkupTableColumn; -import jdk.javadoc.doclet.DocletEnvironment; - -public class GrunnlagInterfaceModell implements MarkupOutput { - private final List entries = new ArrayList<>(); - private DocletEnvironment docEnv; - - static class Entry { - Class targetClass; - String name; - String classDoc; - TypeElement typeElement; - - public Entry(TypeElement typeElement, String doc) throws ClassNotFoundException { - this.typeElement = typeElement; - this.classDoc = doc; - this.name = typeElement.getQualifiedName().toString(); - this.targetClass = Class.forName(this.name); - } - } - - public GrunnlagInterfaceModell(DocletEnvironment docEnv) { - this.docEnv = docEnv; - } - - @Override - public void apply(int sectionLevel, MarkupDocBuilder doc) { - final int sl = sectionLevel++; - doc.sectionTitleLevel(sl + 1, "INPUT"); - List columnSpecs = new ArrayList<>(); - columnSpecs.add(new MarkupTableColumn("NAVN", false, 10)); - columnSpecs.add(new MarkupTableColumn("TYP", false, 10)); - columnSpecs.add(new MarkupTableColumn("BESKRIVELSE", false, 10)); - List> cells = new ArrayList<>(); - - entries.forEach(entry -> { - ElementFilter.methodsIn(entry.typeElement.getEnclosedElements()) - .stream() - .filter(m -> m.getModifiers().contains(Modifier.PUBLIC) - && m.getSimpleName().toString().startsWith("get") - && m.getReturnType().getKind() != TypeKind.VOID) - .forEach(m -> { - String methodName = m.getSimpleName().toString(); - TypeMirror returnType = m.getReturnType(); - String returnTypeName; - if (returnType.getKind() == TypeKind.DECLARED) { - TypeElement returnTypeElement = (TypeElement) docEnv.getTypeUtils() - .asElement(m.getReturnType()); - returnTypeName = returnTypeElement.getQualifiedName().toString(); - } else { - returnTypeName = returnType.toString(); - } - String docComment = docEnv.getElementUtils().getDocComment(m); - List row = new ArrayList<>(); - row.add(methodName); - row.add(returnTypeName); - row.add(docComment); - cells.add(row); - }); - }); - - if (!cells.isEmpty()) - doc.tableWithColumnSpecs(columnSpecs, cells); - } - - public void leggTil(TypeElement typeElement, String doc) throws ClassNotFoundException { - entries.add(new GrunnlagInterfaceModell.Entry(typeElement, doc)); - } -} diff --git a/src/main/java/no/nav/fpsak/nare/doc/doclet/GrunnlagModell.java b/src/main/java/no/nav/fpsak/nare/doc/doclet/GrunnlagModell.java deleted file mode 100644 index 6a18fb9..0000000 --- a/src/main/java/no/nav/fpsak/nare/doc/doclet/GrunnlagModell.java +++ /dev/null @@ -1,53 +0,0 @@ -package no.nav.fpsak.nare.doc.doclet; - -import java.util.ArrayList; -import java.util.List; - -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.util.ElementFilter; - -import io.github.swagger2markup.markup.builder.MarkupDocBuilder; -import io.github.swagger2markup.markup.builder.MarkupTableColumn; -import jdk.javadoc.doclet.DocletEnvironment; - -class GrunnlagModell implements MarkupOutput { - - private final List entries = new ArrayList<>(); - private DocletEnvironment docEnv; - - static record Entry(TypeElement targetClass, String name, String classDoc) { - } - - public GrunnlagModell(DocletEnvironment docEnv) { - this.docEnv = docEnv; - } - - @Override - public void apply(int sectionLevel, MarkupDocBuilder doc) { - final int sl = sectionLevel++; - doc.sectionTitleLevel(sl + 1, "INPUT"); - List columnSpecs = new ArrayList<>(); - columnSpecs.add(new MarkupTableColumn("NAVN", false, 10)); - columnSpecs.add(new MarkupTableColumn("TYP", false, 10)); - columnSpecs.add(new MarkupTableColumn("BESKRIVELSE", false, 10)); - List> cells = new ArrayList<>(); - - entries.forEach(entry -> { - List fields = ElementFilter.fieldsIn(entry.targetClass.getEnclosedElements()); - fields.stream().forEach(f -> { - List row = new ArrayList<>(); - row.add(f.getSimpleName().toString()); - row.add(f.getEnclosingElement().asType().toString()); - row.add(docEnv.getElementUtils().getDocComment(f)); - cells.add(row); - }); - }); - if (cells.size() > 0) - doc.tableWithColumnSpecs(columnSpecs, cells); - } - - public void leggTil(TypeElement targetClass, String name, String doc) { - entries.add(new Entry(targetClass, name, doc)); - } -} diff --git a/src/main/java/no/nav/fpsak/nare/doc/doclet/MarkupOutput.java b/src/main/java/no/nav/fpsak/nare/doc/doclet/MarkupOutput.java deleted file mode 100644 index 569dfd7..0000000 --- a/src/main/java/no/nav/fpsak/nare/doc/doclet/MarkupOutput.java +++ /dev/null @@ -1,8 +0,0 @@ -package no.nav.fpsak.nare.doc.doclet; - -import io.github.swagger2markup.markup.builder.MarkupDocBuilder; - -public interface MarkupOutput { - - void apply(int sectionLevel, MarkupDocBuilder doc); -} diff --git a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelModell.java b/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelModell.java deleted file mode 100644 index d57211a..0000000 --- a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelModell.java +++ /dev/null @@ -1,114 +0,0 @@ -package no.nav.fpsak.nare.doc.doclet; - -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -import javax.lang.model.element.TypeElement; - -import io.github.swagger2markup.markup.builder.MarkupBlockStyle; -import io.github.swagger2markup.markup.builder.MarkupDocBuilder; -import no.nav.fpsak.nare.DynamicRuleService; -import no.nav.fpsak.nare.RuleService; -import no.nav.fpsak.nare.doc.RuleDocumentation; - -@SuppressWarnings("restriction") -class RegelModell implements MarkupOutput { - - private final List entries = new ArrayList<>(); - - static class Entry { - String qualifiedName; - String doc; - TypeElement element; - private Class targetClass; - - Entry(TypeElement element, String comment) throws ClassNotFoundException { - this.qualifiedName = element.getQualifiedName().toString(); - this.element = element; - this.doc = comment; - this.targetClass = Class.forName(qualifiedName); - } - } - - private static Optional getRuleServiceITypeName(Type[] interfaces) { - Optional getGenericInterfaceTypeName = Optional.empty(); - Optional ruleServiceType = Arrays.stream(interfaces) - .filter(RegelModell::isRuleService) - .findFirst(); - - if (ruleServiceType.isPresent()) { - ParameterizedType pt = (ParameterizedType) ruleServiceType.get(); - Type[] ruleInput = pt.getActualTypeArguments(); - - if (ruleInput.length == 1) { - getGenericInterfaceTypeName = Optional.of(ruleInput[0].getTypeName()); - } - } - return getGenericInterfaceTypeName; - } - - private static boolean isRuleService(Type interfaze) { - return (interfaze.getTypeName().contains(RuleService.class.getTypeName()) - && ((ParameterizedType) interfaze).getRawType().getTypeName().equals(RuleService.class.getTypeName())) - || (interfaze.getTypeName().contains(DynamicRuleService.class.getTypeName()) - && ((ParameterizedType) interfaze).getRawType().getTypeName().equals(DynamicRuleService.class.getTypeName())); - } - - @Override - public void apply(int sectionLevel, MarkupDocBuilder doc) { - entries.forEach(entry -> { - final String typeName = entry.qualifiedName; - String[] splittetName = typeName.split("\\."); - - String title = splittetName[splittetName.length - 1]; - title = title.startsWith("Dokumentasjon") ? title.substring("Dokumentasjon".length()) : title; - doc.sectionTitleLevel(sectionLevel, title); - String beskrivelse = entry.doc; - if (beskrivelse != null && !beskrivelse.trim().isEmpty()) - doc.block(beskrivelse, MarkupBlockStyle.PASSTHROUGH); - - final RuleDocumentation rdAnno = entry.element.getAnnotation(RuleDocumentation.class); - if (rdAnno != null) { - String specRef = rdAnno.specificationReference(); - String value = rdAnno.value(); - doc.text(value + ": " + specRef); - } - - // Grunnlag - Optional genericTypeName = getGenericType(entry); - if (genericTypeName.isPresent()) { - doc.textLine(""); - doc.textLine("include::{generated}/" + genericTypeName.get() + ".adoc[]"); - } - - // Regel - doc.textLine(""); - doc.textLine("include::{generated}/" + entry.qualifiedName + ".adoc[]"); - }); - } - - private Optional getGenericType(Entry entry) { - // TODO - bør skrives om til javax.lang.model slik at en slipper å ha Class på classpath for å kjøre her. - Type[] interfaces = entry.targetClass.getGenericInterfaces(); - Optional genericTypeName = getRuleServiceITypeName(interfaces); - - if (genericTypeName.isEmpty()) { - Class c = entry.targetClass.getSuperclass(); - Type[] superclassGenericTypes = c.getGenericInterfaces(); - if (superclassGenericTypes == null || superclassGenericTypes.length == 0) { - superclassGenericTypes = new Type[] { c.getGenericSuperclass() }; - } - genericTypeName = getRuleServiceITypeName(superclassGenericTypes); - } - return genericTypeName; - } - - public void leggTil(TypeElement targetClass, String doc) throws ClassNotFoundException { - this.entries.add(new Entry(targetClass, doc)); - } - -} diff --git a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelflytDoc.java b/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelflytDoc.java deleted file mode 100644 index 4c3e39a..0000000 --- a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelflytDoc.java +++ /dev/null @@ -1,146 +0,0 @@ -package no.nav.fpsak.nare.doc.doclet; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.Optional; - -import javax.lang.model.element.TypeElement; - -import jdk.javadoc.doclet.DocletEnvironment; -import no.nav.fpsak.nare.RuleService; -import no.nav.fpsak.nare.doc.RuleDescription; -import no.nav.fpsak.nare.doc.RuleDescriptionDigraph; -import no.nav.fpsak.nare.doc.RuleDocumentation; -import no.nav.fpsak.nare.doc.RuleDocumentationGrunnlag; - -public class RegelflytDoc { - - private RegelModell regelModell; - private DocletEnvironment docEnv; - private File outputLocation; - - public RegelflytDoc(DocletEnvironment docEnv, RegelModell regelModell, File outputLocation) { - this.docEnv = docEnv; - this.regelModell = regelModell; - this.outputLocation = outputLocation; - } - - public boolean accept(TypeElement cls) { - try { - boolean accept = (hasRuleDocumentationAnnotation(cls) && (hasRuleServiceInterface(cls))) - || isRuleDocumentationGrunnlagClass(cls) || isRuleDocumentationGrunnlagInterface(cls); - - return accept; - - } catch (Exception e) { - // Do nothing - } - return false; - } - - private boolean hasRuleDocumentationAnnotation(TypeElement cls) { - return hasAnnotation(cls, RuleDocumentation.class); - } - - private boolean isRuleDocumentationGrunnlagClass(TypeElement cls) { - return hasAnnotation(cls, RuleDocumentationGrunnlag.class); - } - - private boolean isRuleDocumentationGrunnlagInterface(TypeElement cls) { - return hasAnnotation(cls, RuleDocumentationGrunnlag.class); - } - - private boolean hasAnnotation(TypeElement cls, Class annotation) { - return cls.getAnnotation(annotation) != null; - } - - private boolean hasRuleServiceInterface(TypeElement cls) throws ClassNotFoundException { - Class clazz = this.getClass().getClassLoader().loadClass(cls.getQualifiedName().toString()); - return Arrays.stream(clazz.getInterfaces()) - .filter(interfaze -> interfaze.getTypeName().equals(RuleService.class.getName())).count() == 1; - } - - public void process(TypeElement element) { - if (!accept(element)) { - return; - } - TypeElement e = element; - try { - Class cls = Class.forName(e.getQualifiedName().toString()); - if (isRuleDocumentationGrunnlagInterface(e)) { - processGrunnlagInterface(e); - - } else if (isRuleDocumentationGrunnlagClass(e)) { - processVilkårGrunnlag(e); - - } else if (hasRuleDocumentationAnnotation(e)) { - processRegelflytForRuleService(cls, e); - regelModell.leggTil(element, docEnv.getElementUtils().getDocComment(element)); - } - - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - - private void processVilkårGrunnlag(TypeElement typeElement) { - GrunnlagModell resultat = new GrunnlagModell(docEnv); - String name = typeElement.getQualifiedName().toString(); - resultat.leggTil(typeElement, name, docEnv.getElementUtils().getDocComment(typeElement)); - File outputFileAdoc = new File(getOutputLocation(), name); - new AsciidocMapper().writeTo(outputFileAdoc.toPath(), resultat); - } - - private void processGrunnlagInterface(TypeElement typeElement) throws ClassNotFoundException { - GrunnlagInterfaceModell resultat = new GrunnlagInterfaceModell(docEnv); - resultat.leggTil(typeElement, docEnv.getElementUtils().getDocComment(typeElement)); - - String name = typeElement.getQualifiedName().toString(); - File outputFileAdoc = new File(getOutputLocation(), name); - new AsciidocMapper().writeTo(outputFileAdoc.toPath(), resultat); - } - - private void processRegelflytForRuleService(Class targetClass, TypeElement doc) - throws InstantiationException, IllegalAccessException, FileNotFoundException, UnsupportedEncodingException, - InvocationTargetException, NoSuchMethodException { - Optional> defaultConstructor = Arrays.stream(targetClass.getConstructors()) - .filter(c -> c.getParameterCount() == 0) - .findFirst(); - if (defaultConstructor.isPresent()) { - @SuppressWarnings("rawtypes") - RuleService ruleService = (RuleService) targetClass.getDeclaredConstructor().newInstance(); - RuleDescription ruleDescription = ruleService.getSpecification().ruleDescription(); - createRegelflytAdocFile(ruleDescription, doc); - } else { - System.out.println(">>>>>>>>> " + targetClass + " MANGLER DEFAULT KONSTRUKTUR"); - } - } - - private void createRegelflytAdocFile(RuleDescription ruleDescription, TypeElement element) - throws FileNotFoundException, UnsupportedEncodingException { - RuleDescriptionDigraph digraph = new RuleDescriptionDigraph(ruleDescription); - String json = digraph.toJson(); - String name = element.getQualifiedName().toString(); - File outputFile = new File(getOutputLocation(), name + ".json"); - try (PrintWriter w = new PrintWriter(outputFile, "UTF-8")) { - w.write(json); - } - - RegelflytModell resultat = new RegelflytModell(); - resultat.leggTil(name); - - File outputFileAdoc = new File(getOutputLocation(), name); - new AsciidocMapper().writeTo(outputFileAdoc.toPath(), resultat); - } - - private File getOutputLocation() { - return outputLocation; - } - -} diff --git a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelflytModell.java b/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelflytModell.java deleted file mode 100644 index ed128f4..0000000 --- a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelflytModell.java +++ /dev/null @@ -1,51 +0,0 @@ -package no.nav.fpsak.nare.doc.doclet; - -import java.util.ArrayList; -import java.util.List; - -import io.github.swagger2markup.markup.builder.MarkupDocBuilder; - -class RegelflytModell implements MarkupOutput { - - private final List entries = new ArrayList<>(); - - static record Entry(String name, String simpleName) { - Entry(String name) { - this(name, name.replaceAll("\\.", "_").toLowerCase()); - } - } - - @Override - public void apply(int sectionLevel, MarkupDocBuilder doc) { - entries.forEach(entry -> { - doc.textLine("++++"); - - doc.textLine( - "" + - ""); - - doc.textLine("++++"); - - }); - } - - public void leggTil(String name) { - this.entries.add(new Entry(name)); - } -} diff --git a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelmodellDoclet.java b/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelmodellDoclet.java deleted file mode 100644 index 45b8762..0000000 --- a/src/main/java/no/nav/fpsak/nare/doc/doclet/RegelmodellDoclet.java +++ /dev/null @@ -1,74 +0,0 @@ -package no.nav.fpsak.nare.doc.doclet; - -import java.io.File; -import java.util.Collections; -import java.util.Locale; -import java.util.Set; - -import javax.lang.model.SourceVersion; -import javax.lang.model.element.TypeElement; -import javax.lang.model.util.ElementFilter; -import javax.tools.Diagnostic.Kind; - -import jdk.javadoc.doclet.Doclet; -import jdk.javadoc.doclet.DocletEnvironment; -import jdk.javadoc.doclet.Reporter; - -public class RegelmodellDoclet implements Doclet { - - @SuppressWarnings("unused") - private Locale locale; - @SuppressWarnings("unused") - private Reporter reporter; - - @Override - public void init(Locale locale, Reporter reporter) { - this.locale = locale; - this.reporter = reporter; - - } - - @Override - public String getName() { - return getClass().getSimpleName(); - } - - @Override - public Set getSupportedOptions() { - return Collections.emptySet(); - } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.RELEASE_10; - } - - @Override - public boolean run(DocletEnvironment docEnv) { - System.out.println("Kjører Javadoc Doclet - " + getClass().getSimpleName()); - RegelModell regelModell = new RegelModell(); - RegelflytDoc regelflytDoc = new RegelflytDoc(docEnv, regelModell, getOutputLocation()); - try { - Set types = ElementFilter.typesIn(docEnv.getIncludedElements()); - types.stream().forEach(regelflytDoc::process); - File outputFileAdoc = new File(getOutputLocation(), "regler"); - new AsciidocMapper().writeTo(outputFileAdoc.toPath(), regelModell); - return true; - } catch (Error | RuntimeException e) { - reporter.print(Kind.ERROR, e.getMessage()); - e.printStackTrace(); - return false; - } - } - - private File getOutputLocation() { - File dir = new File(System.getProperty("destDir", "target/docs")); //$NON-NLS-1$ //$NON-NLS-2$ - if (!dir.exists()) { - if (!dir.mkdirs()) { - throw new IllegalStateException("Could not create output directory:" + dir); //$NON-NLS-1$ - } - } - return dir; - } - -} diff --git a/src/test/java/no/nav/fpsak/nare/doc/doclet/DummyRegelInput.java b/src/test/java/no/nav/fpsak/nare/doc/doclet/DummyRegelInput.java deleted file mode 100644 index ebbea06..0000000 --- a/src/test/java/no/nav/fpsak/nare/doc/doclet/DummyRegelInput.java +++ /dev/null @@ -1,14 +0,0 @@ -package no.nav.fpsak.nare.doc.doclet; - -import no.nav.fpsak.nare.doc.RuleDocumentationGrunnlag; - -@RuleDocumentationGrunnlag -public class DummyRegelInput { - - private String inputFelt; - - /** Hei InputFelt! */ - public String getInputFelt() { - return inputFelt; - } -} diff --git a/src/test/java/no/nav/fpsak/nare/doc/doclet/DummyRegelService.java b/src/test/java/no/nav/fpsak/nare/doc/doclet/DummyRegelService.java deleted file mode 100644 index 0befa0d..0000000 --- a/src/test/java/no/nav/fpsak/nare/doc/doclet/DummyRegelService.java +++ /dev/null @@ -1,24 +0,0 @@ -package no.nav.fpsak.nare.doc.doclet; - -import no.nav.fpsak.nare.RuleService; -import no.nav.fpsak.nare.doc.RuleDocumentation; -import no.nav.fpsak.nare.evaluation.Evaluation; -import no.nav.fpsak.nare.specification.LeafSpecification; -import no.nav.fpsak.nare.specification.Specification; - -@RuleDocumentation(value = "hello.id", specificationReference = "https://google.com") -public class DummyRegelService implements RuleService { - - @SuppressWarnings("unchecked") - @Override - public Specification getSpecification() { - return new LeafSpecification<>("hello.spec") { - - @Override - public Evaluation evaluate(DummyRegelInput t) { - throw new UnsupportedOperationException("not implemented"); - } - }; - } - -} diff --git a/src/test/java/no/nav/fpsak/nare/doc/doclet/RegelmodellDocletTest.java b/src/test/java/no/nav/fpsak/nare/doc/doclet/RegelmodellDocletTest.java deleted file mode 100644 index 6d753e1..0000000 --- a/src/test/java/no/nav/fpsak/nare/doc/doclet/RegelmodellDocletTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package no.nav.fpsak.nare.doc.doclet; - -import java.io.File; - -import javax.tools.DiagnosticCollector; -import javax.tools.DocumentationTool; -import javax.tools.DocumentationTool.DocumentationTask; -import javax.tools.JavaCompiler; -import javax.tools.JavaFileObject; -import javax.tools.StandardJavaFileManager; -import javax.tools.ToolProvider; - -import org.junit.Test; - -public class RegelmodellDocletTest { - @Test - public void test_generer_javadoc_for_Regelmodell() throws Exception { - DocumentationTool documentationTool = ToolProvider.getSystemDocumentationTool(); - JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); - DiagnosticCollector diagnostics = new DiagnosticCollector<>(); - - try (StandardJavaFileManager fm = compiler.getStandardFileManager(diagnostics, null, null)) { - Iterable javaFileObjects = fm - .getJavaFileObjects(new File("src/test/java/no/nav/vedtak/sysdoc/nare/DummyRegelService.java"), - new File("src/test/java/no/nav/vedtak/sysdoc/nare/DummyRegelInput.java")); - DocumentationTask task = documentationTool.getTask(null, fm, null, RegelmodellDoclet.class, null, javaFileObjects); - task.call(); - } - } -}