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

DT-607 added sample request and booking schema. #7

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -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 UCI_SHIPPER_SUBMIT_BOOKING_REQUEST_ACTION = "UC1_Shipper_SubmitBookingRequestAction";

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,37 @@ 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 schemaFilePath = null;
if (schemaName.equals(BOOKING_NOTIFICATION_SCHEMA_NAME)) {
schemaFilePath = "/standards/booking/schemas/booking-%s-%s-%s.json"
.formatted(
"notification",standardVersion.startsWith("2") ? "v20" : "v30", apiProviderRole.toLowerCase());
}
nt-gt marked this conversation as resolved.
Show resolved Hide resolved
else {
schemaFilePath = "/standards/booking/schemas/booking-%s-%s.json"
.formatted(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.isCarrier(apiProviderRole)) {
if (forRequest) {
if (UCI_SHIPPER_SUBMIT_BOOKING_REQUEST_ACTION.equals(action)) {
schemaName = BOOKING_SCHEMA_NAME;
nt-gt marked this conversation as resolved.
Show resolved Hide resolved
}
else {
schemaName = BOOKING_NOTIFICATION_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 @@ -151,7 +151,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 @@ -165,7 +165,8 @@ private static BookingScenarioListBuilder uc1_shipper_SubmitBookingRequest() {
shipperPartyName,
(BookingAction) previousAction,
componentFactory.getMessageSchemaValidator(
BookingRole.SHIPPER.getConfigName(), true)));
BookingRole.SHIPPER.getConfigName(), true,
"UC1_Shipper_SubmitBookingRequestAction")));
}

private static BookingScenarioListBuilder uc2_carrier_requestUpdateToBookingRequest() {
Expand All @@ -179,7 +180,7 @@ private static BookingScenarioListBuilder uc2_carrier_requestUpdateToBookingRequ
shipperPartyName,
(BookingAction) previousAction,
componentFactory.getMessageSchemaValidator(
BookingRole.CARRIER.getConfigName(), true)));
BookingRole.CARRIER.getConfigName(), true,null)));
}

private static BookingScenarioListBuilder uc3_shipper_submitUpdatedBookingRequest() {
Expand All @@ -197,7 +198,7 @@ private static BookingScenarioListBuilder uc4_carrier_rejectBookingRequest() {
shipperPartyName,
(BookingAction) previousAction,
componentFactory.getMessageSchemaValidator(
BookingRole.CARRIER.getConfigName(), true)));
BookingRole.CARRIER.getConfigName(), true,null)));
}

private static BookingScenarioListBuilder uc5_carrier_confirmBookingRequest() {
Expand All @@ -211,7 +212,7 @@ private static BookingScenarioListBuilder uc5_carrier_confirmBookingRequest() {
shipperPartyName,
(BookingAction) previousAction,
componentFactory.getMessageSchemaValidator(
BookingRole.CARRIER.getConfigName(), true)));
BookingRole.CARRIER.getConfigName(), true,null)));
}

private static BookingScenarioListBuilder uc6_carrier_requestBookingAmendment() {
Expand Down Expand Up @@ -249,7 +250,7 @@ private static BookingScenarioListBuilder uc11_carrier_confirmBookingCompleted()
shipperPartyName,
(BookingAction) previousAction,
componentFactory.getMessageSchemaValidator(
BookingRole.CARRIER.getConfigName(), true)));
BookingRole.CARRIER.getConfigName(), true,null)));
}

private static BookingScenarioListBuilder uc12_shipper_cancelBooking() {
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
@@ -1,7 +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",
"TODO": "..."
"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"
}
]
}
Loading