15
15
*/
16
16
package org .springframework .data .jpa .repository .support ;
17
17
18
- import static java .util .Arrays .*;
19
- import static org .mockito .Mockito .*;
20
-
21
- import java .util .HashSet ;
18
+ import static java .util .Arrays .asList ;
19
+ import static org .mockito .Mockito .RETURNS_DEEP_STUBS ;
20
+ import static org .mockito .Mockito .mock ;
21
+ import static org .mockito .Mockito .verify ;
22
+ import static org .mockito .Mockito .when ;
22
23
23
24
import jakarta .persistence .EntityGraph ;
24
25
import jakarta .persistence .EntityManager ;
25
26
import jakarta .persistence .Subgraph ;
26
27
28
+ import java .util .HashSet ;
29
+
27
30
import org .junit .jupiter .api .BeforeEach ;
28
31
import org .junit .jupiter .api .Test ;
29
32
30
33
/**
31
34
* Unit tests for {@link EntityGraphFactory}.
32
35
*
33
36
* @author Jens Schauder
37
+ * @author Petr Strnad
34
38
*/
35
39
@ SuppressWarnings ("rawtypes" )
36
40
class EntityGraphFactoryUnitTests {
@@ -45,8 +49,7 @@ void beforeEach() {
45
49
when (em .createEntityGraph (DummyEntity .class )).thenReturn (entityGraph );
46
50
}
47
51
48
- // GH-2329
49
- @ Test
52
+ @ Test // GH-2329
50
53
void simpleSetOfPropertiesGetRegistered () {
51
54
52
55
HashSet <String > properties = new HashSet <>(asList ("one" , "two" ));
@@ -57,8 +60,7 @@ void simpleSetOfPropertiesGetRegistered() {
57
60
verify (entityGraph ).addAttributeNodes ("two" );
58
61
}
59
62
60
- // GH-2329
61
- @ Test
63
+ @ Test // GH-2329
62
64
void setOfCompositePropertiesGetRegisteredPiecewise () {
63
65
64
66
HashSet <String > properties = new HashSet <>(asList ("one.two" , "eins.zwei.drei" ));
@@ -76,6 +78,19 @@ void setOfCompositePropertiesGetRegisteredPiecewise() {
76
78
verify (zwei ).addAttributeNodes ("drei" );
77
79
}
78
80
81
+ @ Test // GH-2571
82
+ void multipleSubNodesUnderSameParentNodeShouldWork () {
83
+
84
+ HashSet <String > properties = new HashSet <>(asList ("one.one" , "one.two" ));
85
+
86
+ entityGraph = EntityGraphFactory .create (em , DummyEntity .class , properties );
87
+
88
+ verify (entityGraph ).addSubgraph ("one" );
89
+ Subgraph <?> one = entityGraph .addSubgraph ("one" );
90
+ verify (one ).addAttributeNodes ("one" );
91
+ verify (one ).addAttributeNodes ("two" );
92
+ }
93
+
79
94
private static class DummyEntity {
80
95
DummyEntity one ;
81
96
DummyEntity two ;
0 commit comments