diff --git a/booking/src/main/java/org/dcsa/conformance/standards/booking/action/Shipper_GetBookingAction.java b/booking/src/main/java/org/dcsa/conformance/standards/booking/action/Shipper_GetBookingAction.java index 20fce29d..32211da1 100644 --- a/booking/src/main/java/org/dcsa/conformance/standards/booking/action/Shipper_GetBookingAction.java +++ b/booking/src/main/java/org/dcsa/conformance/standards/booking/action/Shipper_GetBookingAction.java @@ -1,13 +1,10 @@ package org.dcsa.conformance.standards.booking.action; -import java.util.*; -import java.util.function.Function; + import java.util.stream.Stream; import com.fasterxml.jackson.databind.node.ObjectNode; import org.dcsa.conformance.core.check.*; -import org.dcsa.conformance.core.toolkit.JsonToolkit; -import org.dcsa.conformance.core.traffic.ConformanceExchange; import org.dcsa.conformance.core.traffic.HttpMessageType; import org.dcsa.conformance.standards.booking.checks.BookingChecks; import org.dcsa.conformance.standards.booking.checks.CarrierGetBookingPayloadResponseConformanceCheck; diff --git a/booking/src/main/java/org/dcsa/conformance/standards/booking/checks/BookingChecks.java b/booking/src/main/java/org/dcsa/conformance/standards/booking/checks/BookingChecks.java index 6806d3e7..e07da19b 100644 --- a/booking/src/main/java/org/dcsa/conformance/standards/booking/checks/BookingChecks.java +++ b/booking/src/main/java/org/dcsa/conformance/standards/booking/checks/BookingChecks.java @@ -77,34 +77,38 @@ public static ActionCheck requestContentChecks(UUID matched, Supplier { - String providedLocalDate = body.path("expectedDepartureDate").asText(""); + String expectedDepartureDate = body.path("expectedDepartureDate").asText(""); var invalidDates = new LinkedHashSet(); - LocalDate providedExpectedDepartureDate = LocalDate.parse(providedLocalDate); - if (providedExpectedDepartureDate.isBefore(LocalDate.now())) { - invalidDates.add(providedLocalDate); + if(!expectedDepartureDate.isEmpty()) { + LocalDate expectedDepartureLocalDate = LocalDate.parse(expectedDepartureDate); + if (expectedDepartureLocalDate.isBefore(LocalDate.now())) { + invalidDates.add(expectedDepartureLocalDate.toString()); + } } return invalidDates.stream() - .map("The expected departure date '%s' can not be paste date"::formatted) + .map("The expected departure date '%s' can not be paste date"::formatted) .collect(Collectors.toSet()); } ); private static final JsonContentCheck CHECK_EXPECTED_ARRIVAL_POD = JsonAttribute.customValidator( - "Check expected arrival dates can valid", + "Check expected arrival dates are valid", (body) -> { String providedArrivalStartDate = body.path("expectedArrivalAtPlaceOfDeliveryStartDate").asText(""); String providedArrivalEndDate = body.path("expectedArrivalAtPlaceOfDeliveryEndDate").asText(""); var invalidDates = new LinkedHashSet(); - LocalDate arrivalStartDate = LocalDate.parse(providedArrivalStartDate); - LocalDate arrivalEndDate = LocalDate.parse(providedArrivalEndDate); - if (arrivalStartDate.isAfter(arrivalEndDate)) { - invalidDates.add(arrivalStartDate.toString()); - } - if (arrivalEndDate.isBefore(arrivalStartDate)) { - invalidDates.add(arrivalEndDate.toString()); + if (!providedArrivalStartDate.isEmpty() && !providedArrivalEndDate.isEmpty()) { + LocalDate arrivalStartDate = LocalDate.parse(providedArrivalStartDate); + LocalDate arrivalEndDate = LocalDate.parse(providedArrivalEndDate); + if (arrivalStartDate.isAfter(arrivalEndDate)) { + invalidDates.add(arrivalStartDate.toString()); + } + if (arrivalEndDate.isBefore(arrivalStartDate)) { + invalidDates.add(arrivalEndDate.toString()); + } } return invalidDates.stream() - .map("The expected departure date '%s' can not be past date"::formatted) + .map("The expected arrival dates '%s' are valid"::formatted) .collect(Collectors.toSet()); } ); @@ -459,8 +463,8 @@ private static Supplier delayedValue(Supplier cspSupplier, Function private static void generateScenarioRelatedChecks(List checks, Supplier cspSupplier, Supplier dspSupplier) { checks.add(JsonAttribute.mustEqual( - "[Scenario] Verify that the correct 'serviceContractReference' is used", - "serviceContractReference", + "[Scenario] Verify that the correct 'carrierServiceName' is used", + "carrierServiceName", delayedValue(cspSupplier, CarrierScenarioParameters::carrierServiceName) )); checks.add(JsonAttribute.mustEqual( @@ -471,7 +475,7 @@ private static void generateScenarioRelatedChecks(List checks, checks.add(JsonAttribute.mustEqual( "[Scenario] Verify that the correct 'carrierExportVoyageNumber' is used", - "contractQuotationReference", + "carrierExportVoyageNumber", delayedValue(cspSupplier, CarrierScenarioParameters::carrierExportVoyageNumber) )); checks.add(JsonAttribute.allIndividualMatchesMustBeValid( @@ -483,7 +487,7 @@ private static void generateScenarioRelatedChecks(List checks, var nonOperatingReeferNode = nodeToValidate.path("isNonOperatingReefer"); var issues = new LinkedHashSet(); switch (scenario) { - case REEFER -> { + case REEFER, REEFER_TEMP_CHANGE -> { if (!activeReeferNode.isObject()) { issues.add("The scenario requires '%s' to have an active reefer".formatted(contextPath)); } @@ -598,9 +602,9 @@ private static void generateScenarioRelatedChecks(List checks, var charges = body.path("charges"); var issues = new LinkedHashSet(); for(JsonNode charge : charges) { - var chargeAmount = charge.get("chargeAmount").asDouble(); - if (BigDecimal.valueOf(chargeAmount).scale() > 2) { - issues.add("Charge amount %s is expected to have 2 decimal precious ".formatted(chargeAmount)); + var currencyAmount = charge.get("currencyAmount").asDouble(); + if (BigDecimal.valueOf(currencyAmount).scale() > 2) { + issues.add("Charge amount %s is expected to have 2 decimal precious ".formatted(currencyAmount)); } } return issues; diff --git a/booking/src/main/resources/standards/booking/datasets/segregationgroups.csv b/booking/src/main/resources/standards/booking/datasets/segregationgroups.csv new file mode 100644 index 00000000..cbe48a9c --- /dev/null +++ b/booking/src/main/resources/standards/booking/datasets/segregationgroups.csv @@ -0,0 +1,19 @@ +Segregation Group Code,Segregation Group Description +1,Acids +2,Ammonium Compounds +3,Bromates +4,Chlorates +5,Chlorites +6,Cyanides +7,Heavy metals and their salts +8,Hypochlorites +9,Lead and its compounds +10,Liquid halogenated hydrocarbons +11,Mercury and mercury compounds +12,Nitrites and their mixtures +13,Perchlorates +14,Permanganates +15,Powdered metals +16,Peroxides +17,Azides +18,Alkalis diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-dg.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-dg.json index 85575f07..d6c0ca4e 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-dg.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-dg.json @@ -3,6 +3,7 @@ "deliveryTypeAtDestination": "CY", "cargoMovementTypeAtOrigin": "FCL", "cargoMovementTypeAtDestination": "FCL", + "serviceContractReference": "SCR-1234-DG", "contractQuotationReference": "CONTRACT_QUOTATION_REFERENCE_PLACEHOLDER", "carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER", "carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER", @@ -77,7 +78,7 @@ } ] }, - "partyFunction": "BA", + "partyFunction": "CN", "isToBeNotified": false } ], diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-reefer-temp-change.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-reefer-temp-change.json index afc0b771..0d45f130 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-reefer-temp-change.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-reefer-temp-change.json @@ -3,6 +3,7 @@ "deliveryTypeAtDestination": "CY", "cargoMovementTypeAtOrigin": "FCL", "cargoMovementTypeAtDestination": "FCL", + "serviceContractReference": "SCR-1234-REEFER-TEMP", "contractQuotationReference": "CONTRACT_QUOTATION_REFERENCE_PLACEHOLDER", "carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER", "carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER", @@ -51,7 +52,7 @@ } ] }, - "partyFunction": "BA", + "partyFunction": "CN", "isToBeNotified": false } ], diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-reefer.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-reefer.json index 36d3f467..81587b5e 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-reefer.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-reefer.json @@ -3,6 +3,7 @@ "deliveryTypeAtDestination": "CY", "cargoMovementTypeAtOrigin": "FCL", "cargoMovementTypeAtDestination": "FCL", + "serviceContractReference": "SCR-1234-REEFER", "contractQuotationReference": "CONTRACT_QUOTATION_REFERENCE_PLACEHOLDER", "carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER", "carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER", @@ -51,7 +52,7 @@ } ] }, - "partyFunction": "BA", + "partyFunction": "CN", "isToBeNotified": false } ], diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-2re1c.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-2re1c.json index 27ebf764..f7556181 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-2re1c.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-2re1c.json @@ -3,6 +3,7 @@ "deliveryTypeAtDestination": "CY", "cargoMovementTypeAtOrigin": "FCL", "cargoMovementTypeAtDestination": "FCL", + "serviceContractReference": "SCR-1234-REGULAR-2RE1C", "contractQuotationReference": "CONTRACT_QUOTATION_REFERENCE_PLACEHOLDER", "carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER", "carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER", @@ -59,7 +60,7 @@ } ] }, - "partyFunction": "BA", + "partyFunction": "CN", "isToBeNotified": false } ], diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-2re2c.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-2re2c.json index 143d7356..2dfb9b6a 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-2re2c.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-2re2c.json @@ -3,6 +3,7 @@ "deliveryTypeAtDestination": "CY", "cargoMovementTypeAtOrigin": "FCL", "cargoMovementTypeAtDestination": "FCL", + "serviceContractReference": "SCR-1234-REGULAR-2RE2C", "contractQuotationReference": "CONTRACT_QUOTATION_REFERENCE_PLACEHOLDER", "carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER", "carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER", @@ -71,7 +72,7 @@ } ] }, - "partyFunction": "BA", + "partyFunction": "CN", "isToBeNotified": false } ], diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-cho-dest.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-cho-dest.json index 894ea3ef..a19680b9 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-cho-dest.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-cho-dest.json @@ -3,6 +3,7 @@ "deliveryTypeAtDestination": "SD", "cargoMovementTypeAtOrigin": "FCL", "cargoMovementTypeAtDestination": "FCL", + "serviceContractReference": "SCR-1234-REGULAR-CHO-DEST", "contractQuotationReference": "CONTRACT_QUOTATION_REFERENCE_PLACEHOLDER", "carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER", "carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER", @@ -46,7 +47,7 @@ } ] }, - "partyFunction": "BA", + "partyFunction": "CN", "isToBeNotified": false } ], diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-cho-orig.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-cho-orig.json index b450e5bf..c446317f 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-cho-orig.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-cho-orig.json @@ -3,6 +3,7 @@ "deliveryTypeAtDestination": "CY", "cargoMovementTypeAtOrigin": "FCL", "cargoMovementTypeAtDestination": "FCL", + "serviceContractReference": "SCR-1234-REGULAR-CHO-ORIG", "contractQuotationReference": "CONTRACT_QUOTATION_REFERENCE_PLACEHOLDER", "carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER", "carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER", @@ -46,7 +47,7 @@ } ] }, - "partyFunction": "BA", + "partyFunction": "CN", "isToBeNotified": false } ], diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-non-operating-reefer.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-non-operating-reefer.json index 53ef956f..702a7e45 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-non-operating-reefer.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-non-operating-reefer.json @@ -3,6 +3,7 @@ "deliveryTypeAtDestination": "CY", "cargoMovementTypeAtOrigin": "FCL", "cargoMovementTypeAtDestination": "FCL", + "serviceContractReference": "SCR-1234-REGULAR-NON-OP-REEFER", "contractQuotationReference": "CONTRACT_QUOTATION_REFERENCE_PLACEHOLDER", "carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER", "carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER", @@ -47,7 +48,7 @@ } ] }, - "partyFunction": "BA", + "partyFunction": "CN", "isToBeNotified": false } ], diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-shipper-owned.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-shipper-owned.json index 58dabc1c..fa2a5266 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-shipper-owned.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular-shipper-owned.json @@ -3,6 +3,7 @@ "deliveryTypeAtDestination": "CY", "cargoMovementTypeAtOrigin": "FCL", "cargoMovementTypeAtDestination": "FCL", + "serviceContractReference": "SCR-1234-REGULAR-SHIPPER-OWNED", "contractQuotationReference": "CONTRACT_QUOTATION_REFERENCE_PLACEHOLDER", "carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER", "carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER", @@ -46,7 +47,7 @@ } ] }, - "partyFunction": "BA", + "partyFunction": "CN", "isToBeNotified": false } ], diff --git a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular.json b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular.json index d720864b..cdfd6729 100644 --- a/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular.json +++ b/booking/src/main/resources/standards/booking/messages/booking-api-2.0.0-Beta-1-regular.json @@ -3,6 +3,7 @@ "deliveryTypeAtDestination": "CY", "cargoMovementTypeAtOrigin": "FCL", "cargoMovementTypeAtDestination": "FCL", + "serviceContractReference": "SCR-1234-REGULAR", "contractQuotationReference": "CONTRACT_QUOTATION_REFERENCE_PLACEHOLDER", "carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER", "carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER", @@ -46,7 +47,7 @@ } ] }, - "partyFunction": "BA", + "partyFunction": "CN", "isToBeNotified": false } ],