Refactor ResultInfo to use Java record

Replaced the ResultInfo class with a Java record for conciseness and immutability. Adjusted related validation logic and method calls to align with the new record structure. Minor updates to Javadoc documentation were also included.
This commit is contained in:
2025-04-26 18:40:38 +02:00
parent 3efbe1eaae
commit a5f892b86a
55 changed files with 619 additions and 118 deletions
@@ -62,7 +62,7 @@ class ResponseValidatorTest {
void validateSingleResultExpectedButMultipleFound() {
when(mockMultipleResponse.getResponseResultInfo()).thenReturn(mockResultInfo);
when(mockResultInfo.isSuccess()).thenReturn(true);
when(mockMultipleResponse.getResultInfo()).thenReturn(new TestResultInfo(2));
when(mockMultipleResponse.getResultInfo()).thenReturn(new ResultInfo(2));
CloudflareApiException exception = assertThrows(CloudflareApiException.class,
() -> validatorWithException.validate(mockMultipleResponse, true));
@@ -73,7 +73,7 @@ class ResponseValidatorTest {
void validateEmptyResultWithExceptionEnabled() {
when(mockMultipleResponse.getResponseResultInfo()).thenReturn(mockResultInfo);
when(mockResultInfo.isSuccess()).thenReturn(true);
when(mockMultipleResponse.getResultInfo()).thenReturn(new TestResultInfo(0));
when(mockMultipleResponse.getResultInfo()).thenReturn(new ResultInfo(0));
assertThrows(CloudflareNotFoundException.class,
() -> validatorWithException.validate(mockMultipleResponse, false));
@@ -83,17 +83,8 @@ class ResponseValidatorTest {
void validateEmptyResultWithExceptionDisabled() {
when(mockMultipleResponse.getResponseResultInfo()).thenReturn(mockResultInfo);
when(mockResultInfo.isSuccess()).thenReturn(true);
when(mockMultipleResponse.getResultInfo()).thenReturn(new TestResultInfo(0));
when(mockMultipleResponse.getResultInfo()).thenReturn(new ResultInfo(0));
assertDoesNotThrow(() -> validatorWithoutException.validate(mockMultipleResponse, true));
}
@Getter
private static class TestResultInfo extends ResultInfo {
private final int totalCount;
TestResultInfo(int totalCount) {
this.totalCount = totalCount;
}
}
}