Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SD-642 Adjust the isExportDeclarationRequired condition #244

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,13 @@ private static Consumer<MultiAttributeValidator> allDg(Consumer<MultiAttributeVa
return mav -> consumer.accept(mav.path("requestedEquipments").all().path("commodities").all().path("outerPackaging").path("dangerousGoods").all());
}

private static final JsonContentCheck IS_EXPORT_DECLARATION_REFERENCE_ABSENCE = JsonAttribute.ifThen(
"Check Export declaration reference absence",
JsonAttribute.isFalse("/isExportDeclarationRequired"),
static final JsonContentCheck IS_EXPORT_DECLARATION_REFERENCE_PRESENCE = JsonAttribute.ifThenElse(
"Check Export declaration reference presence",
JsonAttribute.isTrue(JsonPointer.compile("/isExportDeclarationRequired")),
JsonAttribute.mustBePresent(JsonPointer.compile("/exportDeclarationReference")),
JsonAttribute.mustBeAbsent(JsonPointer.compile("/exportDeclarationReference"))
);

private static final JsonContentCheck IS_IMPORT_DECLARATION_REFERENCE_ABSENCE = JsonAttribute.ifThen(
"Check Import declaration reference absence",
JsonAttribute.isFalse("/isImportLicenseRequired"),
JsonAttribute.mustBeAbsent(JsonPointer.compile("/importLicenseReference"))
);

private static final JsonRebaseableContentCheck DOCUMENT_PARTY_FUNCTIONS_MUST_BE_UNIQUE = JsonAttribute.customValidator(
"Each document party can be used at most once",
JsonAttribute.path(
Expand Down Expand Up @@ -630,8 +625,7 @@ private static void generateScenarioRelatedChecks(List<JsonContentCheck> checks,
NOR_PLUS_ISO_CODE_IMPLIES_ACTIVE_REEFER,
ISO_EQUIPMENT_CODE_AND_NOR_CHECK,
REFERENCE_TYPE_VALIDATION,
IS_EXPORT_DECLARATION_REFERENCE_ABSENCE,
IS_IMPORT_DECLARATION_REFERENCE_ABSENCE,
IS_EXPORT_DECLARATION_REFERENCE_PRESENCE,
DOCUMENT_PARTY_FUNCTIONS_MUST_BE_UNIQUE,
UNIVERSAL_SERVICE_REFERENCE,
VALIDATE_SHIPMENT_CUTOFF_TIME_CODE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"serviceContractReference": "SERVICE_CONTRACT_REFERENCE_PLACEHOLDER",
"carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER",
"carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER",
"isExportDeclarationRequired": true,
"isImportLicenseRequired": true,
"isEquipmentSubstitutionAllowed": true,
"carrierServiceCode": "TA1",
"vessel": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"serviceContractReference": "SERVICE_CONTRACT_REFERENCE_PLACEHOLDER",
"carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER",
"carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER",
"isExportDeclarationRequired": false,
"isImportLicenseRequired": false,
"isEquipmentSubstitutionAllowed": true,
"carrierServiceCode": "TA1",
"vessel": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"serviceContractReference": "SERVICE_CONTRACT_REFERENCE_PLACEHOLDER",
"carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER",
"carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER",
"isExportDeclarationRequired": true,
"isImportLicenseRequired": true,
"isEquipmentSubstitutionAllowed": true,
"vessel": {
"name": "King of the Seas"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"serviceContractReference": "SERVICE_CONTRACT_REFERENCE_PLACEHOLDER",
"carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER",
"carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER",
"isExportDeclarationRequired": true,
"isImportLicenseRequired": true,
"isEquipmentSubstitutionAllowed": true,
"carrierServiceCode": "TA1",
"vessel": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"serviceContractReference": "SERVICE_CONTRACT_REFERENCE_PLACEHOLDER",
"carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER",
"carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER",
"isExportDeclarationRequired": true,
"isImportLicenseRequired": true,
"isEquipmentSubstitutionAllowed": true,
"carrierServiceCode": "TA1",
"vessel": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"serviceContractReference": "SERVICE_CONTRACT_REFERENCE_PLACEHOLDER",
"carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER",
"carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER",
"isExportDeclarationRequired": true,
"isImportLicenseRequired": true,
"isEquipmentSubstitutionAllowed": true,
"carrierServiceCode": "TA1",
"vessel": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"serviceContractReference": "SERVICE_CONTRACT_REFERENCE_PLACEHOLDER",
"carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER",
"carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER",
"isExportDeclarationRequired": false,
"isImportLicenseRequired": false,
"isEquipmentSubstitutionAllowed": true,
"carrierServiceCode": "TA1",
"vessel": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"serviceContractReference": "SERVICE_CONTRACT_REFERENCE_PLACEHOLDER",
"carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER",
"carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER",
"isExportDeclarationRequired": false,
"isImportLicenseRequired": false,
"isEquipmentSubstitutionAllowed": true,
"carrierServiceCode": "TA1",
"vessel": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"serviceContractReference": "SERVICE_CONTRACT_REFERENCE_PLACEHOLDER",
"carrierExportVoyageNumber": "CARRIER_EXPORT_VOYAGE_NUMBER_PLACEHOLDER",
"carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER",
"isExportDeclarationRequired": false,
"isImportLicenseRequired": false,
"isEquipmentSubstitutionAllowed": true,
"carrierServiceCode": "TA1",
"vessel": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
"universalExportVoyageReference": "2103N",
"declaredValue": 1231.1,
"declaredValueCurrency": "EUR",
"isExportDeclarationRequired": true,
"exportDeclarationReference": "ABC123123",
"isImportLicenseRequired": true,
"importLicenseReference": "XYZ987987",
"expectedDepartureDate": "2064-10-17",
"expectedArrivalAtPlaceOfDeliveryStartDate": "2064-11-10",
"expectedArrivalAtPlaceOfDeliveryEndDate": "2064-11-15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import java.util.Set;

import static org.dcsa.conformance.core.toolkit.JsonToolkit.OBJECT_MAPPER;
import static org.dcsa.conformance.standards.booking.checks.BookingChecks.IS_EXPORT_DECLARATION_REFERENCE_PRESENCE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class BookingChecksTest {
Expand Down Expand Up @@ -93,4 +95,47 @@ void testCargoGrossWeightMissingInRequestedEquipmentsAndInOneOfTheCommodities_in
errors.contains(
"The 'requestedEquipments[0]' must have cargo gross weight at commodities position 0"));
}

@Test
void testIsExportDeclarationReferencePresence_requiredAndPresent() {
booking.put("isExportDeclarationRequired", true);
booking.put("exportDeclarationReference", "testReference");
Set<String> errors = IS_EXPORT_DECLARATION_REFERENCE_PRESENCE.validate(booking);
assertTrue(errors.isEmpty());
}

@Test
void testIsExportDeclarationReferencePresence_requiredAndAbsent() {
booking.put("isExportDeclarationRequired", true);
Set<String> errors = IS_EXPORT_DECLARATION_REFERENCE_PRESENCE.validate(booking);
assertEquals(1, errors.size());
}

@Test
void testIsExportDeclarationReferencePresence_notRequiredAndAbsent() {
booking.put("isExportDeclarationRequired", false);
Set<String> errors = IS_EXPORT_DECLARATION_REFERENCE_PRESENCE.validate(booking);
assertTrue(errors.isEmpty());
}

@Test
void testIsExportDeclarationReferencePresence_notRequiredAndPresent() {
booking.put("isExportDeclarationRequired", false);
booking.put("exportDeclarationReference", "testReferenceValue");
Set<String> errors = IS_EXPORT_DECLARATION_REFERENCE_PRESENCE.validate(booking);
assertEquals(1, errors.size());
}

@Test
void testIsExportDeclarationReferencePresence_missingFlagAndAbsent() {
Set<String> errors = IS_EXPORT_DECLARATION_REFERENCE_PRESENCE.validate(booking);
assertTrue(errors.isEmpty());
}

@Test
void testIsExportDeclarationReferencePresence_missingFlagAndPresent() {
booking.put("exportDeclarationReference", "testReference");
Set<String> errors = IS_EXPORT_DECLARATION_REFERENCE_PRESENCE.validate(booking);
assertEquals(1, errors.size());
}
}
Loading