Skip to content

Commit

Permalink
DT-1125: Add/fix Beta-2 scenarios for EBL ISS and EBL SUR
Browse files Browse the repository at this point in the history
  • Loading branch information
nt-gt committed Apr 24, 2024
1 parent 777bd98 commit b67c3a2
Show file tree
Hide file tree
Showing 11 changed files with 3,422 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@

public class EblIssuanceComponentFactory extends AbstractComponentFactory {
public static final String STANDARD_NAME = "eBL Issuance";
public static final List<String> STANDARD_VERSIONS = List.of("2.0.0-Beta-1", "3.0.0-Beta-1");
public static final List<String> STANDARD_VERSIONS = List.of(
"2.0.0-Beta-1",
"3.0.0-Beta-1",
"3.0.0-Beta-2"
);

private static final String CARRIER_AUTH_HEADER_VALUE = UUID.randomUUID().toString();
private static final String PLATFORM_AUTH_HEADER_VALUE = UUID.randomUUID().toString();
Expand Down Expand Up @@ -120,10 +124,18 @@ public JsonSchemaValidator getMessageSchemaValidator(String apiProviderRole, boo
"/standards/eblissuance/schemas/eblissuance-v%s-%s.json"
.formatted(
standardVersion, apiProviderRole.toLowerCase());
String schemaName =
EblIssuanceRole.isCarrier(apiProviderRole)
? (forRequest ? "issuanceRequest" : null)
: (forRequest ? "issuanceResponse" : null);
String schemaName;
if (standardVersion.startsWith("2.") || standardVersion.equals("3.0.0-Beta-1")) {
schemaName = EblIssuanceRole.isCarrier(apiProviderRole)
? (forRequest ? "issuanceRequest" : null)
: (forRequest ? "issuanceResponse" : null);
} else {
schemaName = EblIssuanceRole.isCarrier(apiProviderRole)
? (forRequest ? "IssuanceRequest" : null)
: (forRequest ? "IssuanceResponse" : null);
}


return JsonSchemaValidator.getInstance(schemaFilePath, schemaName);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.dcsa.conformance.standards.eblissuance.checks;

import static org.dcsa.conformance.core.check.JsonAttribute.concatContextPath;
import static org.dcsa.conformance.standards.ebl.checks.EBLChecks.genericTDContentChecks;

import java.util.Set;
Expand All @@ -17,27 +18,48 @@

public class IssuanceChecks {

private static JsonRebaseableContentCheck hasEndorseeScenarioCheck(EblType eblType) {
private static JsonRebaseableContentCheck hasEndorseeScenarioCheck(String standardsVersion, EblType eblType) {
if (standardsVersion.startsWith("2.") || standardsVersion.equals("3.0.0-Beta-1")) {
return JsonAttribute.customValidator(
"[Scenario] Validate END party presence is correct",
JsonAttribute.path("document", JsonAttribute.path("documentParties",
(documentParties, contextPath) -> {
var hadEndorsee = false;
if (!eblType.isToOrder()) {
return Set.of();
}
for (var party : documentParties) {
if (party.path("partyFunction").asText("").equals("END")) {
hadEndorsee = true;
break;
}
}

if (eblType.isBlankEbl() && hadEndorsee) {
return Set.of("The EBL should have been blank endorsed, but it has an END party");
}
if (!eblType.isBlankEbl() && !hadEndorsee) {
return Set.of("The EBL should have had a named endorsee, but it is missing the END party");
}
return Set.of();
}
))
);
}
return JsonAttribute.customValidator(
"[Scenario] Validate END party presence is correct",
"[Scenario] Validate endorsee party presence is correct",
JsonAttribute.path("document", JsonAttribute.path("documentParties",
(documentParties, contextPath) -> {
var hadEndorsee = false;
if (!eblType.isToOrder()) {
return Set.of();
}
for (var party : documentParties) {
if (party.path("partyFunction").asText("").equals("END")) {
hadEndorsee = true;
break;
}
}

var hadEndorsee = documentParties.has("endorsee");
var endorseePath = concatContextPath(contextPath, "documentParties.endorsee");
if (eblType.isBlankEbl() && hadEndorsee) {
return Set.of("The EBL should have been blank endorsed, but it has an END party");
return Set.of("The EBL should have been blank endorsed, but it has an '%s' attribute".formatted(endorseePath));
}
if (!eblType.isBlankEbl() && !hadEndorsee) {
return Set.of("The EBL should have had a named endorsee, but it is missing the END party");
return Set.of("The EBL should have had a named endorsee, but it is missing the '%s' attribute".formatted(endorseePath));
}
return Set.of();
}
Expand All @@ -57,7 +79,7 @@ public static ActionCheck tdScenarioChecks(UUID matched, String standardsVersion
JsonPointer.compile("/document/isToOrder"),
eblType.isToOrder()
),
hasEndorseeScenarioCheck(eblType)
hasEndorseeScenarioCheck(standardsVersion, eblType)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,32 @@ private void sendIssuanceRequest(JsonNode actionPrompt) {
if (eblType.isToOrder()) {
var td = (ObjectNode)jsonRequestBody.path("document");
td.put("isToOrder", true);
var documentParties = (ArrayNode)td.path("documentParties");
var cnIdx = -1;
for (int i = 0 ; i < documentParties.size() ; i++) {
if (documentParties.path(i).path("partyFunction").asText("?").equals("CN")) {
cnIdx = i;
break;
if (apiVersion.startsWith("2.") || apiVersion.equals("3.0.0-Beta-1")) {
var documentParties = (ArrayNode)td.path("documentParties");
var cnIdx = -1;
for (int i = 0 ; i < documentParties.size() ; i++) {
if (documentParties.path(i).path("partyFunction").asText("?").equals("CN")) {
cnIdx = i;
break;
}
}
if (eblType.isBlankEbl()) {
documentParties.remove(cnIdx);
} else {
((ObjectNode)documentParties.path(cnIdx)).put("partyFunction", "END");
}
}
if (eblType.isBlankEbl()) {
documentParties.remove(cnIdx);
} else {
((ObjectNode)documentParties.path(cnIdx)).put("partyFunction", "END");
var documentParties = (ObjectNode)td.path("documentParties");
if (eblType.isBlankEbl()) {
documentParties.remove("consignee");
documentParties.remove("endorsee");
} else {
var consignee = documentParties.remove("consignee");
documentParties.set("endorsee", consignee);
}
}
}

if (!isCorrect) {
((ObjectNode) jsonRequestBody.get("document")).remove("issuingParty");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"document": {
"transportDocumentReference": "TRANSPORT_DOCUMENT_REFERENCE_PLACEHOLDER",
"shippingInstructionsReference": "SHIPPING_INSTRUCTION_REFERENCE_PLACEHOLDER",
"transportDocumentTypeCode": "BOL",
"freightPaymentTermCode": "PRE",
"isElectronic": true,
"isToOrder": false,
"invoicePayableAt": {
"locationType": "UNCO",
"UNLocationCode": "DKAAR"
},
"partyContactDetails": [
{
"name": "DCSA test person",
"email": "[email protected]"
}
],
"documentParties": {
"shipper": {
"partyName": "DCSA CTK",
"partyContactDetails": [
{
"name": "DCSA test person",
"email": "[email protected]"
}
]
},
"consignee": {
"partyName": "CONSIGNEE_LEGAL_NAME_PLACEHOLDER",
"partyCodes": [
{
"partyCode": "CONSIGNEE_PARTY_CODE_PLACEHOLDER",
"codeListProvider": "EPUI",
"codeListName": "CONSIGNEE_CODE_LIST_NAME_PLACEHOLDER"
}
],
"partyContactDetails": [
{
"name": "DCSA test person",
"email": "[email protected]"
}
]
},
"other": [
{
"party": {
"partyName": "DCSA CTK Service Contract Owner"
},
"partyFunction": "SCO"
}
]
},
"consignmentItems": [
{
"carrierBookingReference": "BOOKING_REFERENCE_PLACEHOLDER",
"weight": 12000,
"weightUnit": "KGM",
"descriptionOfGoods": "Shoes - black, 400 boxes",
"HSCodes": [
"640510"
],
"cargoItems": [
{
"equipmentReference": "NARU3472484",
"weight": 12000,
"weightUnit": "KGM",
"outerPackaging": {
"numberOfPackages": 400,
"packageCode": "4G",
"description": "Fibreboard boxes"
}
}
]
}
],
"utilizedTransportEquipments": [
{
"isShipperOwned": false,
"seals": [
{
"number": "DCSA-CTK-1234"
}
],
"cargoGrossWeight": 12000.0,
"cargoGrossWeightUnit": "KGM",
"equipment": {
"ISOEquipmentCode": "22G1",
"equipmentReference": "NARU3472484"
}
}
],
"isShippedOnBoardType": true,
"transportDocumentStatus": "ISSUED",
"cargoMovementTypeAtOrigin": "FCL",
"cargoMovementTypeAtDestination": "FCL",
"receiptTypeAtOrigin": "CY",
"deliveryTypeAtDestination": "CY",
"shippedOnBoardDate": "2023-12-19",
"termsAndConditions": "You agree that this transport document exist is name only for the sake of\ntesting your conformance with the DCSA EBL API. This transport document is NOT backed\nby a real shipment with ANY carrier and NONE of the requested services will be\ncarried out in real life.\n\nUnless required by applicable law or agreed to in writing, DCSA provides\nthis JSON data on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\nANY KIND, either express or implied, including, without limitation, any\nwarranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY,\nor FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for\ndetermining the appropriateness of using or redistributing this JSON\ndata and assume any risks associated with Your usage of this data.\n\nIn no event and under no legal theory, whether in tort (including negligence),\ncontract, or otherwise, unless required by applicable law (such as deliberate\nand grossly negligent acts) or agreed to in writing, shall DCSA be liable to\nYou for damages, including any direct, indirect, special, incidental, or\nconsequential damages of any character arising as a result of this terms or conditions\nor out of the use or inability to use the provided JSON data (including but not limited\nto damages for loss of goodwill, work stoppage, computer failure or malfunction, or any\nand all other commercial damages or losses), even if DCSA has been advised of the\npossibility of such damages.\n",
"issuingParty": {
"partyName": "Hyundai",
"address": {
"street": "The street name would be here",
"streetNumber": "... and here the street number",
"city": "... and here the city",
"countryCode": "KR"
},
"identifyingCodes": [
{
"codeListProvider": "SMDG",
"codeListName": "LCL",
"partyCode": "HMM"
}
]
},
"carrierCode": "HMM",
"carrierCodeListProvider": "SMDG",
"charges": [
{
"chargeName": "Fictive transport document fee",
"currencyAmount": 1.0,
"currencyCode": "EUR",
"paymentTermCode": "COL",
"calculationBasis": "Per transport document",
"unitPrice": 1.0,
"quantity": 1
}
],
"transports": {
"plannedDepartureDate": "2023-12-19",
"plannedArrivalDate": "2023-12-21",
"portOfLoading": {
"locationType": "UNCO",
"UNLocationCode": "DKAAR"
},
"portOfDischarge": {
"locationType": "UNLO",
"UNLocationCode": "DEBRV"
},
"vesselVoyage": [
{
"vesselName": "HMM Algeciras",
"carrierExportVoyageNumber": "402E"
}
]
}
},
"issueTo": {
"sendToPlatform": "SEND_TO_PLATFORM_PLACEHOLDER",
"partyName": "ISSUE_TO_LEGAL_NAME_PLACEHOLDER",
"partyCodes": [
{
"partyCode": "ISSUE_TO_PARTY_CODE_PLACEHOLDER",
"codeListProvider": "EPUI",
"codeListName": "ISSUE_TO_CODE_LIST_NAME_PLACEHOLDER"
}
]
}
}
Loading

0 comments on commit b67c3a2

Please sign in to comment.