Skip to content

Commit

Permalink
fix(ccls-2121): add id to baseapplication (#32)
Browse files Browse the repository at this point in the history
* fix(ccls-2121): add id to baseapplication

* fix(ccls-2121): correct integration tests
  • Loading branch information
porritta authored Mar 27, 2024
1 parent 48362d9 commit b5bc242
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 45 deletions.
4 changes: 3 additions & 1 deletion caab-api/open-api-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ components:
organisation_name:
type: 'string'
organisation_type:
$ref: "#/components/schemas/stringDisplayValue"
type: "string"
currently_trading:
type: 'boolean'
contact_name_role:
Expand Down Expand Up @@ -1921,6 +1921,8 @@ components:
baseApplication:
type: 'object'
properties:
id:
type: 'integer'
case_reference_number:
type: 'string'
category_of_law:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ private void updateExpectedBooleans(ApplicationDetail applicationDetail) {
}

private void nullModelIds(ApplicationDetail applicationDetail) {
applicationDetail.setId(null);

if (applicationDetail.getLinkedCases() != null) {
for (LinkedCase linkedCase : applicationDetail.getLinkedCases()) {
linkedCase.setId(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public abstract class BaseApplicationServiceIntegrationTest {
private ApplicationService applicationService;
@Autowired
private ApplicationRepository applicationRepository;

private final Long applicationId = 9876L;
private final String lscCaseReference = "LSC001";
private final Integer providerId = 123456;
private final String providerCaseReference = "PRD_CASE_REF_001";
Expand Down Expand Up @@ -139,11 +141,12 @@ public void testSaveApplication_allFields(){

// Assert that the fetched application is not null and has the expected values
assertNotNull(fetchedApplication);
assertEquals(savedId, fetchedApplication.getId());
assertEquals(lscCaseReference, fetchedApplication.getLscCaseReference());
assertEquals(providerId.toString(), fetchedApplication.getProviderId());
assertEquals(providerCaseReference, fetchedApplication.getProviderCaseReference());
assertEquals(providerDisplayValue, fetchedApplication.getProviderDisplayValue());
assertEquals(officeId, fetchedApplication.getOfficeId().intValue());
assertEquals(officeId, fetchedApplication.getOfficeId());
assertEquals(officeDisplayValue, fetchedApplication.getOfficeDisplayValue());
assertEquals(supervisor, fetchedApplication.getSupervisor());
assertEquals(supervisorDisplayValue, fetchedApplication.getSupervisorDisplayValue());
Expand Down Expand Up @@ -232,7 +235,7 @@ public void testSaveApplication_opponent(){
assertEquals(builtOpponent.getMiddleNames(), fetchedOpponent.getMiddleNames());
assertEquals(builtOpponent.getNationalInsuranceNumber(), fetchedOpponent.getNationalInsuranceNumber());
assertEquals(builtOpponent.getOrganisationName(), fetchedOpponent.getOrganisationName());
assertEquals(builtOpponent.getOrganisationType().getId(), fetchedOpponent.getOrganisationType());
assertEquals(builtOpponent.getOrganisationType(), fetchedOpponent.getOrganisationType());
assertEquals(builtOpponent.getOtherInformation(), fetchedOpponent.getOtherInformation());
assertEquals(builtOpponent.getPublicFundingApplied(), fetchedOpponent.getPublicFundingApplied());
assertEquals(builtOpponent.getRelationshipToCase(), fetchedOpponent.getRelationshipToCase());
Expand Down Expand Up @@ -484,6 +487,8 @@ private ApplicationDetail buildRequiredApplicationDetail() {

private ApplicationDetail buildApplication(){
ApplicationDetail application = buildRequiredApplicationDetail();
application.setId(applicationId.intValue());

//provider details
ApplicationProviderDetails providerDetails = application.getProviderDetails();
providerDetails.setProviderCaseReference(providerCaseReference);
Expand Down Expand Up @@ -597,7 +602,7 @@ public uk.gov.laa.ccms.caab.model.Opponent buildOpponent(java.util.Date date) {
.middleNames("midnames")
.nationalInsuranceNumber("nino")
.organisationName("orgName")
.organisationType(new StringDisplayValue().id("orgid").displayValue("org"))
.organisationType("orgid")
.otherInformation("otherInf")
.partyId("party")
.publicFundingApplied(Boolean.TRUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@
"assessed_assets": 50000,
"assessment_date": null,
"organisation_name": "Organisation Name",
"organisation_type": {
"id": "Org"
},
"organisation_type": "Org",
"currently_trading": true,
"contact_name_role": "Contact Role",
"confirmed": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@
"assessed_assets": 50000,
"assessment_date": null,
"organisation_name": "Organisation Name",
"organisation_type": {
"id": "Org"
},
"organisation_type": "Org",
"currently_trading": true,
"contact_name_role": "Contact Role",
"confirmed": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
"assessed_assets": 50000,
"assessment_date": null,
"organisation_name": "Organisation Name",
"organisation_type": {
"id": "Org"
},
"organisation_type": "Org",
"currently_trading": true,
"contact_name_role": "Contact Role",
"confirmed": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ uk.gov.laa.ccms.caab.model.ReferenceDataItem toReferenceDataItemModel(
uk.gov.laa.ccms.caab.model.ScopeLimitation toScopeLimitationModel(
ScopeLimitation scopeLimitation);

@Mapping(target = "organisationType", source = "organisationType.id")
@Mapping(target = "auditTrail", ignore = true)
@Mapping(target = "address", source = "address", qualifiedByName = "toAddress")
@Mapping(target = "appMode", source = "appMode", defaultValue = "true")
Expand All @@ -199,7 +198,6 @@ uk.gov.laa.ccms.caab.model.ScopeLimitation toScopeLimitationModel(
uk.gov.laa.ccms.caab.model.Opponent toOpponentModel(Opponent opponent);

@Mapping(target = "id", ignore = true)
@Mapping(target = "organisationType", source = "organisationType.id")
@Mapping(target = "auditTrail", ignore = true)
@Mapping(target = "address", source = "address", qualifiedByName = "toAddress")
void updateOpponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ public void testToOpponent() {
Opponent opponent = mapper.toOpponent(opponentModel);

assertNotNull(opponent);
assertEquals(opponentModel.getOrganisationType().getId(), opponent.getOrganisationType());
assertEquals(opponentModel.getOrganisationType(), opponent.getOrganisationType());
assertEquals(opponentModel.getEbsId(), opponent.getEbsId());
assertEquals(opponentModel.getType(), opponent.getType());
assertEquals(opponentModel.getTitle(), opponent.getTitle());
Expand Down Expand Up @@ -860,6 +860,7 @@ void testToApplicationDetailWithValidInput() {

// Verify the resulting ApplicationDetail instance
assertNotNull(applicationDetail);
assertEquals(application.getId().intValue(), applicationDetail.getId());
assertEquals(Integer.valueOf(12345), applicationDetail.getProviderDetails().getProvider().getId());
assertEquals("Provider Display Value", applicationDetail.getProviderDetails().getProvider().getDisplayValue());
assertEquals("Provider Case Reference", applicationDetail.getProviderDetails().getProviderCaseReference());
Expand All @@ -881,6 +882,7 @@ void testToApplicationDetailWithValidInput() {

private static Application getApplication() {
Application application = new Application();
application.setId(9876L);
application.setProviderId("12345");
application.setProviderDisplayValue("Provider Display Value");
application.setProviderCaseReference("Provider Case Reference");
Expand Down Expand Up @@ -1308,7 +1310,7 @@ void testUpdateOpponent() {
assertEquals(opponentBefore.getId(), opponent.getId());
assertEquals(opponentBefore.getAuditTrail(), opponent.getAuditTrail());

assertEquals(opponentModel.getOrganisationType().getId(), opponent.getOrganisationType());
assertEquals(opponentModel.getOrganisationType(), opponent.getOrganisationType());
assertEquals(opponentModel.getEbsId(), opponent.getEbsId());
assertEquals(opponentModel.getType(), opponent.getType());
assertEquals(opponentModel.getTitle(), opponent.getTitle());
Expand Down Expand Up @@ -1348,28 +1350,12 @@ void testUpdateOpponent() {

@Test
public void testToBaseApplication() {
Application application = new Application();
application.setLscCaseReference("caseref");
application.setCategoryOfLaw("cat1");
application.setCategoryOfLawDisplayValue("cat 1");
application.setActualStatus("actstat");
application.setDisplayStatus("dispstat");
application.setClientFirstName("firstname");
application.setClientSurname("surname");
application.setClientReference("clientref");
application.setProviderId("123");
application.setProviderDisplayValue("Provider Display Value");
application.setOfficeId(1);
application.setOfficeDisplayValue("Office 1");
application.setSupervisorDisplayValue("Supervisor Display Value");
application.setFeeEarnerDisplayValue("Fee Earner Display Value");
application.setProviderContactDisplayValue("Provider Contact Display Value");
application.setProviderCaseReference("ProviderCase123");

Application application = getApplication();

BaseApplication result = mapper.toBaseApplication(application);

assertNotNull(result);
assertEquals(application.getId().intValue(), result.getId());
assertEquals(application.getLscCaseReference(), result.getCaseReferenceNumber());
assertEquals(application.getCategoryOfLaw(), result.getCategoryOfLaw().getId());
assertEquals(application.getCategoryOfLawDisplayValue(), result.getCategoryOfLaw().getDisplayValue());
Expand All @@ -1379,15 +1365,14 @@ public void testToBaseApplication() {
assertEquals(application.getClientSurname(), result.getClient().getSurname());
assertEquals(application.getClientReference(), result.getClient().getReference());

assertEquals(123, result.getProviderDetails().getProvider().getId());
assertEquals("Provider Display Value", result.getProviderDetails().getProvider().getDisplayValue());
assertEquals(1, result.getProviderDetails().getOffice().getId());
assertEquals("Office 1", result.getProviderDetails().getOffice().getDisplayValue());
assertEquals("Supervisor Display Value", result.getProviderDetails().getSupervisor().getDisplayValue());
assertEquals("Fee Earner Display Value", result.getProviderDetails().getFeeEarner().getDisplayValue());
assertEquals("Provider Contact Display Value", result.getProviderDetails().getProviderContact().getDisplayValue());
assertEquals("ProviderCase123", result.getProviderDetails().getProviderCaseReference());

assertEquals(Integer.valueOf(application.getProviderId()), result.getProviderDetails().getProvider().getId());
assertEquals(application.getProviderDisplayValue(), result.getProviderDetails().getProvider().getDisplayValue());
assertEquals(application.getOfficeId(), result.getProviderDetails().getOffice().getId());
assertEquals(application.getOfficeDisplayValue(), result.getProviderDetails().getOffice().getDisplayValue());
assertEquals(application.getSupervisorDisplayValue(), result.getProviderDetails().getSupervisor().getDisplayValue());
assertEquals(application.getFeeEarnerDisplayValue(), result.getProviderDetails().getFeeEarner().getDisplayValue());
assertEquals(application.getProviderContactDisplayValue(), result.getProviderDetails().getProviderContact().getDisplayValue());
assertEquals(application.getProviderCaseReference(), result.getProviderDetails().getProviderCaseReference());
}

@Test
Expand Down Expand Up @@ -1515,7 +1500,7 @@ public uk.gov.laa.ccms.caab.model.Opponent buildOpponentModel(java.util.Date dat
.middleNames("midnames")
.nationalInsuranceNumber("nino")
.organisationName("orgName")
.organisationType(new StringDisplayValue().id("orgid").displayValue("org"))
.organisationType("orgid")
.otherInformation("otherInf")
.partyId("party")
.publicFundingApplied(Boolean.TRUE)
Expand Down

0 comments on commit b5bc242

Please sign in to comment.