77import it .aboutbits .springboot .toolbox .autoconfiguration .persistence .impl .jpa .CustomTypeEnumTestModelRepository ;
88import it .aboutbits .springboot .toolbox .autoconfiguration .persistence .impl .jpa .CustomTypeTestModel ;
99import it .aboutbits .springboot .toolbox .autoconfiguration .persistence .impl .jpa .CustomTypeTestModelRepository ;
10+ import it .aboutbits .springboot .toolbox .autoconfiguration .persistence .impl .jpa .DirectEnumEntityId ;
11+ import it .aboutbits .springboot .toolbox .autoconfiguration .persistence .impl .jpa .DirectEnumIdTestModel ;
12+ import it .aboutbits .springboot .toolbox .autoconfiguration .persistence .impl .jpa .DirectEnumIdTestModelRepository ;
1013import it .aboutbits .springboot .toolbox .autoconfiguration .persistence .impl .jpa .ReferencedTestModel ;
1114import org .jspecify .annotations .NullMarked ;
1215import org .junit .jupiter .api .Nested ;
@@ -28,10 +31,13 @@ class EntityIdJpaTest {
2831 @ Autowired
2932 CustomTypeEnumTestModelRepository repositoryEnum ;
3033
34+ @ Autowired
35+ DirectEnumIdTestModelRepository repositoryDirectEnum ;
36+
3137 @ Nested
3238 class OwnId {
3339 @ Test
34- void inAndOut_shouldSucceed () {
40+ void ownId_inAndOut_shouldSucceed () {
3541 var item = new CustomTypeTestModel ();
3642
3743 var savedItem = repository .save (item );
@@ -48,7 +54,7 @@ void inAndOut_shouldSucceed() {
4854 @ Nested
4955 class ReferencedId {
5056 @ Test
51- void inAndOut_shouldSucceed () {
57+ void referencedId_inAndOut_shouldSucceed () {
5258 var item = new CustomTypeTestModel ();
5359 item .setReferencedId (new ReferencedTestModel .ID (1234L ));
5460
@@ -66,7 +72,7 @@ void inAndOut_shouldSucceed() {
6672 @ Nested
6773 class EnumId {
6874 @ Test
69- void inAndOut_shouldSucceed () {
75+ void enumId_inAndOut_shouldSucceed () {
7076 var values = CustomTypeEnumTestModel .CustomTypeEnum .values ();
7177
7278 var item = new CustomTypeEnumTestModel ();
@@ -84,4 +90,24 @@ values[new Random().nextInt(values.length)]
8490 .isEqualTo (savedItem );
8591 }
8692 }
93+
94+ @ Nested
95+ class DirectEnumId {
96+ @ Test
97+ void directEnumId_inAndOut_shouldSucceed () {
98+ var values = DirectEnumEntityId .values ();
99+
100+ var item = new DirectEnumIdTestModel ();
101+ item .setId (values [new Random ().nextInt (values .length )]);
102+
103+ var savedItem = repositoryDirectEnum .save (item );
104+
105+ var retrievedItem = repositoryDirectEnum .findById (savedItem .getId ());
106+
107+ assertThat (retrievedItem ).isPresent ()
108+ .get ()
109+ .usingRecursiveComparison ()
110+ .isEqualTo (savedItem );
111+ }
112+ }
87113}
0 commit comments