diff --git a/caab-api/open-api-specification.yml b/caab-api/open-api-specification.yml index b19ed1e..c9db2f7 100644 --- a/caab-api/open-api-specification.yml +++ b/caab-api/open-api-specification.yml @@ -1489,7 +1489,7 @@ components: organisation_name: type: 'string' organisation_type: - $ref: "#/components/schemas/stringDisplayValue" + type: "string" currently_trading: type: 'boolean' contact_name_role: @@ -1921,6 +1921,8 @@ components: baseApplication: type: 'object' properties: + id: + type: 'integer' case_reference_number: type: 'string' category_of_law: diff --git a/caab-service/src/integrationTest/java/uk/gov/laa/ccms/data/api/controller/BaseApplicationControllerIntegrationTest.java b/caab-service/src/integrationTest/java/uk/gov/laa/ccms/data/api/controller/BaseApplicationControllerIntegrationTest.java index b8a9196..0961501 100644 --- a/caab-service/src/integrationTest/java/uk/gov/laa/ccms/data/api/controller/BaseApplicationControllerIntegrationTest.java +++ b/caab-service/src/integrationTest/java/uk/gov/laa/ccms/data/api/controller/BaseApplicationControllerIntegrationTest.java @@ -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); diff --git a/caab-service/src/integrationTest/java/uk/gov/laa/ccms/data/api/service/BaseApplicationServiceIntegrationTest.java b/caab-service/src/integrationTest/java/uk/gov/laa/ccms/data/api/service/BaseApplicationServiceIntegrationTest.java index 8fd7d67..bbb0b99 100644 --- a/caab-service/src/integrationTest/java/uk/gov/laa/ccms/data/api/service/BaseApplicationServiceIntegrationTest.java +++ b/caab-service/src/integrationTest/java/uk/gov/laa/ccms/data/api/service/BaseApplicationServiceIntegrationTest.java @@ -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"; @@ -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()); @@ -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()); @@ -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); @@ -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) diff --git a/caab-service/src/integrationTest/resources/json/applicationDetail_opponent.json b/caab-service/src/integrationTest/resources/json/applicationDetail_opponent.json index 5e2e579..6a40e29 100644 --- a/caab-service/src/integrationTest/resources/json/applicationDetail_opponent.json +++ b/caab-service/src/integrationTest/resources/json/applicationDetail_opponent.json @@ -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, diff --git a/caab-service/src/integrationTest/resources/json/applicationDetail_opponentAddress.json b/caab-service/src/integrationTest/resources/json/applicationDetail_opponentAddress.json index b5ef3fa..fce60b3 100644 --- a/caab-service/src/integrationTest/resources/json/applicationDetail_opponentAddress.json +++ b/caab-service/src/integrationTest/resources/json/applicationDetail_opponentAddress.json @@ -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, diff --git a/caab-service/src/integrationTest/resources/json/opponent_new.json b/caab-service/src/integrationTest/resources/json/opponent_new.json index eaa1284..db91c59 100644 --- a/caab-service/src/integrationTest/resources/json/opponent_new.json +++ b/caab-service/src/integrationTest/resources/json/opponent_new.json @@ -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, diff --git a/caab-service/src/main/java/uk/gov/laa/ccms/caab/api/mapper/ApplicationMapper.java b/caab-service/src/main/java/uk/gov/laa/ccms/caab/api/mapper/ApplicationMapper.java index e2965e9..3f92411 100644 --- a/caab-service/src/main/java/uk/gov/laa/ccms/caab/api/mapper/ApplicationMapper.java +++ b/caab-service/src/main/java/uk/gov/laa/ccms/caab/api/mapper/ApplicationMapper.java @@ -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") @@ -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( diff --git a/caab-service/src/test/java/uk/gov/laa/ccms/caab/api/mapper/ApplicationMapperTest.java b/caab-service/src/test/java/uk/gov/laa/ccms/caab/api/mapper/ApplicationMapperTest.java index d0c1f18..c5d4788 100644 --- a/caab-service/src/test/java/uk/gov/laa/ccms/caab/api/mapper/ApplicationMapperTest.java +++ b/caab-service/src/test/java/uk/gov/laa/ccms/caab/api/mapper/ApplicationMapperTest.java @@ -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()); @@ -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()); @@ -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"); @@ -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()); @@ -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()); @@ -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 @@ -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)