From a41b072b251df7a07c4c25b7834de53aa30830e1 Mon Sep 17 00:00:00 2001 From: palatsangeetha <138600841+palatsangeetha@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:43:49 +0100 Subject: [PATCH] SD-603 Update PartyFunction EBL (#243) --- .../standards/ebl/checks/EBLChecks.java | 20 ++++++++++- .../standards/ebl/checks/EblDatasets.java | 4 +++ .../ebl/messages/ebl-api-3.0.0-request.json | 2 +- .../standards/ebl/checks/EBLChecksTest.java | 34 +++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EBLChecks.java b/ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EBLChecks.java index 5c846917..451529ce 100644 --- a/ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EBLChecks.java +++ b/ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EBLChecks.java @@ -5,6 +5,8 @@ import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.EXEMPT_PACKAGE_CODES; import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.MODE_OF_TRANSPORT; import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.NATIONAL_COMMODITY_CODES; +import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.PARTY_FUNCTION_CODE; +import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.PARTY_FUNCTION_CODE_HBL; import static org.dcsa.conformance.standards.ebl.checks.EblDatasets.REQUESTED_CARRIER_CLAUSES; @@ -666,6 +668,19 @@ private static Consumer allDg(Consumer mav.submitAllMatching("documentParties.other.*.partyFunction"), + JsonAttribute.matchedMustBeDatasetKeywordIfPresent(PARTY_FUNCTION_CODE)); + + static final JsonRebaseableContentCheck VALID_PARTY_FUNCTION_HBL = + JsonAttribute.allIndividualMatchesMustBeValid( + "The partyFunction in OtherDocumentParty of houseBillOfLadings is valid", + mav -> + mav.submitAllMatching("houseBillOfLadings.*.documentParties.other.*.partyFunction"), + JsonAttribute.matchedMustBeDatasetKeywordIfPresent(PARTY_FUNCTION_CODE_HBL)); + private static final List STATIC_SI_CHECKS = Arrays.asList( JsonAttribute.mustBeDatasetKeywordIfPresent( SI_REQUEST_SEND_TO_PLATFORM, @@ -684,6 +699,8 @@ private static Consumer allDg(Consumer allDg(Consumer invalidErrors = VALID_CONSIGMENT_ITEMS_REFERENCE_TYPES.validate(rootNode); assertEquals(1, invalidErrors.size()); } + + @Test + void testValidPartyFunction() { + ObjectNode documentParties = rootNode.putObject("documentParties"); + ArrayNode otherParties = documentParties.putArray("other"); + ObjectNode otherParty = otherParties.addObject(); + otherParty.put("partyFunction", "SCO"); + + Set errors = VALID_PARTY_FUNCTION.validate(rootNode); + assertEquals(0, errors.size()); + + otherParty.put("partyFunction", "SSS"); + errors = VALID_PARTY_FUNCTION.validate(rootNode); + assertEquals(1, errors.size()); + } + + @Test + void testValidPartyFunctionHBL() { + ArrayNode houseBillOfLadings = rootNode.putArray("houseBillOfLadings"); + ObjectNode hbl = houseBillOfLadings.addObject(); + ObjectNode documentParties = hbl.putObject("documentParties"); + ArrayNode otherParties = documentParties.putArray("other"); + ObjectNode otherParty = otherParties.addObject(); + otherParty.put("partyFunction", "CS"); + + Set errors = VALID_PARTY_FUNCTION_HBL.validate(rootNode); + assertEquals(0, errors.size()); + + otherParty.put("partyFunction", "SSS"); + errors = VALID_PARTY_FUNCTION_HBL.validate(rootNode); + assertEquals(1, errors.size()); + } }