Skip to content

Commit

Permalink
SD-603 Update PartyFunction EBL (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
palatsangeetha authored Dec 12, 2024
1 parent 71f9447 commit a41b072
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down Expand Up @@ -666,6 +668,19 @@ private static Consumer<MultiAttributeValidator> allDg(Consumer<MultiAttributeVa
JsonAttribute.mustBeAbsent(SI_REQUEST_SEND_TO_PLATFORM)),
JsonAttribute.mustBeAbsent(SI_REQUEST_SEND_TO_PLATFORM));

static final JsonRebaseableContentCheck VALID_PARTY_FUNCTION =
JsonAttribute.allIndividualMatchesMustBeValid(
"The partyFunction in OtherDocumentParty is valid",
mav -> 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<JsonContentCheck> STATIC_SI_CHECKS = Arrays.asList(
JsonAttribute.mustBeDatasetKeywordIfPresent(
SI_REQUEST_SEND_TO_PLATFORM,
Expand All @@ -684,6 +699,8 @@ private static Consumer<MultiAttributeValidator> allDg(Consumer<MultiAttributeVa
ROUTING_OF_CONSIGNMENT_COUNTRIES_CHECK,
VALID_REQUESTED_CARRIER_CLAUSES,
BUYER_AND_SELLER_CONDITIONAL_CHECK,
VALID_PARTY_FUNCTION,
VALID_PARTY_FUNCTION_HBL,
ONLY_EBLS_CAN_BE_NEGOTIABLE,
EBL_AT_MOST_ONE_COPY_WITHOUT_CHARGES,
EBL_AT_MOST_ONE_COPY_WITH_CHARGES,
Expand Down Expand Up @@ -811,7 +828,8 @@ private static Consumer<MultiAttributeValidator> allDg(Consumer<MultiAttributeVa
JsonAttribute.matchedMustBeDatasetKeywordIfPresent(MODE_OF_TRANSPORT)
),
NOTIFY_PARTIES_REQUIRED_IN_NEGOTIABLE_BLS,
TLR_CC_T_COMBINATION_UNIQUE
TLR_CC_T_COMBINATION_UNIQUE,
VALID_PARTY_FUNCTION
);

public static final JsonContentCheck SIR_REQUIRED_IN_NOTIFICATION = JsonAttribute.mustBePresent(SI_NOTIFICATION_SIR_PTR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,8 @@ public class EblDatasets {
"INTRANSITCLAUSE"
);

public static final KeywordDataset PARTY_FUNCTION_CODE =
KeywordDataset.staticDataset("SCO", "DDR", "DDS", "COW", "COX", "CS", "MF", "WH");
public static final KeywordDataset PARTY_FUNCTION_CODE_HBL =
KeywordDataset.staticDataset("DDR", "DDS", "CS", "MF", "WH");
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
},
"issueTo": {
"partyName": "DCSA CTK",
"identifyingCodes" : [
"identifyingCodes": [
{
"codeListProvider": "W3C",
"codeListName": "LCL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import static org.dcsa.conformance.standards.ebl.checks.EBLChecks.LOCATION_NAME_CONDITIONAL_VALIDATION_POA;
import static org.dcsa.conformance.standards.ebl.checks.EBLChecks.LOCATION_NAME_CONDITIONAL_VALIDATION_POFD;
import static org.dcsa.conformance.standards.ebl.checks.EBLChecks.VALID_CONSIGMENT_ITEMS_REFERENCE_TYPES;
import static org.dcsa.conformance.standards.ebl.checks.EBLChecks.VALID_PARTY_FUNCTION;
import static org.dcsa.conformance.standards.ebl.checks.EBLChecks.VALID_PARTY_FUNCTION_HBL;
import static org.dcsa.conformance.standards.ebl.checks.EBLChecks.VALID_REQUESTED_CARRIER_CLAUSES;
import static org.junit.jupiter.api.Assertions.assertEquals;

Expand Down Expand Up @@ -295,4 +297,36 @@ void testValidConsignmentItemsReferenceTypes() {
Set<String> 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<String> 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<String> 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());
}
}

0 comments on commit a41b072

Please sign in to comment.