Skip to content

Commit

Permalink
Review: Add more complex integration test for annotation parameters
Browse files Browse the repository at this point in the history
It is good to have an example illustrating dependencies by nested annotation parameters, and also good to have an integration test covering this complex scenario.

Issue: #136
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
  • Loading branch information
codecholeric authored and Alen Kosanović committed Jan 9, 2020
1 parent 4795986 commit c1a86c7
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
Class <com.tngtech.archunit.example.layers.persistence.layerviolation.DaoCallingService> implements interface <com.tngtech.archunit.example.layers.service.ServiceInterface> in (DaoCallingService.java:0)
Class <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> has annotation member of type <com.tngtech.archunit.example.layers.service.SimpleServiceAnnotation> in (ServiceViolatingLayerRules.java:0)
Class <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> is annotated with <com.tngtech.archunit.example.layers.service.ComplexServiceAnnotation> in (ServiceViolatingLayerRules.java:0)
Class <com.tngtech.archunit.example.layers.service.impl.ServiceImplementation> implements interface <com.tngtech.archunit.example.layers.service.ServiceInterface> in (ServiceImplementation.java:0)
Constructor <com.tngtech.archunit.example.layers.SomeMediator.<init>(com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules)> has parameter of type <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> in (SomeMediator.java:0)
Field <com.tngtech.archunit.example.layers.SomeMediator.service> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> in (SomeMediator.java:0)
Field <com.tngtech.archunit.example.layers.controller.SomeController.otherService> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> in (SomeController.java:0)
Field <com.tngtech.archunit.example.layers.controller.SomeController.service> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules> in (SomeController.java:0)
Field <com.tngtech.archunit.example.layers.persistence.layerviolation.DaoCallingService.service> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> in (DaoCallingService.java:0)
Field <com.tngtech.archunit.example.layers.service.ServiceType.$VALUES> has type <[Lcom.tngtech.archunit.example.layers.service.ServiceType;> in (ServiceType.java:0)
Field <com.tngtech.archunit.example.layers.service.ServiceType.STANDARD> has type <com.tngtech.archunit.example.layers.service.ServiceType> in (ServiceType.java:0)
Field <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules.myEntityManager> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules$MyEntityManager> in (ServiceViolatingDaoRules.java:0)
Method <com.tngtech.archunit.example.layers.SomeMediator.violateLayerRulesIndirectly()> calls method <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules.doSomething()> in (SomeMediator.java:15)
Method <com.tngtech.archunit.example.layers.controller.SomeGuiController.callServiceLayer()> calls constructor <com.tngtech.archunit.example.layers.service.ServiceHelper.<init>()> in (SomeGuiController.java:7)
Method <com.tngtech.archunit.example.layers.controller.SomeGuiController.callServiceLayer()> calls constructor <com.tngtech.archunit.example.layers.service.ServiceHelper.<init>(java.lang.String)> in (SomeGuiController.java:8)
Method <com.tngtech.archunit.example.layers.controller.SomeGuiController.callServiceLayer()> gets field <com.tngtech.archunit.example.layers.service.ServiceHelper.insecure> in (SomeGuiController.java:10)
Method <com.tngtech.archunit.example.layers.controller.SomeGuiController.callServiceLayer()> gets field <com.tngtech.archunit.example.layers.service.ServiceHelper.properlySecured> in (SomeGuiController.java:11)
Method <com.tngtech.archunit.example.layers.persistence.layerviolation.DaoCallingService.violateLayerRules()> calls method <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules.doSomething()> in (DaoCallingService.java:14)
Method <com.tngtech.archunit.example.layers.service.ComplexServiceAnnotation.serviceType()> has return type <com.tngtech.archunit.example.layers.service.ServiceType> in (ComplexServiceAnnotation.java:0)
Method <com.tngtech.archunit.example.layers.service.ComplexServiceAnnotation.simpleServiceAnnotation()> has return type <com.tngtech.archunit.example.layers.service.SimpleServiceAnnotation> in (ComplexServiceAnnotation.java:0)
Method <com.tngtech.archunit.example.layers.service.ServiceType.valueOf(java.lang.String)> has return type <com.tngtech.archunit.example.layers.service.ServiceType> in (ServiceType.java:0)
Method <com.tngtech.archunit.example.layers.service.ServiceType.values()> calls method <[Lcom.tngtech.archunit.example.layers.service.ServiceType;.clone()> in (ServiceType.java:3)
Method <com.tngtech.archunit.example.layers.service.ServiceType.values()> has return type <[Lcom.tngtech.archunit.example.layers.service.ServiceType;> in (ServiceType.java:0)
Method <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules.illegallyUseEntityManager()> calls method <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules$MyEntityManager.persist(java.lang.Object)> in (ServiceViolatingDaoRules.java:27)
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
Class <com.tngtech.archunit.example.layers.persistence.layerviolation.DaoCallingService> implements interface <com.tngtech.archunit.example.layers.service.ServiceInterface> in (DaoCallingService.java:0)
Class <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> has annotation member of type <com.tngtech.archunit.example.layers.service.SimpleServiceAnnotation> in (ServiceViolatingLayerRules.java:0)
Class <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> is annotated with <com.tngtech.archunit.example.layers.service.ComplexServiceAnnotation> in (ServiceViolatingLayerRules.java:0)
Class <com.tngtech.archunit.example.layers.service.impl.ServiceImplementation> implements interface <com.tngtech.archunit.example.layers.service.ServiceInterface> in (ServiceImplementation.java:0)
Constructor <com.tngtech.archunit.example.layers.SomeMediator.<init>(com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules)> has parameter of type <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> in (SomeMediator.java:0)
Field <com.tngtech.archunit.example.layers.SomeMediator.service> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> in (SomeMediator.java:0)
Field <com.tngtech.archunit.example.layers.controller.SomeController.otherService> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> in (SomeController.java:0)
Field <com.tngtech.archunit.example.layers.controller.SomeController.service> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules> in (SomeController.java:0)
Field <com.tngtech.archunit.example.layers.persistence.layerviolation.DaoCallingService.service> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> in (DaoCallingService.java:0)
Field <com.tngtech.archunit.example.layers.service.ServiceType.$VALUES> has type <[Lcom.tngtech.archunit.example.layers.service.ServiceType;> in (ServiceType.java:0)
Field <com.tngtech.archunit.example.layers.service.ServiceType.STANDARD> has type <com.tngtech.archunit.example.layers.service.ServiceType> in (ServiceType.java:0)
Field <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules.myEntityManager> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules$MyEntityManager> in (ServiceViolatingDaoRules.java:0)
Method <com.tngtech.archunit.example.layers.SomeMediator.violateLayerRulesIndirectly()> calls method <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules.doSomething()> in (SomeMediator.java:15)
Method <com.tngtech.archunit.example.layers.controller.SomeGuiController.callServiceLayer()> calls constructor <com.tngtech.archunit.example.layers.service.ServiceHelper.<init>()> in (SomeGuiController.java:7)
Method <com.tngtech.archunit.example.layers.controller.SomeGuiController.callServiceLayer()> calls constructor <com.tngtech.archunit.example.layers.service.ServiceHelper.<init>(java.lang.String)> in (SomeGuiController.java:8)
Method <com.tngtech.archunit.example.layers.controller.SomeGuiController.callServiceLayer()> gets field <com.tngtech.archunit.example.layers.service.ServiceHelper.insecure> in (SomeGuiController.java:10)
Method <com.tngtech.archunit.example.layers.controller.SomeGuiController.callServiceLayer()> gets field <com.tngtech.archunit.example.layers.service.ServiceHelper.properlySecured> in (SomeGuiController.java:11)
Method <com.tngtech.archunit.example.layers.persistence.layerviolation.DaoCallingService.violateLayerRules()> calls method <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules.doSomething()> in (DaoCallingService.java:14)
Method <com.tngtech.archunit.example.layers.service.ComplexServiceAnnotation.serviceType()> has return type <com.tngtech.archunit.example.layers.service.ServiceType> in (ComplexServiceAnnotation.java:0)
Method <com.tngtech.archunit.example.layers.service.ComplexServiceAnnotation.simpleServiceAnnotation()> has return type <com.tngtech.archunit.example.layers.service.SimpleServiceAnnotation> in (ComplexServiceAnnotation.java:0)
Method <com.tngtech.archunit.example.layers.service.ServiceType.valueOf(java.lang.String)> has return type <com.tngtech.archunit.example.layers.service.ServiceType> in (ServiceType.java:0)
Method <com.tngtech.archunit.example.layers.service.ServiceType.values()> calls method <[Lcom.tngtech.archunit.example.layers.service.ServiceType;.clone()> in (ServiceType.java:3)
Method <com.tngtech.archunit.example.layers.service.ServiceType.values()> has return type <[Lcom.tngtech.archunit.example.layers.service.ServiceType;> in (ServiceType.java:0)
Method <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules.illegallyUseEntityManager()> calls method <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules$MyEntityManager.persist(java.lang.Object)> in (ServiceViolatingDaoRules.java:27)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.tngtech.archunit.example.layers.controller;

public @interface ComplexControllerAnnotation {
SimpleControllerAnnotation simpleControllerAnnotation();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.tngtech.archunit.example.layers.controller;

public @interface SimpleControllerAnnotation {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.tngtech.archunit.example.layers.service;

import com.tngtech.archunit.example.layers.controller.ComplexControllerAnnotation;
import com.tngtech.archunit.example.layers.controller.one.SomeEnum;

public @interface ComplexServiceAnnotation {
ComplexControllerAnnotation controllerAnnotation();

SimpleServiceAnnotation simpleServiceAnnotation();

SomeEnum controllerEnum();

ServiceType serviceType();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.tngtech.archunit.example.layers.service;

public enum ServiceType {
STANDARD
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package com.tngtech.archunit.example.layers.service;

import com.tngtech.archunit.example.layers.MyService;
import com.tngtech.archunit.example.layers.controller.ComplexControllerAnnotation;
import com.tngtech.archunit.example.layers.controller.SimpleControllerAnnotation;
import com.tngtech.archunit.example.layers.controller.SomeGuiController;
import com.tngtech.archunit.example.layers.controller.one.SomeEnum;
import com.tngtech.archunit.example.layers.controller.one.UseCaseOneTwoController;
import com.tngtech.archunit.example.layers.controller.two.UseCaseTwoController;
import com.tngtech.archunit.example.layers.security.Secured;

@MyService
@ComplexServiceAnnotation(
controllerAnnotation = @ComplexControllerAnnotation(simpleControllerAnnotation = @SimpleControllerAnnotation),
simpleServiceAnnotation = @SimpleServiceAnnotation,
controllerEnum = SomeEnum.DISPATCH,
serviceType = ServiceType.STANDARD
)
public class ServiceViolatingLayerRules {
public static final String illegalAccessToController = "illegalAccessToController";
public static final String doSomething = "doSomething";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.tngtech.archunit.example.layers.service;

public @interface SimpleServiceAnnotation {
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
Class <com.tngtech.archunit.example.layers.persistence.layerviolation.DaoCallingService> implements interface <com.tngtech.archunit.example.layers.service.ServiceInterface> in (DaoCallingService.java:0)
Class <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> has annotation member of type <com.tngtech.archunit.example.layers.service.SimpleServiceAnnotation> in (ServiceViolatingLayerRules.java:0)
Class <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> is annotated with <com.tngtech.archunit.example.layers.service.ComplexServiceAnnotation> in (ServiceViolatingLayerRules.java:0)
Class <com.tngtech.archunit.example.layers.service.impl.ServiceImplementation> implements interface <com.tngtech.archunit.example.layers.service.ServiceInterface> in (ServiceImplementation.java:0)
Constructor <com.tngtech.archunit.example.layers.SomeMediator.<init>(com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules)> has parameter of type <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> in (SomeMediator.java:0)
Field <com.tngtech.archunit.example.layers.SomeMediator.service> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> in (SomeMediator.java:0)
Field <com.tngtech.archunit.example.layers.controller.SomeController.otherService> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> in (SomeController.java:0)
Field <com.tngtech.archunit.example.layers.controller.SomeController.service> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules> in (SomeController.java:0)
Field <com.tngtech.archunit.example.layers.persistence.layerviolation.DaoCallingService.service> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules> in (DaoCallingService.java:0)
Field <com.tngtech.archunit.example.layers.service.ServiceType.$VALUES> has type <[Lcom.tngtech.archunit.example.layers.service.ServiceType;> in (ServiceType.java:0)
Field <com.tngtech.archunit.example.layers.service.ServiceType.STANDARD> has type <com.tngtech.archunit.example.layers.service.ServiceType> in (ServiceType.java:0)
Field <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules.myEntityManager> has type <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules$MyEntityManager> in (ServiceViolatingDaoRules.java:0)
Method <com.tngtech.archunit.example.layers.SomeMediator.violateLayerRulesIndirectly()> calls method <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules.doSomething()> in (SomeMediator.java:15)
Method <com.tngtech.archunit.example.layers.controller.SomeGuiController.callServiceLayer()> calls constructor <com.tngtech.archunit.example.layers.service.ServiceHelper.<init>()> in (SomeGuiController.java:7)
Method <com.tngtech.archunit.example.layers.controller.SomeGuiController.callServiceLayer()> calls constructor <com.tngtech.archunit.example.layers.service.ServiceHelper.<init>(java.lang.String)> in (SomeGuiController.java:8)
Method <com.tngtech.archunit.example.layers.controller.SomeGuiController.callServiceLayer()> gets field <com.tngtech.archunit.example.layers.service.ServiceHelper.insecure> in (SomeGuiController.java:10)
Method <com.tngtech.archunit.example.layers.controller.SomeGuiController.callServiceLayer()> gets field <com.tngtech.archunit.example.layers.service.ServiceHelper.properlySecured> in (SomeGuiController.java:11)
Method <com.tngtech.archunit.example.layers.persistence.layerviolation.DaoCallingService.violateLayerRules()> calls method <com.tngtech.archunit.example.layers.service.ServiceViolatingLayerRules.doSomething()> in (DaoCallingService.java:14)
Method <com.tngtech.archunit.example.layers.service.ComplexServiceAnnotation.serviceType()> has return type <com.tngtech.archunit.example.layers.service.ServiceType> in (ComplexServiceAnnotation.java:0)
Method <com.tngtech.archunit.example.layers.service.ComplexServiceAnnotation.simpleServiceAnnotation()> has return type <com.tngtech.archunit.example.layers.service.SimpleServiceAnnotation> in (ComplexServiceAnnotation.java:0)
Method <com.tngtech.archunit.example.layers.service.ServiceType.valueOf(java.lang.String)> has return type <com.tngtech.archunit.example.layers.service.ServiceType> in (ServiceType.java:0)
Method <com.tngtech.archunit.example.layers.service.ServiceType.values()> calls method <[Lcom.tngtech.archunit.example.layers.service.ServiceType;.clone()> in (ServiceType.java:3)
Method <com.tngtech.archunit.example.layers.service.ServiceType.values()> has return type <[Lcom.tngtech.archunit.example.layers.service.ServiceType;> in (ServiceType.java:0)
Method <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules.illegallyUseEntityManager()> calls method <com.tngtech.archunit.example.layers.service.ServiceViolatingDaoRules$MyEntityManager.persist(java.lang.Object)> in (ServiceViolatingDaoRules.java:27)
Loading

0 comments on commit c1a86c7

Please sign in to comment.