[JAVA] Test the integrity of the aggregation using ArchUnit ③

Another version of Testing aggregate consistency using ArchUnit ①


    @ArchTest
    static ArchRule aggregate_object_only_be_accessed_from_root =
        classes()
            .that().resideInAPackage("com.example.domain")
            .should().onlyBeAccessed().byClassesThat(new DescribedPredicate<JavaClass>("is AggregateRoot") {
            @Override
            public boolean apply(JavaClass input) {
                return input.getAnnotations().stream().anyMatch(a -> a.toString().equals("AggregateRoot"));
            }
        });

If @AggregateRoot is added to the aggregate root, it can be judged simply. The place to extract annotations should be able to be written a little more beautifully ...

Recommended Posts

Test the integrity of the aggregation using ArchUnit ②
Test the integrity of the aggregation using ArchUnit ③
Unit test architecture using ArchUnit
Try using || instead of the ternary operator
Introduction memo of automatic test using Jenkins
[Java] [Spring] Test the behavior of the logger
RSpec-Results of reviewing the test code for'users validation'
Story of test automation using Appium [Android / java]
I tried using the profiler of IntelliJ IDEA
Test the response JSON of the REST API created in Spring MVC using AssertJ in MockMvc
I tried using the Server Push function of Servlet 4.0
Get the name of the test case in the JUnit test class
Test the contents of an Excel file with JUnit
Rails6: Input the initial data of ActionText using seed
Output of the day of the week using Ruby's Date class
Limit the number of threads using Java's Executor Service
Are you using the default method of the interface properly?
The first step to using Xib instead of StoryBoard
Try using the query attribute of Ruby on Rails
The world of clara-rules (2)
Using Elasticsearch Java-API (Aggregation)
Judgment of the calendar
The world of clara-rules (4)
The world of clara-rules (3)
The world of clara-rules (5)
The idea of quicksort
Summary of using DBFlow
The idea of jQuery
[Enum] Let's improve the readability of data by using rails enum
[Rails] Register by attribute of the same model using Devise
Transition using the header image of CardView as it is
When using the constructor of Java's Date class, the date advances by 1900.
Check the status of Java application without using monitoring tool
[Ruby] Creating code using the concept of classes and instances
[Java] Try editing the elements of the Json string using the library
[Ruby] Display today's day of the week using Date class
How to mock some methods of the class under test
The story of pushing Java to Heroku using the BitBucket pipeline
About the default behavior of decimal point rounding using java.text.NumberFormat
[Apache Tomcat] The story of using Apache OpenWebBeans to enable CDI
Test the behavior of the log output logger when using an external logging API such as SLF4J