Skip to content

Commit

Permalink
Merge pull request #7 from dcsaorg/DT-607-Booking-conformance-UC1-shi…
Browse files Browse the repository at this point in the history
…pper-submit-booking-request

DT-607 added sample request and booking schema.
  • Loading branch information
nt-gt authored Nov 20, 2023
2 parents 4a2106c + d45856f commit bec6758
Show file tree
Hide file tree
Showing 11 changed files with 7,911 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public class BookingComponentFactory extends AbstractComponentFactory {
private static final String CARRIER_AUTH_HEADER_VALUE = UUID.randomUUID().toString();
private static final String SHIPPER_AUTH_HEADER_VALUE = UUID.randomUUID().toString();

private static final String UC1_SHIPPER_SUBMIT_BOOKING_REQUEST_ACTION = "UC1_SHIPPER_SUBMIT_BOOKING_REQUEST";

private static final String BOOKING_SCHEMA_NAME = "postBooking";

private static final String BOOKING_NOTIFICATION_SCHEMA_NAME = "BookingNotification";

private final String standardVersion;

public BookingComponentFactory(String standardVersion) {
Expand Down Expand Up @@ -113,19 +119,31 @@ public Set<String> getReportRoleNames(
.collect(Collectors.toSet());
}

public JsonSchemaValidator getMessageSchemaValidator(String apiProviderRole, boolean forRequest) {
String schemaFilePath =
"/standards/booking/schemas/booking-%s-%s.json"
.formatted(
standardVersion.startsWith("2") ? "v20" : "v30", apiProviderRole.toLowerCase());
String schemaName =
BookingRole.isCarrier(apiProviderRole)
? (forRequest ? "BookingNotification" : null)
: (forRequest ? "BookingNotification" : "BookingNotification");
public JsonSchemaValidator getMessageSchemaValidator(String apiProviderRole, boolean forRequest, String action) {
String schemaName = getSchemaName(apiProviderRole, forRequest, action);
String schemaSuffix = "api";
if (schemaName.equals(BOOKING_NOTIFICATION_SCHEMA_NAME)) {
schemaSuffix = "notification";
}
String schemaFilePath = "/standards/booking/schemas/booking-%s-%s-%s.json"
.formatted(schemaSuffix,standardVersion.startsWith("2") ? "v20" : "v30", apiProviderRole.toLowerCase());

return new JsonSchemaValidator(
BookingComponentFactory.class.getResourceAsStream(schemaFilePath), schemaName);
}

private String getSchemaName(String apiProviderRole, boolean forRequest, String action) {
String schemaName = BOOKING_NOTIFICATION_SCHEMA_NAME;
if (BookingRole.isShipper(apiProviderRole)) {
if (forRequest) {
if (UC1_SHIPPER_SUBMIT_BOOKING_REQUEST_ACTION.equals(action)) {
schemaName = BOOKING_SCHEMA_NAME;
}
}
}
return schemaName;
}

@SneakyThrows
public JsonNode getJsonSandboxConfigurationTemplate(
String testedPartyRole, boolean isManual, boolean isTestingCounterpartsConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

@Slf4j
public class BookingScenarioListBuilder extends ScenarioListBuilder<BookingScenarioListBuilder> {

private static final String UC1_SHIPPER_SUBMIT_BOOKING_REQUEST_ACTION = "UC1_SHIPPER_SUBMIT_BOOKING_REQUEST";
private static final ThreadLocal<BookingComponentFactory> threadLocalComponentFactory =
new ThreadLocal<>();
private static final ThreadLocal<String> threadLocalCarrierPartyName = new ThreadLocal<>();
Expand Down Expand Up @@ -154,7 +156,7 @@ private static BookingScenarioListBuilder shipper_GetBooking(BookingState expect
(BookingAction) previousAction,
expectedState,
componentFactory.getMessageSchemaValidator(
BookingRole.SHIPPER.getConfigName(), false)));
BookingRole.SHIPPER.getConfigName(), false, null)));
}

