File tree Expand file tree Collapse file tree 15 files changed +90
-15
lines changed
src/main/java/com/tngtech/archunit/example/layers
persistence/second/dao/jpa
src/main/java/com/tngtech/archunit/example/layers
persistence/second/dao/jpa
src/main/java/com/tngtech/archunit/example/layers
persistence/second/dao/jpa Expand file tree Collapse file tree 15 files changed +90
-15
lines changed Original file line number Diff line number Diff line change 1
1
dependencies {
2
- testImplementation ' com.tngtech.archunit:archunit-junit4:0.14.1 '
2
+ testImplementation ' com.tngtech.archunit:archunit-junit4:0.15.0 '
3
3
}
Original file line number Diff line number Diff line change 9
9
import com .tngtech .archunit .example .layers .persistence .second .dao .OtherDao ;
10
10
import com .tngtech .archunit .example .layers .persistence .second .dao .domain .OtherPersistentObject ;
11
11
import com .tngtech .archunit .example .layers .security .Secured ;
12
+ import com .tngtech .archunit .example .layers .service .ProxiedConnection ;
12
13
13
14
public class OtherJpa implements OtherDao {
14
15
@ PersistenceContext
@@ -22,6 +23,9 @@ public OtherPersistentObject findById(long id) {
22
23
@ Override
23
24
public void testConnection () throws SQLException {
24
25
Connection conn = entityManager .unwrap (Connection .class );
26
+ if (conn instanceof ProxiedConnection ) {
27
+ ((ProxiedConnection ) conn ).refresh ();
28
+ }
25
29
conn .prepareStatement ("SELECT 1 FROM DUAL" );
26
30
}
27
31
Original file line number Diff line number Diff line change
1
+ package com .tngtech .archunit .example .layers .service ;
2
+
3
+ public interface ProxiedConnection {
4
+ void refresh ();
5
+ }
Original file line number Diff line number Diff line change 1
1
package com .tngtech .archunit .example .layers .service ;
2
2
3
+ import java .util .Map ;
4
+ import java .util .Set ;
5
+
6
+ import com .tngtech .archunit .example .layers .controller .SomeUtility ;
7
+ import com .tngtech .archunit .example .layers .controller .one .SomeEnum ;
3
8
import com .tngtech .archunit .example .layers .security .Secured ;
4
9
5
10
/**
6
11
* Well modelled code always has lots of 'helpers' ;-)
7
12
*/
8
- public class ServiceHelper {
13
+ @ SuppressWarnings ("unused" )
14
+ public class ServiceHelper <
15
+ TYPE_PARAMETER_VIOLATING_LAYER_RULE extends SomeUtility ,
16
+ ANOTHER_TYPE_PARAMETER_VIOLATING_LAYER_RULE extends Map <?, Set <? super SomeEnum >>> {
17
+
9
18
public Object insecure = new Object ();
10
19
@ Secured
11
20
public Object properlySecured = new Object ();
Original file line number Diff line number Diff line change 9
9
import com .tngtech .archunit .example .layers .controller .two .UseCaseTwoController ;
10
10
import com .tngtech .archunit .example .layers .security .Secured ;
11
11
12
+ @ SuppressWarnings ("unused" )
12
13
@ MyService
13
14
@ ComplexServiceAnnotation (
14
15
controllerAnnotation = @ ComplexControllerAnnotation (simpleControllerAnnotation = @ SimpleControllerAnnotation ),
17
18
serviceType = ServiceType .STANDARD
18
19
)
19
20
public class ServiceViolatingLayerRules {
20
- public static final String illegalAccessToController = "illegalAccessToController" ;
21
- public static final String doSomething = "doSomething" ;
22
- public static final String dependentMethod = "dependentMethod" ;
23
21
24
22
void illegalAccessToController () {
25
23
System .out .println (UseCaseOneTwoController .someString );
@@ -34,7 +32,16 @@ public SomeGuiController dependentMethod(UseCaseTwoController otherController) {
34
32
return null ;
35
33
}
36
34
35
+ public SomeGuiController [][] dependentOnComponentTypeMethod (UseCaseTwoController [] otherController ) {
36
+ return null ;
37
+ }
38
+
37
39
@ Secured
38
40
public void properlySecured () {
39
41
}
42
+
43
+ public static final String illegalAccessToController = "illegalAccessToController" ;
44
+ public static final String doSomething = "doSomething" ;
45
+ public static final String dependentMethod = "dependentMethod" ;
46
+ public static final String dependentOnComponentTypeMethod = "dependentOnComponentTypeMethod" ;
40
47
}
Original file line number Diff line number Diff line change 1
1
dependencies {
2
- testImplementation ' com.tngtech.archunit:archunit-junit5:0.14.1 '
2
+ testImplementation ' com.tngtech.archunit:archunit-junit5:0.15.0 '
3
3
}
4
4
5
5
test {
Original file line number Diff line number Diff line change 9
9
import com .tngtech .archunit .example .layers .persistence .second .dao .OtherDao ;
10
10
import com .tngtech .archunit .example .layers .persistence .second .dao .domain .OtherPersistentObject ;
11
11
import com .tngtech .archunit .example .layers .security .Secured ;
12
+ import com .tngtech .archunit .example .layers .service .ProxiedConnection ;
12
13
13
14
public class OtherJpa implements OtherDao {
14
15
@ PersistenceContext
@@ -22,6 +23,9 @@ public OtherPersistentObject findById(long id) {
22
23
@ Override
23
24
public void testConnection () throws SQLException {
24
25
Connection conn = entityManager .unwrap (Connection .class );
26
+ if (conn instanceof ProxiedConnection ) {
27
+ ((ProxiedConnection ) conn ).refresh ();
28
+ }
25
29
conn .prepareStatement ("SELECT 1 FROM DUAL" );
26
30
}
27
31
Original file line number Diff line number Diff line change
1
+ package com .tngtech .archunit .example .layers .service ;
2
+
3
+ public interface ProxiedConnection {
4
+ void refresh ();
5
+ }
Original file line number Diff line number Diff line change 1
1
package com .tngtech .archunit .example .layers .service ;
2
2
3
+ import java .util .Map ;
4
+ import java .util .Set ;
5
+
6
+ import com .tngtech .archunit .example .layers .controller .SomeUtility ;
7
+ import com .tngtech .archunit .example .layers .controller .one .SomeEnum ;
3
8
import com .tngtech .archunit .example .layers .security .Secured ;
4
9
5
10
/**
6
11
* Well modelled code always has lots of 'helpers' ;-)
7
12
*/
8
- public class ServiceHelper {
13
+ @ SuppressWarnings ("unused" )
14
+ public class ServiceHelper <
15
+ TYPE_PARAMETER_VIOLATING_LAYER_RULE extends SomeUtility ,
16
+ ANOTHER_TYPE_PARAMETER_VIOLATING_LAYER_RULE extends Map <?, Set <? super SomeEnum >>> {
17
+
9
18
public Object insecure = new Object ();
10
19
@ Secured
11
20
public Object properlySecured = new Object ();
Original file line number Diff line number Diff line change 9
9
import com .tngtech .archunit .example .layers .controller .two .UseCaseTwoController ;
10
10
import com .tngtech .archunit .example .layers .security .Secured ;
11
11
12
+ @ SuppressWarnings ("unused" )
12
13
@ MyService
13
14
@ ComplexServiceAnnotation (
14
15
controllerAnnotation = @ ComplexControllerAnnotation (simpleControllerAnnotation = @ SimpleControllerAnnotation ),
17
18
serviceType = ServiceType .STANDARD
18
19
)
19
20
public class ServiceViolatingLayerRules {
20
- public static final String illegalAccessToController = "illegalAccessToController" ;
21
- public static final String doSomething = "doSomething" ;
22
- public static final String dependentMethod = "dependentMethod" ;
23
21
24
22
void illegalAccessToController () {
25
23
System .out .println (UseCaseOneTwoController .someString );
@@ -34,7 +32,16 @@ public SomeGuiController dependentMethod(UseCaseTwoController otherController) {
34
32
return null ;
35
33
}
36
34
35
+ public SomeGuiController [][] dependentOnComponentTypeMethod (UseCaseTwoController [] otherController ) {
36
+ return null ;
37
+ }
38
+
37
39
@ Secured
38
40
public void properlySecured () {
39
41
}
42
+
43
+ public static final String illegalAccessToController = "illegalAccessToController" ;
44
+ public static final String doSomething = "doSomething" ;
45
+ public static final String dependentMethod = "dependentMethod" ;
46
+ public static final String dependentOnComponentTypeMethod = "dependentOnComponentTypeMethod" ;
40
47
}
You can’t perform that action at this time.
0 commit comments