-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArchUnit, README, Postman, Structure refactoring
- Loading branch information
Showing
52 changed files
with
600 additions
and
170 deletions.
There are no files selected for viewing
Empty file.
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 +1,29 @@ | ||
# arch-blueprint-java | ||
# arch-blueprint-java | ||
|
||
![build workflow](https://github.com/vondacho/arch-blueprint-java/actions/workflows/build.yml/badge.svg) | ||
|
||
A Java project as template and pedagogical support for the teaching of Clean Architecture crafting practice. | ||
|
||
## Features | ||
|
||
CRUD operations on Customer entities exposed by a REST API. | ||
|
||
- Web request validation with Atlassian | ||
- Web security based on Basic Authentication | ||
- Application management with Spring Actuator | ||
- Acceptance testing with Cucumber | ||
- Contract testing with Pact and Spring Cloud Contract | ||
- Architecture testing with ArchUnit | ||
|
||
## Getting started | ||
|
||
- To build the project with `./gradlew clean build`. | ||
- To launch the test suite with `./gradlew clean check`. | ||
- To launch the application with `./gradlew bootRun --args='--spring.profiles.active=test,jpa'`. | ||
|
||
## Technical documentation | ||
|
||
- Powered by MkDocs | ||
- API documentation powered by Swagger UI | ||
- Architecture documentation powered by Structurizr and AppMap | ||
- [Latest release](https://vondacho.github.io/arch-blueprint-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
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,12 @@ | ||
version: "3.7" | ||
|
||
services: | ||
postgres: | ||
container_name: postgres-blueprint | ||
image: postgres:12-alpine | ||
ports: | ||
- 15432:5432 | ||
environment: | ||
- POSTGRES_DB=blueprint | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=blueprint |
14 changes: 7 additions & 7 deletions
14
src/acceptanceTest/java/edu/obya/blueprint/customer/at/CustomerCucumberBootstrap.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
8 changes: 4 additions & 4 deletions
8
...st/java/edu/obya/blueprint/customer/at/config/CustomerCucumberTypeRegistryConfigurer.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
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
8 changes: 4 additions & 4 deletions
8
src/acceptanceTest/java/edu/obya/blueprint/customer/at/steps/AssertionSteps.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
4 changes: 2 additions & 2 deletions
4
src/acceptanceTest/java/edu/obya/blueprint/customer/at/steps/FixtureSteps.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
115 changes: 115 additions & 0 deletions
115
src/archTest/java/edu/obya/blueprint/customer/CustomerArchitectureTest.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,115 @@ | ||
package edu.obya.blueprint.customer; | ||
|
||
import com.tngtech.archunit.core.domain.JavaClass; | ||
import com.tngtech.archunit.core.domain.JavaClasses; | ||
import com.tngtech.archunit.core.importer.ClassFileImporter; | ||
import com.tngtech.archunit.library.dependencies.SliceAssignment; | ||
import com.tngtech.archunit.library.dependencies.SliceIdentifier; | ||
import com.tngtech.archunit.library.dependencies.SlicesRuleDefinition; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; | ||
import static com.tngtech.archunit.library.Architectures.onionArchitecture; | ||
|
||
public class CustomerArchitectureTest { | ||
|
||
final String ROOT_PACKAGE = "edu.obya.blueprint"; | ||
final String ALL_FEATURE_PACKAGES = ROOT_PACKAGE + ".."; | ||
final String CUSTOMER_FEATURE_PACKAGE = ROOT_PACKAGE + ".customer"; | ||
|
||
/** | ||
* https://www.archunit.org/userguide/html/000_Index.html#_slices | ||
*/ | ||
@Test | ||
public void features_are_isolated_from_each_other() { | ||
JavaClasses importedClasses = new ClassFileImporter().importPackages(ALL_FEATURE_PACKAGES); | ||
SlicesRuleDefinition.slices().assignedFrom(new SliceAssignment() { | ||
@Override | ||
public SliceIdentifier getIdentifierOf(JavaClass javaClass) { | ||
if (javaClass.getName().contains(".customer.")) { | ||
return SliceIdentifier.of("customer"); | ||
} | ||
return SliceIdentifier.ignore(); | ||
} | ||
@Override | ||
public String getDescription() { | ||
return "only feature packages"; | ||
} | ||
}).should().notDependOnEachOther().check(importedClasses); | ||
} | ||
|
||
/** | ||
* https://www.archunit.org/userguide/html/000_Index.html#_onion_architecture | ||
*/ | ||
@Test | ||
public void dependencies_are_oriented_to_the_center() { | ||
JavaClasses importedClasses = new ClassFileImporter().importPackages(ALL_FEATURE_PACKAGES); | ||
onionArchitecture() | ||
.domainModels(CUSTOMER_FEATURE_PACKAGE + ".domain.model..") | ||
.domainServices(CUSTOMER_FEATURE_PACKAGE + ".domain.service..") | ||
.applicationServices( | ||
CUSTOMER_FEATURE_PACKAGE + ".application..", | ||
CUSTOMER_FEATURE_PACKAGE + ".config..", | ||
ROOT_PACKAGE + ".config.." | ||
) | ||
.adapter("rest", CUSTOMER_FEATURE_PACKAGE + ".adapter.rest..") | ||
.adapter("jpa", CUSTOMER_FEATURE_PACKAGE + ".adapter.jpa..") | ||
.check(importedClasses); | ||
} | ||
|
||
@Test | ||
public void output_ports_are_defined_as_interfaces() { | ||
JavaClasses importedClasses = new ClassFileImporter().importPackages(ALL_FEATURE_PACKAGES); | ||
classes() | ||
.that().haveSimpleNameEndingWith("Repository") | ||
.should().beInterfaces() | ||
.check(importedClasses); | ||
classes() | ||
.that().haveSimpleNameEndingWith("Client") | ||
.should().beInterfaces() | ||
.allowEmptyShould(true) | ||
.check(importedClasses); | ||
} | ||
|
||
/** | ||
* https://www.archunit.org/userguide/html/000_Index.html#_composing_class_rules | ||
*/ | ||
@Test | ||
public void repository_adapters_are_named_and_located_correctly() { | ||
JavaClasses importedClasses = new ClassFileImporter().importPackages(ALL_FEATURE_PACKAGES); | ||
importedClasses | ||
.stream() | ||
.filter(clazz -> clazz.getName().endsWith("Repository")) | ||
.collect(Collectors.toSet()) | ||
.forEach(clazz -> | ||
classes() | ||
.that().implement(clazz.getName()) | ||
.should().haveSimpleNameEndingWith("Adapter") | ||
.andShould().resideInAnyPackage(CUSTOMER_FEATURE_PACKAGE + ".adapter.jpa..") | ||
.allowEmptyShould(true) | ||
.check(importedClasses) | ||
); | ||
} | ||
|
||
/** | ||
* https://www.archunit.org/userguide/html/000_Index.html#_composing_class_rules | ||
*/ | ||
@Test | ||
public void client_adapters_are_named_and_located_correctly() { | ||
JavaClasses importedClasses = new ClassFileImporter().importPackages(ALL_FEATURE_PACKAGES); | ||
importedClasses | ||
.stream() | ||
.filter(clazz -> clazz.getName().endsWith("Client")) | ||
.collect(Collectors.toSet()) | ||
.forEach(clazz -> | ||
classes() | ||
.that().implement(clazz.getName()) | ||
.should().haveSimpleNameEndingWith("Adapter") | ||
.andShould().resideInAnyPackage(CUSTOMER_FEATURE_PACKAGE + ".adapter.client..") | ||
.allowEmptyShould(true) | ||
.check(importedClasses) | ||
); | ||
} | ||
} |
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,4 @@ | ||
# Because Spring context configuration depends on JPA adapter configuration | ||
.*CustomerEndpointIT.* | ||
# Because Spring context configuration depends on JPA adapter configuration | ||
.*CustomerServiceIT.* |
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
Oops, something went wrong.