3
3
import static org .junit .jupiter .api .Assertions .assertEquals ;
4
4
import static org .junit .jupiter .api .Assertions .assertFalse ;
5
5
import static org .junit .jupiter .api .Assertions .assertTrue ;
6
+ import static org .springframework .test .context .jdbc .Sql .ExecutionPhase .AFTER_TEST_CLASS ;
7
+ import static org .springframework .test .context .jdbc .Sql .ExecutionPhase .BEFORE_TEST_CLASS ;
8
+ import static org .springframework .test .context .jdbc .SqlMergeMode .MergeMode .MERGE ;
6
9
7
10
import jakarta .persistence .EntityManager ;
8
11
import jakarta .persistence .PersistenceContext ;
9
12
import java .time .LocalDate ;
10
13
import org .junit .jupiter .api .BeforeEach ;
11
14
import org .junit .jupiter .api .DisplayName ;
12
15
import org .junit .jupiter .api .Test ;
13
- import org .springframework .boot .test .autoconfigure . orm . jpa . DataJpaTest ;
16
+ import org .springframework .boot .test .context . SpringBootTest ;
14
17
import org .springframework .data .domain .Page ;
15
18
import org .springframework .data .domain .Pageable ;
16
- import org .springframework .test .context .ActiveProfiles ;
19
+ import org .springframework .test .context .jdbc .Sql ;
20
+ import org .springframework .test .context .jdbc .SqlMergeMode ;
21
+ import org .springframework .transaction .annotation .Transactional ;
22
+ import uk .gov .laa .ccms .data .IntegrationTestInterface ;
17
23
import uk .gov .laa .ccms .data .entity .NotificationInfo ;
18
24
19
- @ DataJpaTest
20
- @ ActiveProfiles ("h2-test" )
25
+ @ SpringBootTest
26
+ @ SqlMergeMode (MERGE )
27
+ @ Sql (executionPhase =BEFORE_TEST_CLASS ,scripts = "/sql/get_notif_info_create_schema.sql" )
28
+ @ Sql (executionPhase =AFTER_TEST_CLASS ,scripts = "/sql/get_notif_info_drop_schema.sql" )
21
29
@ DisplayName ("NotificationInfo Repository Integration Test" )
22
- class NotificationSearchRepositoryIntegrationTest {
30
+ class NotificationSearchRepositoryIntegrationTest implements IntegrationTestInterface {
23
31
24
32
private NotificationSearchRepository notificationRepository ;
25
33
@@ -29,35 +37,48 @@ class NotificationSearchRepositoryIntegrationTest {
29
37
private NotificationInfo n1 ;
30
38
private NotificationInfo n2 ;
31
39
40
+ @ Transactional
32
41
@ BeforeEach
33
42
void setUp () {
34
43
notificationRepository = new NotificationSearchRepository (entityManager );
35
44
// Insert test data into the in-memory database
36
45
n1 = NotificationInfo .builder ().notificationId (1L )
46
+ .userId ("test_user" )
47
+ .userLoginId ("test_login" )
37
48
.providerFirmId (10L )
49
+ .dateAssigned (LocalDate .of (2025 , 1 , 1 ))
50
+ .subject ("Subject" )
51
+ .dueDate (LocalDate .of (2027 , 1 , 1 ))
52
+ .assignedTo ("JBriggs" )
53
+ .status ("open" )
38
54
.lscCaseRefReference ("1001" )
39
55
.providerCaseReference ("First Case Reference" )
40
- .assignedTo ("JBriggs" )
56
+ .clientName ("Jamie Briggs" )
57
+ .feeEarner ("Fee" )
41
58
.personLastName ("Briggs" )
42
59
.feeEarnerPartyId (3001L )
43
- .isOpen (true )
44
60
.actionNotificationInd ("N" )
45
- .dateAssigned ( LocalDate . of ( 2025 , 1 , 1 ) )
61
+ .isOpen ( true )
46
62
.build ();
47
63
n2 = NotificationInfo .builder ().notificationId (2L )
64
+ .userId ("test_user" )
65
+ .userLoginId ("test_login" )
48
66
.providerFirmId (10L )
49
- .lscCaseRefReference ("1002" )
50
- .providerCaseReference ("Second Case Reference" )
67
+ .dateAssigned (LocalDate .of (2026 , 1 , 1 ))
68
+ .subject ("Subject" )
69
+ .dueDate (LocalDate .of (2027 , 1 , 1 ))
51
70
.assignedTo ("SMonday" )
71
+ .status ("open" )
72
+ .lscCaseRefReference ("2100" )
73
+ .providerCaseReference ("Second Case Reference" )
74
+ .clientName ("Ski Monday" )
75
+ .feeEarner ("Fee" )
52
76
.personLastName ("Bri-Monday" )
53
77
.feeEarnerPartyId (3002L )
54
- .isOpen (false )
55
78
.actionNotificationInd ("O" )
56
- .dateAssigned ( LocalDate . of ( 2026 , 1 , 1 ) )
79
+ .isOpen ( false )
57
80
.build ();
58
- // Use entityManager as NotificationRepository extends ReadOnlyRepository.
59
- entityManager .persist (n1 );
60
- entityManager .persist (n2 );
81
+
61
82
}
62
83
63
84
@ Test
@@ -136,9 +157,9 @@ void shouldFilterBySimilarCaseReferenceNumber(){
136
157
null ,
137
158
null , Pageable .ofSize (10 ).withPage (0 ));
138
159
// Then
139
- assertEquals (2 , result .getTotalElements ());
140
160
assertTrue (result .getContent ().contains (n1 ));
141
161
assertTrue (result .getContent ().contains (n2 ));
162
+ assertEquals (2 , result .getTotalElements ());
142
163
}
143
164
144
165
@ Test
@@ -398,7 +419,7 @@ void shouldFilterByDateToInclusive(){
398
419
true ,
399
420
null ,
400
421
null ,
401
- LocalDate .of (2026 , 1 , 1 ), Pageable .ofSize (10 ).withPage (0 ));
422
+ LocalDate .of (2027 , 1 , 1 ), Pageable .ofSize (10 ).withPage (0 ));
402
423
// Then
403
424
assertEquals (2 , result .getTotalElements ());
404
425
assertTrue (result .getContent ().contains (n1 ));
0 commit comments