@@ -25,6 +25,7 @@ public class ClientHistoryControllerIntegrationTest extends
2525 void shouldReturnHistoryLogsByClientNumber (
2626 String clientNumber ,
2727 String expectedClientNumber ,
28+ boolean expectEmptyWithHeader ,
2829 Class <RuntimeException > exception
2930 ) {
3031
@@ -41,22 +42,37 @@ void shouldReturnHistoryLogsByClientNumber(
4142 if (StringUtils .isNotBlank (expectedClientNumber )) {
4243 response
4344 .expectStatus ().isOk ()
45+ .expectHeader ().exists ("x-total-count" )
46+ .expectHeader ().value ("x-total-count" ,
47+ count -> assertThat (Integer .parseInt (count )).isGreaterThan (0 ))
4448 .expectBodyList (HistoryLogDto .class )
4549 .value (logs -> assertThat (logs ).isNotEmpty ());
4650 }
4751
52+ if (expectEmptyWithHeader ) {
53+ response
54+ .expectStatus ().isOk ()
55+ .expectHeader ().exists ("x-total-count" )
56+ .expectHeader ().valueEquals ("x-total-count" , "0" )
57+ .expectBodyList (HistoryLogDto .class )
58+ .value (logs -> assertThat (logs ).isEmpty ());
59+ }
60+
4861 if (exception != null ) {
4962 response .expectStatus ().is4xxClientError ();
5063 }
5164 }
5265
5366 private static Stream <Arguments > byClientNumber () {
5467 return Stream .of (
55- // Valid case
56- Arguments .of ("00000138" , "00000138" , null ),
68+ // Valid case: client with history logs
69+ Arguments .of ("00000138" , "00000138" , false , null ),
70+
71+ // Valid case: client with no history logs — x-total-count must still be "0"
72+ Arguments .of ("99999999" , null , true , null ),
5773
5874 // Invalid case: missing client number
59- Arguments .of (null , null , MissingRequiredParameterException .class ));
75+ Arguments .of (null , null , false , MissingRequiredParameterException .class ));
6076 }
6177
6278}
0 commit comments