generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some more tests for legacy data marshalling
- Loading branch information
1 parent
1fea577
commit 35e7793
Showing
11 changed files
with
234 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/test/java/uk/gov/hmcts/opal/service/legacy/dto/DefendantAccountSearchCriteriaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package uk.gov.hmcts.opal.service.legacy.dto; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Test; | ||
import uk.gov.hmcts.opal.dto.ToJsonString; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import static uk.gov.hmcts.opal.service.legacy.dto.DefendantAccountSearchCriteria.DefendantAccountSearchCriteriaBuilder; | ||
|
||
@Slf4j | ||
public class DefendantAccountSearchCriteriaTest { | ||
|
||
@Test | ||
public void testBuilder() throws InterruptedException { | ||
DefendantAccountSearchCriteria criteria = constructDefendantAccountSearchCriteria(); | ||
|
||
assertEquals("accountNo", criteria.getAccountNumber()); | ||
assertEquals("John", criteria.getForenames()); | ||
assertEquals("D", criteria.getInitials()); | ||
assertEquals("Smith", criteria.getSurname()); | ||
assertEquals("1977-06-26", criteria.getBirthDate()); | ||
assertEquals("Glasgow", criteria.getAddressLine1()); | ||
assertEquals("XX123456C", criteria.getNationalInsuranceNumber()); | ||
assertEquals(1L, criteria.getBusinessUnitId()); | ||
assertNull(criteria.getOrganisationName()); | ||
assertNull(criteria.getProsecutorCaseReference()); | ||
} | ||
|
||
@Test | ||
public void testNullBusinessUnit() { | ||
DefendantAccountSearchCriteriaBuilder criteriaBuilder = constructDefendantAccountSearchCriteriaBuilder(); | ||
DefendantAccountSearchCriteria criteria = criteriaBuilder.businessUnitId(null).build(); | ||
assertNull(criteria.getBusinessUnitId()); | ||
assertEquals(getJsonRepresentation(), criteria.toPrettyJson()); | ||
} | ||
|
||
@Test | ||
public void testJsonString() throws Exception { | ||
DefendantAccountSearchCriteria model = constructDefendantAccountSearchCriteria(); | ||
assertNotNull(model.toJsonString()); | ||
|
||
DefendantAccountSearchCriteria parsed = ToJsonString.getObjectMapper() | ||
.readValue(getJsonRepresentation(), DefendantAccountSearchCriteria.class); | ||
assertNotNull(parsed); | ||
} | ||
|
||
private DefendantAccountSearchCriteria constructDefendantAccountSearchCriteria() { | ||
return constructDefendantAccountSearchCriteriaBuilder().build(); | ||
} | ||
|
||
private DefendantAccountSearchCriteriaBuilder constructDefendantAccountSearchCriteriaBuilder() { | ||
return DefendantAccountSearchCriteria.builder() | ||
.accountNumber("accountNo") | ||
.addressLine1("Glasgow") | ||
.businessUnitId(1L) | ||
.firstRowNumber(4) | ||
.lastRowNumber(44) | ||
.surname("Smith") | ||
.forenames("John") | ||
.initials("D") | ||
.birthDate("1977-06-26") | ||
.nationalInsuranceNumber("XX123456C"); | ||
} | ||
|
||
private String getJsonRepresentation() { | ||
return """ | ||
{ | ||
"surname" : "Smith", | ||
"forenames" : "John", | ||
"initials" : "D", | ||
"firstRowNumber" : 4, | ||
"lastRowNumber" : 44, | ||
"account_number" : "accountNo", | ||
"birth_date" : "1977-06-26", | ||
"national_insurance_number" : "XX123456C", | ||
"address_line_1" : "Glasgow" | ||
}"""; | ||
} | ||
} |
Oops, something went wrong.