-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2315 from DamnClin/arch-unit-module
Migrate arch unit module
- Loading branch information
Showing
19 changed files
with
177 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
15
...pster/lite/generator/server/javatool/arch/application/JavaArchUnitApplicationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
package tech.jhipster.lite.generator.server.javatool.arch.application; | ||
|
||
import org.springframework.stereotype.Service; | ||
import tech.jhipster.lite.generator.project.domain.Project; | ||
import tech.jhipster.lite.generator.server.javatool.arch.domain.JavaArchUnitService; | ||
import tech.jhipster.lite.generator.server.javatool.arch.domain.ArchUnitModuleFactory; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
@Service | ||
public class JavaArchUnitApplicationService { | ||
|
||
private final JavaArchUnitService javaArchUnitService; | ||
private final ArchUnitModuleFactory factory; | ||
|
||
public JavaArchUnitApplicationService(JavaArchUnitService javaArchUnitService) { | ||
this.javaArchUnitService = javaArchUnitService; | ||
public JavaArchUnitApplicationService() { | ||
factory = new ArchUnitModuleFactory(); | ||
} | ||
|
||
public void init(Project project) { | ||
javaArchUnitService.init(project); | ||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
return factory.buildModule(properties); | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
src/main/java/tech/jhipster/lite/generator/server/javatool/arch/domain/ArchUnit.java
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
.../java/tech/jhipster/lite/generator/server/javatool/arch/domain/ArchUnitModuleFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package tech.jhipster.lite.generator.server.javatool.arch.domain; | ||
|
||
import static tech.jhipster.lite.module.domain.JHipsterModule.*; | ||
|
||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
import tech.jhipster.lite.error.domain.Assert; | ||
import tech.jhipster.lite.module.domain.JHipsterDestination; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.JHipsterSource; | ||
import tech.jhipster.lite.module.domain.javadependency.JavaDependency; | ||
import tech.jhipster.lite.module.domain.javadependency.JavaDependencyScope; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterBasePackage; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
public class ArchUnitModuleFactory { | ||
|
||
private static final String QUOTE = "\""; | ||
private static final JHipsterSource SOURCE = from("server/javatool/arch"); | ||
|
||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
Assert.notNull("properties", properties); | ||
|
||
JHipsterDestination testDestination = toSrcTestJava().append(properties.basePackage().path()); | ||
|
||
//@formatter:off | ||
return moduleBuilder(properties) | ||
.context() | ||
.put("packageWalkPath", packageWalkPath(properties.basePackage())) | ||
.and() | ||
.files() | ||
.add(SOURCE.template("archunit.properties"), to("src/test/resources/archunit.properties")) | ||
.add(SOURCE.template("HexagonalArchTest.java"), testDestination.append("HexagonalArchTest.java")) | ||
.and() | ||
.javaDependencies() | ||
.add(archUnitDependency()) | ||
.and() | ||
.optionalReplacements() | ||
.in("src/test/resources/logback.xml") | ||
.add(justLineBefore(text("<!-- jhipster-needle-logback-add-log -->")), "<logger name=\"com.tngtech.archunit\" level=\"WARN\" />") | ||
.and() | ||
.and() | ||
.build(); | ||
//@formatter:on | ||
} | ||
|
||
private String packageWalkPath(JHipsterBasePackage basePackage) { | ||
return Stream.of(basePackage.path().split("/")).map(folder -> QUOTE + folder + QUOTE).collect(Collectors.joining(", ")); | ||
} | ||
|
||
private JavaDependency archUnitDependency() { | ||
return javaDependency() | ||
.groupId("com.tngtech.archunit") | ||
.artifactId("archunit-junit5-api") | ||
.versionSlug("archunit-junit5.version") | ||
.scope(JavaDependencyScope.TEST) | ||
.build(); | ||
} | ||
} |
81 changes: 0 additions & 81 deletions
81
...a/tech/jhipster/lite/generator/server/javatool/arch/domain/JavaArchUnitDomainService.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...in/java/tech/jhipster/lite/generator/server/javatool/arch/domain/JavaArchUnitService.java
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...e/generator/server/javatool/arch/infrastructure/config/JavaArchUnitBeanConfiguration.java
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
...te/generator/server/javatool/arch/infrastructure/primary/ArchUnitModuleConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package tech.jhipster.lite.generator.server.javatool.arch.infrastructure.primary; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import tech.jhipster.lite.generator.server.javatool.arch.application.JavaArchUnitApplicationService; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModulePropertiesDefinition; | ||
import tech.jhipster.lite.module.infrastructure.primary.JHipsterModuleApiDoc; | ||
import tech.jhipster.lite.module.infrastructure.primary.JHipsterModuleResource; | ||
|
||
@Configuration | ||
class ArchUnitModuleConfiguration { | ||
|
||
@Bean | ||
JHipsterModuleResource archUnitModule(JavaArchUnitApplicationService archUnit) { | ||
return JHipsterModuleResource | ||
.builder() | ||
.legacyUrl("/api/servers/java/arch") | ||
.slug("java-archunit") | ||
.propertiesDefinition(JHipsterModulePropertiesDefinition.builder().addBasePackage().build()) | ||
.apiDoc(new JHipsterModuleApiDoc("Java", "Add Hexagonal Arch classes to project")) | ||
.factory(archUnit::buildModule); | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
...lite/generator/server/javatool/arch/infrastructure/primary/rest/JavaArchUnitResource.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Feature: Arch Unit | ||
|
||
Scenario: Should apply arch unit module | ||
When I apply "java-archunit" module to default project with maven file | ||
| packageName | tech.jhipster.chips | | ||
Then I should have files in "src/test/java/tech/jhipster/chips" | ||
| HexagonalArchTest.java | |
41 changes: 0 additions & 41 deletions
41
...ter/lite/generator/server/javatool/arch/application/JavaArchUnitApplicationServiceIT.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.