Unfortunately this does not work if the method is an implementation of a generic interface method
public interface ItemProcessor<I, O> {
Integer process(I var1) throws Exception;
}
public class LoadProcessor implements ItemProcessor<String, Integer> {
@Override
@Transactional
public Integer process(String var1) throws Exception {
return null;
}
}
The result is
java.lang.AssertionError: Architecture Violation [Priority: MEDIUM] - Rule 'no classes should directly call other methods declared in the same class that are annotated with @Transactional, because it bypasses the proxy mechanism' was violated (1 times): Method <org.example.LoadProcessor.process(java.lang.Object)> calls method <org.example.LoadProcessor.process(java.lang.String)> in (LoadProcessor.java:5)
Same result if ItemProcessor is an abstract class. Tested with archunit-junit5 in version 1.2.0.
I use your recommended test to avoid internal calls to methods with
@Transactional
Unfortunately this does not work if the method is an implementation of a generic interface method
The result is
java.lang.AssertionError: Architecture Violation [Priority: MEDIUM] - Rule 'no classes should directly call other methods declared in the same class that are annotated with @Transactional, because it bypasses the proxy mechanism' was violated (1 times): Method <org.example.LoadProcessor.process(java.lang.Object)> calls method <org.example.LoadProcessor.process(java.lang.String)> in (LoadProcessor.java:5)
Same result if ItemProcessor is an abstract class. Tested with
archunit-junit5
in version1.2.0
.