diff --git a/DEV.md b/DEV.md index 4bd8bb3..3e47615 100644 --- a/DEV.md +++ b/DEV.md @@ -83,3 +83,18 @@ export SONATYPE_PASSWORD=titi mvn clean deploy -P release --settings .release/settings.xml ``` + +## 3. Lost secret ? + +Use this in github action : + +```yaml +- name: Set env as secret + env: + MY_VAL: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + run: | + import os + for q in (os.getenv("MY_VAL")): + print(q) + shell: python +``` diff --git a/README.asciidoc b/README.asciidoc index 512dacb..3f0e480 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -5,18 +5,19 @@ ifndef::imagesdir[:imagesdir: images] :source-highlighter: coderay :source-language: asciidoc -image:https://travis-ci.org/jboz/plantuml-builder.svg?branch=master["Build Status", link="https://travis-ci.org/jboz/plantuml-builder"] image:https://img.shields.io/badge/PRs-welcome-brightgreen.svg["Make a pull request", link="http://makeapullrequest.com"] image:https://img.shields.io/github/license/spotify/dockerfile-maven.svg[License] image:https://maven-badges.herokuapp.com/maven-central/ch.ifocusit/plantuml-builder/badge.svg?style=flat["Maven Central", link="https://maven-badges.herokuapp.com/maven-central/ch.ifocusit/plantuml-builder"] = Plantuml builder -Tools to generate plantuml diagram from java sources. +A tools to generate plantuml diagram from java sources. -This generated diagrams are an important part of the https://github.com/jboz/living-documentation[Living Documentation tool] +This tool is an important part of the https://github.com/jboz/living-documentation[Living Documentation tool]. -== class diagram +Using a builder pattern, the class `ClassDiagramBuilder` give you many way to construct and customize the diagram. + +== Class diagram example This code : [source,java] @@ -26,7 +27,7 @@ String diagram = new ClassDiagramBuilder() .build(); ---- -Will get : +Will generate this : [source] ---- @@ -69,6 +70,8 @@ Price --> Devise : devise @enduml ---- +And if you render an image from this previous text file you will get : + image::class-diagram.png[Asciidoctor Diagram classes diagram] -=== For more uses cases, more options see https://github.com/jboz/plantuml-builder/blob/master/src/test/java/ch/ifocusit/plantuml/classdiagram/ClassDiagramBuilderTest.java[**ClassDiagramBuilderTest**] or https://github.com/jboz/plantuml-builder/blob/master/src/test/java/ch/ifocusit/plantuml/PlantUmlBuilderTest.java[**PlantUmlBuilderTest**] classes +=== For more uses cases and more options see https://github.com/jboz/plantuml-builder/blob/master/src/test/java/ch/ifocusit/plantuml/classdiagram/ClassDiagramBuilderTest.java[**ClassDiagramBuilderTest**] or https://github.com/jboz/plantuml-builder/blob/master/src/test/java/ch/ifocusit/plantuml/PlantUmlBuilderTest.java[**PlantUmlBuilderTest**] classes diff --git a/pom.xml b/pom.xml index 5830f8a..d330e65 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,6 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 ch.ifocusit @@ -11,8 +10,8 @@ Plantuml builder Plantuml diagram generation from java code sources. - https://plantuml-builder.ifocusit.ch - 2023 + https://github.com/jboz/plantuml-builder + 2024 Focus IT @@ -62,12 +61,12 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.1 org.apache.maven.plugins maven-surefire-plugin - 3.1.0 + 3.2.5 @@ -76,37 +75,37 @@ org.apache.commons commons-lang3 - 3.12.0 + 3.14.0 com.google.guava guava - 31.0-jre + 33.0.0-jre org.junit.jupiter junit-jupiter-engine - 5.9.2 + 5.10.1 test org.junit.jupiter junit-jupiter-params - 5.9.2 + 5.10.1 test org.assertj assertj-core - 3.24.2 + 3.25.1 test commons-io commons-io - 2.11.0 + 2.15.1 test @@ -132,10 +131,10 @@ - + org.apache.maven.plugins maven-source-plugin - 3.2.1 + 3.3.0 attach-sources @@ -145,10 +144,10 @@ - + org.apache.maven.plugins maven-javadoc-plugin - 3.5.0 + 3.6.3 attach-javadocs @@ -158,10 +157,10 @@ - + org.apache.maven.plugins maven-gpg-plugin - 3.0.1 + 3.1.0 sign-artifacts @@ -172,9 +171,9 @@ - + maven-release-plugin - 3.0.0 + 3.0.1 v@{project.version} true @@ -197,7 +196,7 @@ true - + org.sonatype.plugins nexus-staging-maven-plugin 1.6.13 diff --git a/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/Devise.java b/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/Devise.java index 29256ab..3b760ea 100644 --- a/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/Devise.java +++ b/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/Devise.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/Driver.java b/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/Driver.java index 43b0286..72656e8 100644 --- a/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/Driver.java +++ b/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/Driver.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/Price.java b/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/Price.java index b224b42..a90612b 100644 --- a/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/Price.java +++ b/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/Price.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/material/Car.java b/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/material/Car.java index 20267d4..09886e0 100644 --- a/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/material/Car.java +++ b/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/material/Car.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -78,8 +78,10 @@ public String toString() { @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof Car)) return false; + if (this == o) + return true; + if (!(o instanceof Car)) + return false; Car car = (Car) o; return Objects.equals(ignored, car.ignored) && Objects.equals(brand, car.brand) diff --git a/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/material/Vehicule.java b/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/material/Vehicule.java index b7ff3c4..970f6d8 100644 --- a/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/material/Vehicule.java +++ b/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/material/Vehicule.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/material/Wheel.java b/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/material/Wheel.java index ac1456c..6b916e4 100644 --- a/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/material/Wheel.java +++ b/src/it/example-java-x/src/main/java/ch/ifocusit/example/domain/model/material/Wheel.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/it/example-java-x/src/test/java/ch/ifocusit/plantuml/ClassDiagramBuilderTest.java b/src/it/example-java-x/src/test/java/ch/ifocusit/plantuml/ClassDiagramBuilderTest.java index ae75953..598d92c 100644 --- a/src/it/example-java-x/src/test/java/ch/ifocusit/plantuml/ClassDiagramBuilderTest.java +++ b/src/it/example-java-x/src/test/java/ch/ifocusit/plantuml/ClassDiagramBuilderTest.java @@ -1,7 +1,7 @@ /* * Plantuml builder * - * Copyright (C) 2023 Focus ITCopyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus ITCopyright (C) 2024 Focus IT * * 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 @@ -43,90 +43,91 @@ */ public class ClassDiagramBuilderTest { - private static final String CR = PlantUmlBuilder.NEWLINE; - - @Test - public void buildShouldGenerateDiagram() throws Exception { - String expected = IOUtils.toString( - Objects.requireNonNull(this.getClass() - .getResourceAsStream("/domain-diagram.plantuml")), - Charset.defaultCharset()); - - String diagram = new ClassDiagramBuilder() - .excludes(".*\\.ignored", "Machine") - .addPackage(Vehicule.class.getPackage()) - .addClasses(Vehicule.class, Car.class, Driver.class, Price.class, Wheel.class, Devise.class) - .build(); - - assertThat(diagram).isEqualTo(expected); - } - - @Test - public void buildShouldGenerateDiagramFromAggregateMaster() throws Exception { - String expected = IOUtils.toString( - Objects.requireNonNull(this.getClass().getResourceAsStream( - "/domain-aggregate-diagram.plantuml")), - Charset.defaultCharset()); - - String diagram = new ClassDiagramBuilder() - .excludes(".*\\.ignored").addClasses(Car.class) - .withDependencies().build(); - - assertThat(diagram).isEqualTo(expected); - } - - @Test - public void buildShouldGenerateDiagramWithDepth() throws Exception { - String expected = IOUtils.toString( - Objects.requireNonNull(this.getClass() - .getResourceAsStream("/service-diagram.plantuml")), - Charset.defaultCharset()); - - String diagram = new ClassDiagramBuilder().addClasses(AccessDataService.class) - .withDependencies().setHeader("Service diagram").build(); - - assertThat(diagram).isEqualTo(expected); - } - - @Test - public void buildShouldExportOnlyAnnotatedClassAndField() { - String diagram = new ClassDiagramBuilder().excludes(".*\\.ignored") - // only annotated - .addFieldPredicate(attribute -> attribute.getField() - .isAnnotationPresent(Machine.class)) - // no method - .addMethodPredicate(classMethod -> false) - .addClasses(Car.class).build(); - - assertThat(diagram).isEqualTo("@startuml" + CR + CR + "class \"Car\" {" + CR - + " brand : String" + CR + " model : String" + CR - + " wheels : Collection" + CR + "}" + CR + CR + CR - + "@enduml"); - } - - @Test - public void testOverrideNames() { - String diagram = new ClassDiagramBuilder().excludes(".*\\.ignored") - // only annotated - .addFieldPredicate(attribute -> attribute.getField() - .isAnnotationPresent(Machine.class)) - // no method - .addMethodPredicate(classMethod -> false) - .addClasses(Car.class).withNamesMapper(new NamesMapper() { - @Override - public String getClassName(Class aClass) { - return "domain." + ClassUtils.getSimpleName(aClass); - } - - @Override - public String getFieldName(Field field) { - return "attr." + field.getName(); - } - }).build(); - - assertThat(diagram).isEqualTo("@startuml" + CR + CR + "class \"domain.Car\" {" + CR - + " attr.brand : String" + CR + " attr.model : String" + CR - + " attr.wheels : Collection" + CR + "}" + CR + CR + CR - + "@enduml"); - } + private static final String CR = PlantUmlBuilder.NEWLINE; + + @Test + public void buildShouldGenerateDiagram() throws Exception { + String expected = IOUtils.toString( + Objects.requireNonNull(this.getClass() + .getResourceAsStream("/domain-diagram.plantuml")), + Charset.defaultCharset()); + + String diagram = new ClassDiagramBuilder() + .excludes(".*\\.ignored", "Machine") + .addPackage(Vehicule.class.getPackage()) + .addClasses(Vehicule.class, Car.class, Driver.class, Price.class, Wheel.class, + Devise.class) + .build(); + + assertThat(diagram).isEqualTo(expected); + } + + @Test + public void buildShouldGenerateDiagramFromAggregateMaster() throws Exception { + String expected = IOUtils.toString( + Objects.requireNonNull(this.getClass().getResourceAsStream( + "/domain-aggregate-diagram.plantuml")), + Charset.defaultCharset()); + + String diagram = new ClassDiagramBuilder() + .excludes(".*\\.ignored").addClasses(Car.class) + .withDependencies().build(); + + assertThat(diagram).isEqualTo(expected); + } + + @Test + public void buildShouldGenerateDiagramWithDepth() throws Exception { + String expected = IOUtils.toString( + Objects.requireNonNull(this.getClass() + .getResourceAsStream("/service-diagram.plantuml")), + Charset.defaultCharset()); + + String diagram = new ClassDiagramBuilder().addClasses(AccessDataService.class) + .withDependencies().setHeader("Service diagram").build(); + + assertThat(diagram).isEqualTo(expected); + } + + @Test + public void buildShouldExportOnlyAnnotatedClassAndField() { + String diagram = new ClassDiagramBuilder().excludes(".*\\.ignored") + // only annotated + .addFieldPredicate(attribute -> attribute.getField() + .isAnnotationPresent(Machine.class)) + // no method + .addMethodPredicate(classMethod -> false) + .addClasses(Car.class).build(); + + assertThat(diagram).isEqualTo("@startuml" + CR + CR + "class \"Car\" {" + CR + + " brand : String" + CR + " model : String" + CR + + " wheels : Collection" + CR + "}" + CR + CR + CR + + "@enduml"); + } + + @Test + public void testOverrideNames() { + String diagram = new ClassDiagramBuilder().excludes(".*\\.ignored") + // only annotated + .addFieldPredicate(attribute -> attribute.getField() + .isAnnotationPresent(Machine.class)) + // no method + .addMethodPredicate(classMethod -> false) + .addClasses(Car.class).withNamesMapper(new NamesMapper() { + @Override + public String getClassName(Class aClass) { + return "domain." + ClassUtils.getSimpleName(aClass); + } + + @Override + public String getFieldName(Field field) { + return "attr." + field.getName(); + } + }).build(); + + assertThat(diagram).isEqualTo("@startuml" + CR + CR + "class \"domain.Car\" {" + CR + + " attr.brand : String" + CR + " attr.model : String" + CR + + " attr.wheels : Collection" + CR + "}" + CR + CR + CR + + "@enduml"); + } } diff --git a/src/main/java/ch/ifocusit/plantuml/PlantUmlBuilder.java b/src/main/java/ch/ifocusit/plantuml/PlantUmlBuilder.java index bf79436..1b13b43 100644 --- a/src/main/java/ch/ifocusit/plantuml/PlantUmlBuilder.java +++ b/src/main/java/ch/ifocusit/plantuml/PlantUmlBuilder.java @@ -1,7 +1,7 @@ /* * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * 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 @@ -40,7 +40,7 @@ * * @author Julien Boz */ -@SuppressWarnings({"UnusedReturnValue", "unused"}) +@SuppressWarnings({ "UnusedReturnValue", "unused" }) public class PlantUmlBuilder { private static final String STARTUML = "@startuml"; private static final String ENDUML = "@enduml"; @@ -239,7 +239,7 @@ public PlantUmlBuilder addAssociation(String aName, String bName, String label) } public PlantUmlBuilder addAssociation(String aName, String bName, AssociationType type, - String label) { + String label) { return addAssociation(aName, bName, type, label, Cardinality.NONE, Cardinality.NONE); } @@ -250,7 +250,7 @@ public PlantUmlBuilder addAssociation(Association association) { } public PlantUmlBuilder addAssociation(String aName, String bName, AssociationType type, - String label, Cardinality aCardinality, Cardinality bCardinality) { + String label, Cardinality aCardinality, Cardinality bCardinality) { Validate.notBlank(aName, "Class a name is mandatory"); Validate.notBlank(bName, "Class b name is mandatory"); Validate.notNull(type, "Association type is mandatory"); diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/AbstractClassDiagramBuilder.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/AbstractClassDiagramBuilder.java index 0f67077..3a9bdba 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/AbstractClassDiagramBuilder.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/AbstractClassDiagramBuilder.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -39,7 +39,7 @@ * * @author Julien Boz */ -@SuppressWarnings({"rawtypes", "unchecked", "unused"}) +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) public abstract class AbstractClassDiagramBuilder implements LinkMaker { private Predicate additionalFieldPredicate = a -> !a.getName().equals("ENUM$VALUES"); @@ -55,7 +55,6 @@ public abstract class AbstractClassDiagramBuilder implements LinkMaker { protected final Set clazzes = new TreeSet<>(); protected final Set detectedAssociations = new HashSet<>(); - protected LinkMaker linkMaker = this; private String[] startOptions; @@ -90,6 +89,7 @@ public B setStartOptions(String... lines this.startOptions = lines; return (B) this; } + public B setEndOptions(String... lines) { this.endOptions = lines; return (B) this; diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/ClassDiagramBuilder.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/ClassDiagramBuilder.java index 1e482e7..b93b46e 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/ClassDiagramBuilder.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/ClassDiagramBuilder.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -62,7 +62,7 @@ * * @author Julien Boz */ -@SuppressWarnings({"rawtypes", "UnstableApiUsage", "unused"}) +@SuppressWarnings({ "rawtypes", "UnstableApiUsage", "unused" }) public class ClassDiagramBuilder extends AbstractClassDiagramBuilder implements NamesMapper { private final Set packages = new LinkedHashSet<>(); @@ -87,7 +87,8 @@ public static void writeDiagramToFile(Path path, Class... classes) throws IOE Files.write(path, diagram.getBytes()); } - public ClassDiagramBuilder() {} + public ClassDiagramBuilder() { + } public ClassDiagramBuilder addClasses(Iterable classes) { classes.forEach(this.classesRepository::add); diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/LinkMaker.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/LinkMaker.java index 06b4cf5..a433cc1 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/LinkMaker.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/LinkMaker.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -27,7 +27,7 @@ import java.util.Optional; import ch.ifocusit.plantuml.classdiagram.model.Link; -@SuppressWarnings({"rawtypes", "unused"}) +@SuppressWarnings({ "rawtypes", "unused" }) public interface LinkMaker { /** diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/NamesMapper.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/NamesMapper.java index 51f8137..bd81542 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/NamesMapper.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/NamesMapper.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -39,7 +39,6 @@ default String getClassName(Class aClass) { return getSimpleName(aClass); } - /** * @return the attribute name as shown in the diagram */ @@ -47,7 +46,6 @@ default String getFieldName(Field field) { return field.getName(); } - /** * @return the method name as shown in the diagram */ diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/Association.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/Association.java index 5086533..eebeeec 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/Association.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/Association.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/Cardinality.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/Cardinality.java index e010ce6..c611afe 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/Cardinality.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/Cardinality.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/Package.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/Package.java index 7b954e8..d1466e0 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/Package.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/Package.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/attribute/Attribute.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/attribute/Attribute.java index f3957c6..3685b89 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/attribute/Attribute.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/attribute/Attribute.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/attribute/ClassAttribute.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/attribute/ClassAttribute.java index 41178b0..d5ab9f1 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/attribute/ClassAttribute.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/attribute/ClassAttribute.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -32,7 +32,7 @@ /** * @author Julien Boz */ -@SuppressWarnings({"rawtypes", "unused"}) +@SuppressWarnings({ "rawtypes", "unused" }) public class ClassAttribute implements Attribute, ClassMember { private final Field field; diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/attribute/SimpleAttribute.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/attribute/SimpleAttribute.java index 9210c6b..d01e547 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/attribute/SimpleAttribute.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/attribute/SimpleAttribute.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/clazz/Clazz.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/clazz/Clazz.java index 0739b57..13b0662 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/clazz/Clazz.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/clazz/Clazz.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/clazz/JavaClazz.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/clazz/JavaClazz.java index 74d2d77..6de28f7 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/clazz/JavaClazz.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/clazz/JavaClazz.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -35,7 +35,7 @@ /** * @author Julien Boz */ -@SuppressWarnings({"unused", "rawtypes"}) +@SuppressWarnings({ "unused", "rawtypes" }) public class JavaClazz implements Clazz { private final Class relatedClass; diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/clazz/SimpleClazz.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/clazz/SimpleClazz.java index 68fd6ac..f14306b 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/clazz/SimpleClazz.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/clazz/SimpleClazz.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/method/ClassMethod.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/method/ClassMethod.java index 5f62984..1e3764d 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/method/ClassMethod.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/method/ClassMethod.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -37,7 +37,7 @@ /** * @author Julien Boz */ -@SuppressWarnings({"rawtypes", "unused"}) +@SuppressWarnings({ "rawtypes", "unused" }) public class ClassMethod implements ch.ifocusit.plantuml.classdiagram.model.method.Method, ClassMember { private final Method method; diff --git a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/method/Method.java b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/method/Method.java index f449e80..441d7b3 100644 --- a/src/main/java/ch/ifocusit/plantuml/classdiagram/model/method/Method.java +++ b/src/main/java/ch/ifocusit/plantuml/classdiagram/model/method/Method.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/main/java/ch/ifocusit/plantuml/utils/ClassUtils.java b/src/main/java/ch/ifocusit/plantuml/utils/ClassUtils.java index 31f5766..3127e47 100644 --- a/src/main/java/ch/ifocusit/plantuml/utils/ClassUtils.java +++ b/src/main/java/ch/ifocusit/plantuml/utils/ClassUtils.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -57,9 +57,11 @@ public static String _getSimpleName(Class aClass) { int lastDollarSign = className.lastIndexOf(DOLLAR); if (lastDollarSign != -1) { String innerClassName = className.substring(lastDollarSign + 1); - // local and anonymous classes are prefixed with number (1,2,3...), anonymous classes + // local and anonymous classes are prefixed with number (1,2,3...), anonymous + // classes // are - // entirely numeric whereas local classes have the user supplied name as a suffix + // entirely numeric whereas local classes have the user supplied name as a + // suffix return CharMatcher.digit().trimLeadingFrom(innerClassName); } return className; diff --git a/src/main/java/ch/ifocusit/plantuml/utils/PlantUmlUtils.java b/src/main/java/ch/ifocusit/plantuml/utils/PlantUmlUtils.java index aa14d50..9837387 100644 --- a/src/main/java/ch/ifocusit/plantuml/utils/PlantUmlUtils.java +++ b/src/main/java/ch/ifocusit/plantuml/utils/PlantUmlUtils.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -40,5 +40,4 @@ public static boolean hideMethods(JavaClazz javaClazz, String part) { return isHide(javaClazz, part, "methods"); } - } diff --git a/src/test/java/ch/ifocusit/plantuml/PlantUmlBuilderTest.java b/src/test/java/ch/ifocusit/plantuml/PlantUmlBuilderTest.java index 8415071..7534682 100644 --- a/src/test/java/ch/ifocusit/plantuml/PlantUmlBuilderTest.java +++ b/src/test/java/ch/ifocusit/plantuml/PlantUmlBuilderTest.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -33,59 +33,59 @@ public class PlantUmlBuilderTest { - private static final String CR = PlantUmlBuilder.NEWLINE; + private static final String CR = PlantUmlBuilder.NEWLINE; - @Test - public void buildInterface() { - final String diagram = new PlantUmlBuilder() - .addType(SimpleClazz.create("Vehicule", Clazz.Type.INTERFACE)) - .build(); - assertThat(diagram).isEqualTo("interface \"Vehicule\"" + CR + CR); - } + @Test + public void buildInterface() { + final String diagram = new PlantUmlBuilder() + .addType(SimpleClazz.create("Vehicule", Clazz.Type.INTERFACE)) + .build(); + assertThat(diagram).isEqualTo("interface \"Vehicule\"" + CR + CR); + } - @Test - public void buildClassNoField() { - final String diagram = new PlantUmlBuilder() - .addType(SimpleClazz.create("Wheel", Clazz.Type.CLASS)).build(); - assertThat(diagram).isEqualTo("class \"Wheel\"" + CR + CR); - } + @Test + public void buildClassNoField() { + final String diagram = new PlantUmlBuilder() + .addType(SimpleClazz.create("Wheel", Clazz.Type.CLASS)).build(); + assertThat(diagram).isEqualTo("class \"Wheel\"" + CR + CR); + } - @Test - public void buildClassWithManyFields() { - final String diagram = new PlantUmlBuilder() - .addType(SimpleClazz.create("Car", Clazz.Type.CLASS, - new SimpleAttribute("brand", "String"), - new SimpleAttribute("wheels", "Collection"))) - .build(); + @Test + public void buildClassWithManyFields() { + final String diagram = new PlantUmlBuilder() + .addType(SimpleClazz.create("Car", Clazz.Type.CLASS, + new SimpleAttribute("brand", "String"), + new SimpleAttribute("wheels", "Collection"))) + .build(); - assertThat(diagram).isEqualTo("class \"Car\" {" + CR + " brand : String" + CR - + " wheels : Collection" + CR + "}" + CR + CR); - } + assertThat(diagram).isEqualTo("class \"Car\" {" + CR + " brand : String" + CR + + " wheels : Collection" + CR + "}" + CR + CR); + } - @Test - public void buildEnum() { - final String diagram = new PlantUmlBuilder().addType(SimpleClazz.create("Devise", - Clazz.Type.ENUM, new SimpleAttribute("CHF", null), - new SimpleAttribute("EUR", null), new SimpleAttribute("USD", null))) - .build(); + @Test + public void buildEnum() { + final String diagram = new PlantUmlBuilder().addType(SimpleClazz.create("Devise", + Clazz.Type.ENUM, new SimpleAttribute("CHF", null), + new SimpleAttribute("EUR", null), new SimpleAttribute("USD", null))) + .build(); - assertThat(diagram).isEqualTo("enum \"Devise\" {" + CR + " CHF" + CR + " EUR" + CR - + " USD" + CR + "}" + CR + CR); - } + assertThat(diagram).isEqualTo("enum \"Devise\" {" + CR + " CHF" + CR + " EUR" + CR + + " USD" + CR + "}" + CR + CR); + } - @Test - public void buildAssociations() throws Exception { - String diagram = new PlantUmlBuilder() - .addAssociation("Vehicule", "Car", AssociationType.INHERITANCE) - .addAssociation("Car", "Price", AssociationType.DIRECTION, "price") - .addAssociation("Car", "Wheel", AssociationType.DIRECTION, "wheels", - Cardinality.NONE, Cardinality.MANY) - .addAssociation("Price", "Devise", AssociationType.DIRECTION) - .build(); + @Test + public void buildAssociations() throws Exception { + String diagram = new PlantUmlBuilder() + .addAssociation("Vehicule", "Car", AssociationType.INHERITANCE) + .addAssociation("Car", "Price", AssociationType.DIRECTION, "price") + .addAssociation("Car", "Wheel", AssociationType.DIRECTION, "wheels", + Cardinality.NONE, Cardinality.MANY) + .addAssociation("Price", "Devise", AssociationType.DIRECTION) + .build(); - assertThat(diagram).isEqualTo( - "\"Vehicule\" <|-- \"Car\"" + CR + "\"Car\" --> \"Price\" : price" - + CR + "\"Car\" --> \"*\" \"Wheel\" : wheels" + CR - + "\"Price\" --> \"Devise\"" + CR); - } + assertThat(diagram).isEqualTo( + "\"Vehicule\" <|-- \"Car\"" + CR + "\"Car\" --> \"Price\" : price" + + CR + "\"Car\" --> \"*\" \"Wheel\" : wheels" + CR + + "\"Price\" --> \"Devise\"" + CR); + } } diff --git a/src/test/java/ch/ifocusit/plantuml/classdiagram/ClassDiagramBuilderTest.java b/src/test/java/ch/ifocusit/plantuml/classdiagram/ClassDiagramBuilderTest.java index e260968..a3b173e 100644 --- a/src/test/java/ch/ifocusit/plantuml/classdiagram/ClassDiagramBuilderTest.java +++ b/src/test/java/ch/ifocusit/plantuml/classdiagram/ClassDiagramBuilderTest.java @@ -1,7 +1,7 @@ /* * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * 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 @@ -50,14 +50,15 @@ class ClassDiagramBuilderTest { @Test void buildShouldGenerateDiagram() throws Exception { - String expected = IOUtils.toString(Objects.requireNonNull(this.getClass().getResourceAsStream("/domain-diagram.plantuml")), Charset.defaultCharset()); + String expected = IOUtils.toString( + Objects.requireNonNull(this.getClass().getResourceAsStream("/domain-diagram.plantuml")), + Charset.defaultCharset()); // tag::createSimple[] - String diagram = - new ClassDiagramBuilder().excludes(".*\\.ignored", "Machine") - .addPackage(Vehicule.class.getPackage()).addClasses(Vehicule.class, - Car.class, Driver.class, Price.class, Wheel.class, Devise.class) - .build(); + String diagram = new ClassDiagramBuilder().excludes(".*\\.ignored", "Machine") + .addPackage(Vehicule.class.getPackage()).addClasses(Vehicule.class, + Car.class, Driver.class, Price.class, Wheel.class, Devise.class) + .build(); // end::createSimple[] assertThat(diagram).isEqualTo(expected); @@ -65,7 +66,9 @@ void buildShouldGenerateDiagram() throws Exception { @Test public void buildShouldGenerateDiagramFromAggregateMaster() throws Exception { - String expected = IOUtils.toString(Objects.requireNonNull(this.getClass().getResourceAsStream("/domain-aggregate-diagram.plantuml")), Charset.defaultCharset()); + String expected = IOUtils.toString( + Objects.requireNonNull(this.getClass().getResourceAsStream("/domain-aggregate-diagram.plantuml")), + Charset.defaultCharset()); // tag::createSimple[] String diagram = new ClassDiagramBuilder() @@ -81,7 +84,9 @@ public void buildShouldGenerateDiagramFromAggregateMaster() throws Exception { @Test public void buildShouldGenerateDiagramWithDepth() throws Exception { - String expected = IOUtils.toString(Objects.requireNonNull(this.getClass().getResourceAsStream("/service-diagram.plantuml")), Charset.defaultCharset()); + String expected = IOUtils.toString( + Objects.requireNonNull(this.getClass().getResourceAsStream("/service-diagram.plantuml")), + Charset.defaultCharset()); // tag::createFromOneClassWithDependencies[] String diagram = new ClassDiagramBuilder().addClasses(AccessDataService.class) @@ -140,7 +145,8 @@ public String getFieldName(Field field) { @Test public void testLinkRenderer() throws IOException { - String expected = IOUtils.toString(Objects.requireNonNull(this.getClass().getResourceAsStream("/links.puml")), Charset.defaultCharset()); + String expected = IOUtils.toString(Objects.requireNonNull(this.getClass().getResourceAsStream("/links.puml")), + Charset.defaultCharset()); String diagram = new ClassDiagramBuilder() .addClasses(Car.class, Driver.class) @@ -164,13 +170,13 @@ public Optional getFieldLink(Field field) { } Link link = new Link(); link.setUrl("https://link.com/car/" + field.getName().toLowerCase()); - if (field.getName().equals("brand") ) { + if (field.getName().equals("brand")) { link.setLabel("lien"); } - if (field.getName().equals("price") ) { + if (field.getName().equals("price")) { link.setTooltip("Show details"); } - if (field.getName().equals("model") ) { + if (field.getName().equals("model")) { link.setLabel("Car models"); link.setTooltip("Show all cars' models"); } diff --git a/src/test/java/ch/ifocusit/plantuml/test/helper/domain/Devise.java b/src/test/java/ch/ifocusit/plantuml/test/helper/domain/Devise.java index 390f878..df27c4f 100644 --- a/src/test/java/ch/ifocusit/plantuml/test/helper/domain/Devise.java +++ b/src/test/java/ch/ifocusit/plantuml/test/helper/domain/Devise.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/test/java/ch/ifocusit/plantuml/test/helper/domain/Driver.java b/src/test/java/ch/ifocusit/plantuml/test/helper/domain/Driver.java index 452c6d6..39272b6 100644 --- a/src/test/java/ch/ifocusit/plantuml/test/helper/domain/Driver.java +++ b/src/test/java/ch/ifocusit/plantuml/test/helper/domain/Driver.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/test/java/ch/ifocusit/plantuml/test/helper/domain/Price.java b/src/test/java/ch/ifocusit/plantuml/test/helper/domain/Price.java index c1c331d..ad97808 100644 --- a/src/test/java/ch/ifocusit/plantuml/test/helper/domain/Price.java +++ b/src/test/java/ch/ifocusit/plantuml/test/helper/domain/Price.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/test/java/ch/ifocusit/plantuml/test/helper/domain/material/Car.java b/src/test/java/ch/ifocusit/plantuml/test/helper/domain/material/Car.java index 13a4f55..17c1e1e 100644 --- a/src/test/java/ch/ifocusit/plantuml/test/helper/domain/material/Car.java +++ b/src/test/java/ch/ifocusit/plantuml/test/helper/domain/material/Car.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/test/java/ch/ifocusit/plantuml/test/helper/domain/material/Vehicule.java b/src/test/java/ch/ifocusit/plantuml/test/helper/domain/material/Vehicule.java index 15897b1..01b8914 100644 --- a/src/test/java/ch/ifocusit/plantuml/test/helper/domain/material/Vehicule.java +++ b/src/test/java/ch/ifocusit/plantuml/test/helper/domain/material/Vehicule.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file diff --git a/src/test/java/ch/ifocusit/plantuml/test/helper/domain/material/Wheel.java b/src/test/java/ch/ifocusit/plantuml/test/helper/domain/material/Wheel.java index 6915b50..260e3d9 100644 --- a/src/test/java/ch/ifocusit/plantuml/test/helper/domain/material/Wheel.java +++ b/src/test/java/ch/ifocusit/plantuml/test/helper/domain/material/Wheel.java @@ -1,7 +1,7 @@ /*- * Plantuml builder * - * Copyright (C) 2023 Focus IT + * Copyright (C) 2024 Focus IT * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file