Skip to content

Commit

Permalink
Backporting fix for issue #3
Browse files Browse the repository at this point in the history
Fixing NPE when XFWB comes without SpecifiedLogisticsTransportMovement.StageCode.ModeCode value
  • Loading branch information
mskopp committed Nov 23, 2021
1 parent 0278470 commit 1b448c5
Show file tree
Hide file tree
Showing 3 changed files with 317 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ private void convertCIMPSegment03to04Flights() {
// ModeCode is the same in 1R+XFWB, so we apply 1:1
// In XFWB, ModeCode="4" means "Air transport"
// In XFWB, there is also a ltm.getMode() with value "Air transport"
tm.setModeCode(ltm.getModeCode().getValue());
if (ltm.getModeCode() != null) {
tm.setModeCode(ltm.getModeCode().getValue());
}
tm.setModeQualifier(value(ltm.getStageCode()));
if (ltm.getDepartureEvent() != null) {
tm.setDepartureLocation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,48 @@ public void test88811111111() throws JAXBException, JsonProcessingException {
Assertions.assertTrue(json.contains("Piece#goodsDescription\" : \"CONSOLIDATION\\nAS PER ATTACHED\\nMANIFEST\\nSECURE CARGO\\nNOT RESTRICTED\\nAIRLINE PHARMA\\nSERVICE\""));
}

@Test
public void test88811111111noModeCode() throws JAXBException, JsonProcessingException {
String filename = "888-11111111_XFWB_noModeCode.xml";

InputStream is;
WaybillType xfwb;
XFWB3toOneRecordConverter converter;
String awb;

ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
// mapper.disable(SerializationFeature.WRAP_ROOT_VALUE);
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"));

is = ClassLoader.getSystemResourceAsStream(filename);
xfwb = new ConverterUtil().unmarshalXFWB3(is);
awb = xfwb.getBusinessHeaderDocument().getID().getValue();
converter = new XFWB3toOneRecordConverter(xfwb);

Assertions.assertNotNull(converter.getValidationHints());
Assertions.assertFalse(converter.getValidationHints().isEmpty());
for (ValidationMessage msg : converter.getValidationHints()) {
System.out.println(awb + " HINT: " + msg.getMessage());
}

Assertions.assertNotNull(converter.getValidationWarnings());
Assertions.assertFalse(converter.getValidationWarnings().isEmpty());
for (ValidationMessage msg : converter.getValidationWarnings()) {
System.out.println(awb + " WARNING: " + msg.getMessage());
}

Assertions.assertNotNull(converter.getValidationErrors());
Assertions.assertTrue(converter.getValidationErrors().isEmpty());
for (ValidationMessage msg : converter.getValidationErrors()) {
System.out.println(awb + " ERROR: " + msg.getMessage());
}

String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(converter.getOneRecordResult());
System.out.println(awb + " JSON=\n" + json);
Assertions.assertTrue(json.contains("customsInfoNote\" : \"USCI1234567812345678X7\""));
Assertions.assertTrue(json.contains("Piece#goodsDescription\" : \"CONSOLIDATION\\nAS PER ATTACHED\\nMANIFEST\\nSECURE CARGO\\nNOT RESTRICTED\\nAIRLINE PHARMA\\nSERVICE\""));
}

}
270 changes: 270 additions & 0 deletions src/test/resources/888-11111111_XFWB_noModeCode.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:Waybill xmlns="iata:datamodel:3" xmlns:ns6="urn:un:unece:uncefact:codelist:standard:IANA:MIMEMediaType:2009-09-01" xmlns:ns5="urn:un:unece:uncefact:codelist:standard:UNECE:TransportModeCode:2" xmlns:ns8="urn:un:unece:uncefact:codelist:standard:6:Recommendation20:6" xmlns:ns7="urn:un:unece:uncefact:codelist:standard:6:0133:40106" xmlns:ns9="urn:un:unece:uncefact:codelist:standard:UNECE:DocumentNameCode:D09A" xmlns:ns12="urn:un:unece:uncefact:codelist:standard:5:ISO42173A:2009-09-09" xmlns:ns11="urn:un:unece:uncefact:identifierlist:standard:5:ISO316612A:SecondEdition2006VI-6" xmlns:ns10="urn:un:unece:uncefact:codelist:standard:6:3055:D09A" xmlns:ns2="iata:waybill:1" xmlns:ns4="urn:un:unece:uncefact:codelist:standard:IANA:CharacterSetCode:2007-05-14" xmlns:ns3="urn:un:unece:uncefact:codelist:standard:UNECE:PartyRoleCode:D09A">
<ns2:MessageHeaderDocument>
<ID>888-11111111_6c763819-1067-43fe-acf7-db4daf4f77cf</ID>
<Name>Master Air Waybill</Name>
<TypeCode>741</TypeCode>
<IssueDateTime>2021-03-10T11:00:00+01:00</IssueDateTime>
<PurposeCode>Creation</PurposeCode>
<VersionID>3.00</VersionID>
<SenderParty>
<PrimaryID schemeID="C">RIEGESOFTWARE</PrimaryID>
</SenderParty>
<SenderParty>
<PrimaryID schemeID="P">REUAGT88FORWARDER/FRA01</PrimaryID>
</SenderParty>
<RecipientParty>
<PrimaryID schemeID="C">CCSPROVIDERNAME</PrimaryID>
</RecipientParty>
</ns2:MessageHeaderDocument>
<ns2:BusinessHeaderDocument>
<ID>888-11111111</ID>
<SenderAssignedID>FRA8117142550</SenderAssignedID>
<IncludedHeaderNote>
<ContentCode>C</ContentCode>
<Content>Consolidation Shipment</Content>
</IncludedHeaderNote>
<SignatoryCarrierAuthentication>
<ActualDateTime>2021-03-10T00:00:00</ActualDateTime>
<Signatory>MARK USER</Signatory>
<IssueAuthenticationLocation>
<Name>ORK</Name>
</IssueAuthenticationLocation>
</SignatoryCarrierAuthentication>
</ns2:BusinessHeaderDocument>
<ns2:MasterConsignment>
<ID>8112345678</ID>
<NilCarriageValueIndicator>true</NilCarriageValueIndicator>
<NilCustomsValueIndicator>true</NilCustomsValueIndicator>
<NilInsuranceValueIndicator>true</NilInsuranceValueIndicator>
<TotalChargePrepaidIndicator>true</TotalChargePrepaidIndicator>
<TotalDisbursementPrepaidIndicator>true</TotalDisbursementPrepaidIndicator>
<IncludedTareGrossWeightMeasure unitCode="KGM">1042.0</IncludedTareGrossWeightMeasure>
<GrossVolumeMeasure unitCode="MTQ">2.602</GrossVolumeMeasure>
<TotalPieceQuantity>3</TotalPieceQuantity>
<ConsignorParty>
<Name>FORWARDER COMPANY IRELAND LTD</Name>
<AccountID>SHP_ACCOUNT_NO_1234</AccountID>
<PostalStructuredAddress>
<PostcodeCode>ABCD</PostcodeCode>
<StreetName>HARBOUR POINT BUSINESS PARK</StreetName>
<CityName>LITTLE CITY</CityName>
<CountryID>IE</CountryID>
</PostalStructuredAddress>
<DefinedTradeContact>
<DirectTelephoneCommunication>
<CompleteNumber>353123456789</CompleteNumber>
</DirectTelephoneCommunication>
</DefinedTradeContact>
</ConsignorParty>
<ConsigneeParty>
<Name>FORWARDER COMPANY SHANGHAI LTD
ROOM 123 SPECIAL BUILDING. NR 987</Name>
<PostalStructuredAddress>
<StreetName>SUHANG RD. PUDONG AIRPORT
AIRPORT ROAD</StreetName>
<CityName>SHANGHAI</CityName>
<CountryID>CN</CountryID>
<CountryName>People's Republic of China</CountryName>
</PostalStructuredAddress>
<DefinedTradeContact>
<DirectTelephoneCommunication>
<CompleteNumber>861234567890</CompleteNumber>
</DirectTelephoneCommunication>
</DefinedTradeContact>
</ConsigneeParty>
<FreightForwarderParty>
<Name>FORWARDER COMPANY IRELAND LIMITED</Name>
<AccountID>87654321</AccountID>
<CargoAgentID>3456789</CargoAgentID>
<FreightForwarderAddress>
<PostcodeCode>ABCD</PostcodeCode>
<StreetName>Harbour Point Business Part</StreetName>
<CityName>Little City</CityName>
<CountryID>IE</CountryID>
</FreightForwarderAddress>
<SpecifiedCargoAgentLocation>
<ID>0123</ID>
</SpecifiedCargoAgentLocation>
<DefinedTradeContact>
<DirectTelephoneCommunication>
<CompleteNumber>353987654321</CompleteNumber>
</DirectTelephoneCommunication>
</DefinedTradeContact>
</FreightForwarderParty>
<OriginLocation>
<ID>ORK</ID>
</OriginLocation>
<FinalDestinationLocation>
<ID>PVG</ID>
</FinalDestinationLocation>
<SpecifiedLogisticsTransportMovement>
<StageCode>Main-Carriage</StageCode>
<Mode>Air transport</Mode>
<ID>XX8012</ID>
<SequenceNumeric>1</SequenceNumeric>
<UsedLogisticsTransportMeans>
<Name>XX</Name>
</UsedLogisticsTransportMeans>
<ArrivalEvent>
<OccurrenceArrivalLocation>
<ID>DUB</ID>
<TypeCode>Airport</TypeCode>
</OccurrenceArrivalLocation>
</ArrivalEvent>
<DepartureEvent>
<ScheduledOccurrenceDateTime>2021-03-10T00:00:00</ScheduledOccurrenceDateTime>
<OccurrenceDepartureLocation>
<ID>ORK</ID>
<TypeCode>Airport</TypeCode>
</OccurrenceDepartureLocation>
</DepartureEvent>
</SpecifiedLogisticsTransportMovement>
<SpecifiedLogisticsTransportMovement>
<StageCode>Main-Carriage</StageCode>
<Mode>Air transport</Mode>
<ID>XX345</ID>
<SequenceNumeric>2</SequenceNumeric>
<UsedLogisticsTransportMeans>
<Name>XX</Name>
</UsedLogisticsTransportMeans>
<ArrivalEvent>
<OccurrenceArrivalLocation>
<ID>AUH</ID>
<TypeCode>Airport</TypeCode>
</OccurrenceArrivalLocation>
</ArrivalEvent>
<DepartureEvent>
<ScheduledOccurrenceDateTime>2021-03-12T00:00:00</ScheduledOccurrenceDateTime>
<OccurrenceDepartureLocation>
<ID>DUB</ID>
<TypeCode>Airport</TypeCode>
</OccurrenceDepartureLocation>
</DepartureEvent>
</SpecifiedLogisticsTransportMovement>
<HandlingSPHInstructions>
<DescriptionCode>NSC</DescriptionCode>
</HandlingSPHInstructions>
<HandlingOSIInstructions>
<Description>4 PALLETS</Description>
</HandlingOSIInstructions>
<HandlingOSIInstructions>
<Description>TEMPERATURE CONTROL 15 TO 25 DEGREES CELSIUS</Description>
</HandlingOSIInstructions>
<HandlingOSIInstructions>
<Description>HANDLE WITH CARE</Description>
</HandlingOSIInstructions>
<IncludedCustomsNote>
<ContentCode>T</ContentCode>
<Content>IE1234567N</Content>
<SubjectCode>SHP</SubjectCode>
<CountryID>IE</CountryID>
</IncludedCustomsNote>
<IncludedCustomsNote>
<ContentCode>CP</ContentCode>
<Content>HILDA HILARIOUS</Content>
<SubjectCode>SHP</SubjectCode>
<CountryID>IE</CountryID>
</IncludedCustomsNote>
<IncludedCustomsNote>
<ContentCode>CT</ContentCode>
<Content>353123454321</Content>
<SubjectCode>SHP</SubjectCode>
<CountryID>IE</CountryID>
</IncludedCustomsNote>
<IncludedCustomsNote>
<ContentCode>T</ContentCode>
<Content>USCI1234567812345678X7</Content>
<SubjectCode>CNE</SubjectCode>
<CountryID>CN</CountryID>
</IncludedCustomsNote>
<IncludedCustomsNote>
<ContentCode>CP</ContentCode>
<Content>PAUL PERSON</Content>
<SubjectCode>CNE</SubjectCode>
<CountryID>CN</CountryID>
</IncludedCustomsNote>
<IncludedCustomsNote>
<ContentCode>CT</ContentCode>
<Content>862123454321</Content>
<SubjectCode>CNE</SubjectCode>
<CountryID>CN</CountryID>
</IncludedCustomsNote>
<IncludedCustomsNote>
<ContentCode>RA</ContentCode>
<Content>01234-01</Content>
<SubjectCode>ISS</SubjectCode>
<CountryID>IE</CountryID>
</IncludedCustomsNote>
<IncludedCustomsNote>
<ContentCode>ED</ContentCode>
<Content>1299</Content>
</IncludedCustomsNote>
<AssociatedConsignmentCustomsProcedure>
<GoodsStatusCode>X</GoodsStatusCode>
</AssociatedConsignmentCustomsProcedure>
<ApplicableOriginCurrencyExchange>
<SourceCurrencyCode>EUR</SourceCurrencyCode>
</ApplicableOriginCurrencyExchange>
<ApplicableLogisticsServiceCharge/>
<ApplicableLogisticsAllowanceCharge>
<ID>MC</ID>
<PrepaidIndicator>true</PrepaidIndicator>
<PartyTypeCode>C</PartyTypeCode>
<ActualAmount currencyID="EUR">1234.56</ActualAmount>
</ApplicableLogisticsAllowanceCharge>
<ApplicableRating>
<TypeCode>F</TypeCode>
<ConsignmentItemQuantity>1</ConsignmentItemQuantity>
<IncludedMasterConsignmentItem>
<SequenceNumeric>1</SequenceNumeric>
<TypeCode>000111</TypeCode>
<GrossWeightMeasure unitCode="KGM">1042.0</GrossWeightMeasure>
<GrossVolumeMeasure unitCode="CMQ">2602000</GrossVolumeMeasure>
<PackageQuantity>333</PackageQuantity>
<PieceQuantity>3</PieceQuantity>
<NatureIdentificationTransportCargo>
<Identification>CONSOLIDATION
AS PER ATTACHED
MANIFEST
SECURE CARGO
NOT RESTRICTED
AIRLINE PHARMA
SERVICE</Identification>
</NatureIdentificationTransportCargo>
<TransportLogisticsPackage>
<ItemQuantity>2</ItemQuantity>
<LinearSpatialDimension>
<WidthMeasure unitCode="CMT">80</WidthMeasure>
<LengthMeasure unitCode="CMT">120</LengthMeasure>
<HeightMeasure unitCode="CMT">96</HeightMeasure>
</LinearSpatialDimension>
</TransportLogisticsPackage>
<TransportLogisticsPackage>
<ItemQuantity>1</ItemQuantity>
<LinearSpatialDimension>
<WidthMeasure unitCode="CMT">80</WidthMeasure>
<LengthMeasure unitCode="CMT">120</LengthMeasure>
<HeightMeasure unitCode="CMT">79</HeightMeasure>
</LinearSpatialDimension>
</TransportLogisticsPackage>
<ApplicableFreightRateServiceCharge>
<CategoryCode>Q</CategoryCode>
<ChargeableWeightMeasure unitCode="KGM">1042.0</ChargeableWeightMeasure>
<AppliedRate>4.44</AppliedRate>
<AppliedAmount currencyID="EUR">4626.48</AppliedAmount>
</ApplicableFreightRateServiceCharge>
</IncludedMasterConsignmentItem>
</ApplicableRating>
<ApplicableTotalRating>
<TypeCode>F</TypeCode>
<ApplicablePrepaidCollectMonetarySummation>
<PrepaidIndicator>true</PrepaidIndicator>
<WeightChargeTotalAmount currencyID="EUR">4626.48</WeightChargeTotalAmount>
<TaxTotalAmount currencyID="EUR">11.22</TaxTotalAmount>
<CarrierTotalDuePayableAmount currencyID="EUR">222.33</CarrierTotalDuePayableAmount>
<GrandTotalAmount currencyID="EUR">4860.03</GrandTotalAmount>
</ApplicablePrepaidCollectMonetarySummation>
</ApplicableTotalRating>
</ns2:MasterConsignment>
</ns2:Waybill>

0 comments on commit 1b448c5

Please sign in to comment.