GH-1 - Update Maven artifact coordinates, package and directory structure.

Original pull request: GH-7.
This commit is contained in:
Björn Kieling
2022-07-07 12:16:07 +02:00
committed by Oliver Drotbohm
parent 6c444769d7
commit 417e215993
255 changed files with 764 additions and 759 deletions

View File

@@ -0,0 +1,71 @@
/*
* Copyright 2020 the original author or authors.
*
* Licensed 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
*
* https://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.springframework.modulith.docs;
import static org.assertj.core.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.springframework.modulith.model.Modules;
import org.springframework.context.ApplicationContext;
import com.tngtech.archunit.core.domain.JavaClass;
import com.tngtech.archunit.core.importer.ClassFileImporter;
/**
* @author Oliver Drotbohm
*/
class AsciidoctorUnitTests {
Asciidoctor asciidoctor = Asciidoctor.withJavadocBase(Modules.of("org.springframework.modulith"), "{javadoc}");
@Test
void formatsInlineCode() {
assertThat(asciidoctor.toInlineCode("Foo")).isEqualTo("`Foo`");
}
@Test
void rendersLinkToMethodReference() {
assertThat(asciidoctor.toInlineCode("Documenter#toModuleCanvas(Module, CanvasOptions)"))
.isEqualTo("link:{javadoc}/org/springframework/modulith/docs/Documenter.html"
+ "[`o.s.m.d.Documenter#toModuleCanvas(Module, CanvasOptions)`]");
}
@Test
void doesNotRenderLinkToMethodReferenceForNonPublicType() {
assertThat(asciidoctor.toInlineCode("DocumentationSource#getDocumentation(JavaMethod)"))
.isEqualTo("`o.s.m.d.DocumentationSource#getDocumentation(JavaMethod)`");
}
@Test
void rendersInlineCodeForNonModuleTypeCorrectly() {
JavaClass type = new ClassFileImporter().importClass(ApplicationContext.class);
assertThatCode(() -> asciidoctor.toInlineCode(type)).doesNotThrowAnyException();
}
@Test
void cleansUpJavadocForConfigurationProperties() {
ConfigurationProperties metadata = new ConfigurationProperties();
assertThat(metadata).containsExactly(new ConfigurationProperties.ConfigurationProperty("org.springframework.modulith.sample.test",
"Some test property of type {@link java.lang.Boolean}.", "java.lang.Boolean",
"com.acme.myproject.stereotypes.Stereotypes$SomeConfigurationProperties", "false"));
}
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright 2018 the original author or authors.
*
* Licensed 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.springframework.modulith.docs;
import static org.assertj.core.api.Assertions.*;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.Optional;
import org.junit.jupiter.api.Test;
import org.springframework.modulith.docs.Documenter.Options;
import org.springframework.modulith.model.Module;
import org.springframework.modulith.model.Module.DependencyType;
import com.acme.myproject.Application;
/**
* Unit tests for {@link Documenter}.
*
* @author Oliver Gierke
*/
class DocumenterTest {
Documenter documenter = new Documenter(Application.class);
@Test
void writesComponentStructureAsPlantUml() throws IOException {
documenter.toPlantUml();
}
@Test
void writesSingleModuleDocumentation() throws IOException {
Module module = documenter.getModules().getModuleByName("moduleB") //
.orElseThrow(() -> new IllegalArgumentException());
documenter.writeModuleAsPlantUml(module, Options.defaults() //
.withColorSelector(it -> Optional.of("#ff0000")) //
.withDefaultDisplayName(it -> it.getDisplayName().toUpperCase()));
Options options = Options.defaults() //
.withComponentFilter(component -> component.getRelationships().stream()
.anyMatch(it -> it.getTagsAsSet().contains(DependencyType.EVENT_LISTENER.toString())));
documenter.writeModulesAsPlantUml(options);
}
@Test
void testName() {
documenter.getModules().stream() //
.map(it -> documenter.toModuleCanvas(it));
}
@Test
void customizesOutputLocation() throws IOException {
String customOutputFolder = "build/spring-modulith";
Path path = Paths.get(customOutputFolder);
try {
documenter.withOutputFolder(customOutputFolder).writeModuleCanvases();
assertThat(Files.list(path)).isNotEmpty();
assertThat(path).exists();
} finally {
Files.walk(path)
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);
}
}
}

View File

@@ -0,0 +1,19 @@
{
"groups": [
{
"name": "org.springframework.modulith.sample",
"type": "com.acme.myproject.stereotypes.Stereotypes$SomeConfigurationProperties",
"sourceType": "com.acme.myproject.stereotypes.Stereotypes$SomeConfigurationProperties"
}
],
"properties": [
{
"name": "org.springframework.modulith.sample.test",
"type": "java.lang.Boolean",
"description": "Some test property of type {@link java.lang.Boolean}.",
"sourceType": "com.acme.myproject.stereotypes.Stereotypes$SomeConfigurationProperties",
"defaultValue": false
}
],
"hints": []
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %5p %40.40c:%4L - %m%n</pattern>
</encoder>
</appender>
<root level="error">
<appender-ref ref="console" />
</root>
</configuration>