private static BookingScenarioListBuilder uc1_shipper_SubmitBookingRequest() {
Expand All @@ -168,7 +170,7 @@ private static BookingScenarioListBuilder uc1_shipper_SubmitBookingRequest() {
shipperPartyName,
(BookingAction) previousAction,
componentFactory.getMessageSchemaValidator(
BookingRole.SHIPPER.getConfigName(), true)));
BookingRole.SHIPPER.getConfigName(), true, UC1_SHIPPER_SUBMIT_BOOKING_REQUEST_ACTION)));
}

private static BookingScenarioListBuilder carrierStateChange(CarrierNotificationUseCase constructor) {
Expand All @@ -182,7 +184,7 @@ private static BookingScenarioListBuilder carrierStateChange(CarrierNotification
shipperPartyName,
(BookingAction) previousAction,
componentFactory.getMessageSchemaValidator(
BookingRole.CARRIER.getConfigName(), true))
BookingRole.CARRIER.getConfigName(), true, null))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void sendBookingRequest(JsonNode actionPrompt) {

JsonNode jsonRequestBody =
JsonToolkit.templateFileToJsonNode(
"/standards/booking/messages/booking-v20-request.json",
"/standards/booking/messages/booking-api-v20-request.json",
Map.ofEntries(
Map.entry(
"CARRIER_SERVICE_NAME_PLACEHOLDER",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"receiptTypeAtOrigin": "CY",
"deliveryTypeAtDestination": "CY",
"cargoMovementTypeAtOrigin": "FCL",
"cargoMovementTypeAtDestination": "FCL",
"vessel": {
"name": "King of the Seas",
"vesselIMONumber": "VESSEL_IMO_NUMBER_PLACEHOLDER"
},
"serviceContractReference": "serviceRef",
"carrierExportVoyageNumber": "2106W",
"carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER",
"declaredValue": 3.14,
"declaredValueCurrency": "DKK",
"isPartialLoadAllowed": true,
"isExportDeclarationRequired": true,
"exportDeclarationReference": "exportDeclarationRef",
"isImportLicenseRequired": true,
"importLicenseReference": "importLicenseRef",
"expectedDepartureDate": "2052-11-15",
"expectedArrivalAtPlaceOfDeliveryStartDate": "2052-11-15",
"expectedArrivalAtPlaceOfDeliveryEndDate": "2052-11-15",
"transportDocumentTypeCode": "BOL",
"transportDocumentReference": "transportDocumentRef",
"bookingChannelReference": "bookingChannelRef",
"incoTerms": "FOB",
"communicationChannelCode": "AO",
"isEquipmentSubstitutionAllowed": true,
"placeOfBLIssue": {
"locationName": "Asseco DK office",
"locationType": "ADDR",
"address": {
"name": "Asseco DK",
"street": "Kronprinsessegade",
"streetNumber": "54",
"floor": "5. sal",
"postCode": "1306",
"city": "København",
"country": "Denmark"
}
},
"requestedEquipments": [
{
"ISOEquipmentCode": "22G1",
"units": 1,
"isShipperOwned": false,
"commodities": [
{
"HSCodes": ["411510"],
"commodityType": "commodity type",
"cargoGrossWeight": 323.32,
"cargoGrossWeightUnit": "KGM",
"cargoGrossVolume": 100.0,
"cargoGrossVolumeUnit": "MTQ",
"outerPackaging": {
"packageCode" : "1A",
"imoPackagingCode": "A1222",
"numberOfPackages": 1,
"description": "steel"

},
"exportLicenseIssueDate": "2022-11-15",
"exportLicenseExpiryDate": "2023-05-15"
}
]
}
],
"references": [
{
"type": "AAO",
"value": "ref value"
}
],
"documentParties": [
{
"party": {
"partyName": "boring party",
"address": {
"name": "Asseco DK",
"street": "Kronprinsessegade",
"streetNumber": "54",
"floor": "5. sal",
"postCode": "1306",
"city": "København",
"country": "Denmark"
},
"partyContactDetails": [
{
"name": "Henrik",
"phone": "+31611444666"
}
],
"identifyingCodes": [
{
"DCSAResponsibleAgencyCode": "DCSA",
"partyCode": "reponsible fun",
"codeListName": "irreponsible fun"
}
]
},
"partyFunction": "BA",
"displayedAddress": [
"line1",
"line2"
],
"isToBeNotified": true
}
],
"shipmentLocations": [
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "NLRTM"
},
"shipmentLocationTypeCode": "POL",
"eventDateTime": "2022-11-15T10:34:41.99631016+01:00"
},
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "USMIA"
},
"shipmentLocationTypeCode": "POD",
"eventDateTime": "2022-11-15T10:34:41.99631016+01:00"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"receiptTypeAtOrigin": "CY",
"deliveryTypeAtDestination": "CY",
"cargoMovementTypeAtOrigin": "FCL",
"cargoMovementTypeAtDestination": "FCL",
"vessel": {
"name": "King of the Seas",
"vesselIMONumber": "VESSEL_IMO_NUMBER_PLACEHOLDER"
},
"serviceContractReference": "serviceRef",
"carrierExportVoyageNumber": "2106W",
"carrierServiceName": "CARRIER_SERVICE_NAME_PLACEHOLDER",
"declaredValue": 3.14,
"declaredValueCurrency": "DKK",
"isPartialLoadAllowed": true,
"isExportDeclarationRequired": true,
"exportDeclarationReference": "exportDeclarationRef",
"isImportLicenseRequired": true,
"importLicenseReference": "importLicenseRef",
"expectedDepartureDate": "2052-11-15",
"expectedArrivalAtPlaceOfDeliveryStartDate": "2052-11-15",
"expectedArrivalAtPlaceOfDeliveryEndDate": "2052-11-15",
"transportDocumentTypeCode": "BOL",
"transportDocumentReference": "transportDocumentRef",
"bookingChannelReference": "bookingChannelRef",
"incoTerms": "FOB",
"communicationChannelCode": "AO",
"isEquipmentSubstitutionAllowed": true,
"placeOfBLIssue": {
"locationName": "Asseco DK office",
"locationType": "ADDR",
"address": {
"name": "Asseco DK",
"street": "Kronprinsessegade",
"streetNumber": "54",
"floor": "5. sal",
"postCode": "1306",
"city": "København",
"country": "Denmark"
}
},
"requestedEquipments": [
{
"ISOEquipmentCode": "22G1",
"units": 1,
"isShipperOwned": false,
"commodities": [
{
"HSCodes": ["411510"],
"commodityType": "commodity type",
"cargoGrossWeight": 323.32,
"cargoGrossWeightUnit": "KGM",
"cargoGrossVolume": 100.0,
"cargoGrossVolumeUnit": "MTQ",
"outerPackaging": {
"packageCode" : "1A",
"imoPackagingCode": "A1222",
"numberOfPackages": 1,
"description": "steel"

},
"exportLicenseIssueDate": "2022-11-15",
"exportLicenseExpiryDate": "2023-05-15"
}
]
}
],
"references": [
{
"type": "AAO",
"value": "ref value"
}
],
"documentParties": [
{
"party": {
"partyName": "boring party",
"address": {
"name": "Asseco DK",
"street": "Kronprinsessegade",
"streetNumber": "54",
"floor": "5. sal",
"postCode": "1306",
"city": "København",
"country": "Denmark"
},
"partyContactDetails": [
{
"name": "Henrik",
"phone": "+31611444666"
}
],
"identifyingCodes": [
{
"DCSAResponsibleAgencyCode": "DCSA",
"partyCode": "reponsible fun",
"codeListName": "irreponsible fun"
}
]
},
"partyFunction": "BA",
"displayedAddress": [
"line1",
"line2"
],
"isToBeNotified": true
}
],
"shipmentLocations": [
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "NLRTM"
},
"shipmentLocationTypeCode": "POL",
"eventDateTime": "2022-11-15T10:34:41.99631016+01:00"
},
{
"location": {
"locationType": "UNLO",
"UNLocationCode": "USMIA"
},
"shipmentLocationTypeCode": "POD",
"eventDateTime": "2022-11-15T10:34:41.99631016+01:00"
}
]
}

This file was deleted.

Loading

0 comments on commit bec6758

Please sign in to comment.