From b7223a1c9e99eb45d5e83bd041ca97c15b151a37 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Mon, 12 Apr 2021 19:22:00 +0200 Subject: included open ticket test --- .../ticket/api/test/OpenTicketComplexTestV1.java | 89 +++++ .../ticket/api/test/OpenTicketComplexTestV2.java | 96 +++++ .../test/testtickets/CustomerCardTestTicketV1.java | 1 + .../test/testtickets/CustomerCardTestTicketV2.java | 4 +- .../test/testtickets/OpenTestComplexTicketV1.java | 401 ++++++++++++++++++++ .../test/testtickets/OpenTestComplexTicketV2.java | 411 +++++++++++++++++++++ 6 files changed, 1001 insertions(+), 1 deletion(-) create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV1.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV2.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/testtickets/OpenTestComplexTicketV1.java create mode 100644 src/test/java/org/uic/barcode/ticket/api/test/testtickets/OpenTestComplexTicketV2.java (limited to 'src/test') diff --git a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV1.java new file mode 100644 index 0000000..4b1d61e --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV1.java @@ -0,0 +1,89 @@ +package org.uic.barcode.ticket.api.test; + +import java.text.ParseException; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData; +import org.uic.barcode.ticket.api.test.testtickets.OpenTestComplexTicketV1; + + + +/** + * The Class FipTimeZoneTestV1. + * + * + * + */ +public class OpenTicketComplexTestV1 { + + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void decoding() { + + //get tickets + String hex = OpenTestComplexTicketV1.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + ticket = OpenTestComplexTicketV1.getUicTestTicket(); + byte[] encoded = UperEncoder.encode(ticket); + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = OpenTestComplexTicketV1.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } + + +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV2.java b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV2.java new file mode 100644 index 0000000..da167c4 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV2.java @@ -0,0 +1,96 @@ +package org.uic.barcode.ticket.api.test; + +import java.text.ParseException; +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData; +import org.uic.barcode.ticket.api.test.testtickets.OpenTestComplexTicketV2; + + + +/** + * The Class FipTimeZoneTestV2. + * + * + * + */ +public class OpenTicketComplexTestV2 { + + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + + /** + * Test encode test tickets in UTC and decode in CET. + * + * @throws IllegalArgumentException the illegal argument exception + * @throws IllegalAccessException the illegal access exception + * @throws ParseException + */ + @Test public void decoding() { + + //get tickets + String hex = OpenTestComplexTicketV2.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + String hex = OpenTestComplexTicketV2.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + + //ticket = OpenTestComplexTicketV2.getUicTestTicket(); + byte[] encoded = UperEncoder.encode(ticket); + + + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = OpenTestComplexTicketV2.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } + + +} diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CustomerCardTestTicketV1.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CustomerCardTestTicketV1.java index 09faac8..89cfb55 100644 --- a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CustomerCardTestTicketV1.java +++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CustomerCardTestTicketV1.java @@ -115,6 +115,7 @@ import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData; tr.setIdCard("12345"); tr.setFirstName("John"); tr.setSecondName("Dow"); + tr.setYearOfBirth(1990L); tr.setDayOfBirth(100L); tr.setGender(GenderType.male); tr.setIdCard("IEDZ235FT"); diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CustomerCardTestTicketV2.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CustomerCardTestTicketV2.java index 7f01b94..9630169 100644 --- a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CustomerCardTestTicketV2.java +++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CustomerCardTestTicketV2.java @@ -115,7 +115,9 @@ import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData; tr.setIdCard("12345"); tr.setFirstName("John"); tr.setSecondName("Dow"); - tr.setDayOfBirth(100L); + tr.setYearOfBirth(1990L); + tr.setMonthOfBirth(1L); + tr.setDayOfBirth(21L); tr.setGender(GenderType.male); tr.setIdCard("IEDZ235FT"); return tr; diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/OpenTestComplexTicketV1.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/OpenTestComplexTicketV1.java new file mode 100644 index 0000000..90c6861 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/OpenTestComplexTicketV1.java @@ -0,0 +1,401 @@ +package org.uic.barcode.ticket.api.test.testtickets; + +import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8; +import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong; +import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType; +import org.uic.barcode.ticket.api.asn.omv1.ControlData; +import org.uic.barcode.ticket.api.asn.omv1.CustomerStatusType; +import org.uic.barcode.ticket.api.asn.omv1.DocumentData; +import org.uic.barcode.ticket.api.asn.omv1.ExtensionData; +import org.uic.barcode.ticket.api.asn.omv1.IncludedOpenTicketType; +import org.uic.barcode.ticket.api.asn.omv1.IssuingData; +import org.uic.barcode.ticket.api.asn.omv1.LinkMode; +import org.uic.barcode.ticket.api.asn.omv1.OpenTicketData; +import org.uic.barcode.ticket.api.asn.omv1.PassengerType; +import org.uic.barcode.ticket.api.asn.omv1.RegionalValidityType; +import org.uic.barcode.ticket.api.asn.omv1.RouteSectionType; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCardReferenceType; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCustomerStatusType; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfDocumentData; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfExtensionData; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfIncludedOpenTicketType; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfRegionalValidityType; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTariffType; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTicketLinkType; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTravelerType; +import org.uic.barcode.ticket.api.asn.omv1.SequenceOfVatDetail; +import org.uic.barcode.ticket.api.asn.omv1.StationPassageData; +import org.uic.barcode.ticket.api.asn.omv1.TariffType; +import org.uic.barcode.ticket.api.asn.omv1.TicketDetailData; +import org.uic.barcode.ticket.api.asn.omv1.TicketLinkType; +import org.uic.barcode.ticket.api.asn.omv1.TicketType; +import org.uic.barcode.ticket.api.asn.omv1.TokenType; +import org.uic.barcode.ticket.api.asn.omv1.TravelClassType; +import org.uic.barcode.ticket.api.asn.omv1.TravelerData; +import org.uic.barcode.ticket.api.asn.omv1.TravelerType; +import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData; +import org.uic.barcode.ticket.api.asn.omv1.VatDetailType; +import org.uic.barcode.ticket.api.asn.omv1.ZoneType; + + + public class OpenTestComplexTicketV1 { + + public static UicRailTicketData getUicTestTicket() { + UicRailTicketData ticket = new UicRailTicketData(); + populateTicket(ticket); + return ticket; + } + + /* + value UicRailTicketData ::= { + issuingDetail { + issuingYear 2018 + issuingDay 1 + specimen TRUE, + securePaperTicket FALSE, + activated TRUE, + issuerPNR "issuerTestPNR", + issuedOnLine 12 + } + ,travelerDetail{ + traveler { + { + firstName "John" + ,secondName "Dow" + ,idCard "12345" + ,ticketHolder TRUE + ,status {{customerStatusDescr "senior" }} + } + } + ,groupName "myGroup" + } + ,transportDocument { + { + token {tokenProviderIA5 "VDV", token '82DA'H } + ,ticket openTicket : { + returnIncluded FALSE + ,classCode first + ,vatDetail { + { country 80 + ,percentage 70 + ,amount 10 + ,vatId "IUDGTE" + } + } + ,infoText "openTicketInfo" + ,includedAddOns { + { productOwnerNum 1080 + ,validRegion { zones : { zoneId { 100 } } } + ,validFromDay 0 + ,validFromTime 1000 + ,validUntilDay 1 + ,validUntilTime 1000 + ,classCode second + ,tariffs { + { numberOfPassengers 2 + ,passengerType adult + ,restrictedToCountryOfResidence FALSE + ,restrictedToRouteSection { fromStationNum 8000001 , toStationNum 8010000 } + } + } + ,infoText "included ticket" + } + } + } + } + ,{ + ticket stationPassage : { + productName "passage" + ,stationNameUTF8 { "Amsterdam" } + ,validFromDay 0 + ,numberOfDaysValid 123 + } + } + } + ,controlDetail { + identificationByCardReference { + { trailingCardIdNum 100 } + } + ,identificationByIdCard FALSE + ,identificationByPassportId FALSE + ,passportValidationRequired FALSE + ,onlineValidationRequired FALSE + ,ageCheckRequired FALSE + ,reductionCardCheckRequired FALSE + ,infoText "cd" + ,includedTickets { + { referenceIA5 "UED12435867" + ,issuerName "OEBB" + ,issuerPNR "PNR" + ,productOwnerIA5 "test" + ,ticketType pass + ,linkMode onlyValidInCombination + + } + } + } + ,extension { + { extensionId "1", extensionData '82DA'H } + ,{ extensionId "2", extensionData '83DA'H } + } + } + */ + + + + public static String getEncodingHex() { + return "78022020050DD3CF9F5CBCAA65E7D284EA40218A02D000822537B43701A237BB" + + "82B164CDA358088373CBBB4EFE40EDAF28EE4DEEAE004A03AD12B01416D08000" + + "00080E040713C46010A069356247A91439BDC195B951A58DAD95D125B999BC05" + + "02B41821B8090020080B23E800BE8201620010287A12007A390F0F696E636C75" + + "646564207469636B6574120220103B830B9B9B0B3B28084A0B6B9BA32B93230B" + + "680202F698040100B20004C6C802B70BAB1623164D19B570D9B8227A2A12101D" + + "09D4813A65E7D0A0402C40A0B680590141ED00"; + } + + + + private static void populateTicket(UicRailTicketData ticket) { + + ticket.setControlDetail(new ControlData()); + populate(ticket.getControlDetail()); + + + ticket.setIssuingDetail(new IssuingData()); + populateIssuingData(ticket.getIssuingDetail()); + + TravelerData td = new TravelerData(); + populateTravelerData(td); + ticket.setTravelerDetail(td); + + SequenceOfDocumentData ds = new SequenceOfDocumentData(); + + + //OpenTicket + DocumentData do1 = new DocumentData(); + addOpenTicketData(do1); + ds.add(do1); + + //StationPassage + DocumentData do2 = new DocumentData(); + addStationPassage(do2); + ds.add(do2); + + ticket.setTransportDocument(ds); + + SequenceOfExtensionData ed = new SequenceOfExtensionData(); + populateExtensionSequence(ed); + ticket.setExtension(ed); + + } + + private static void addStationPassage(DocumentData dd) { + TicketDetailData tdd = new TicketDetailData(); + StationPassageData sp = new StationPassageData(); + sp.setProductName("passage"); + sp.setValidFromDay(0L); + sp.setNumberOfDaysValid(123L); + SequenceOfStringUTF8 ss = new SequenceOfStringUTF8(); + ss.add("Amsterdam"); + sp.setStationNameUTF8(ss); + tdd.setStationPassage(sp); + dd.setTicket(tdd); + } + + /* + * + * returnIncluded FALSE + ,classCode first + ,vatDetail { + { country 80 + ,percentage 70 + ,amount 10 + ,vatId "IUDGTE" + } + } + ,infoText "openTicketInfo" + */ + private static void addOpenTicketData(DocumentData dd) { + TokenType to = new TokenType(); + to.setTokenProviderIA5("VDV"); + byte[] ba = { (byte) 0x82, (byte) 0xDA }; + to.setToken(ba); + dd.setToken(to); + + TicketDetailData tdd = new TicketDetailData(); + OpenTicketData otd = new OpenTicketData(); + otd.setInfoText("openTicketInfo"); + otd.setClassCode(TravelClassType.first); + otd.setReturnIncluded(false); + + otd.setIncludedAddOns(new SequenceOfIncludedOpenTicketType()); + otd.getIncludedAddOns().add(getIncludedOpenTicket()); + + otd.setVatDetails(new SequenceOfVatDetail()); + otd.getVatDetails().add(getVatDetail()); + + tdd.setOpenTicket(otd); + dd.setTicket(tdd); + + } + + private static VatDetailType getVatDetail() { + VatDetailType v = new VatDetailType(); + v.setAmount(10L); + v.setCountry(80L); + v.setPercentage(70L); + v.setVatId("IUDGTE"); + return v; + } + + /* + { productOwnerNum 1080 + ,validRegion { zones : { zoneId { 100 } } } + ,validFromDay 0 + ,validFromTime 1000 + ,validUntilDay 1 + ,validUntilTime 1000 + ,classCode second + ,tariffs { + { numberOfPassengers 2 + ,passengerType adult + ,restrictedToCountryOfResidence FALSE + ,restrictedToRouteSection { fromStationNum 8000001 , toStationNum 8010000 } + } + } + ,infoText "included ticket" + } + */ + + private static IncludedOpenTicketType getIncludedOpenTicket() { + IncludedOpenTicketType t = new IncludedOpenTicketType(); + t.setClassCode(TravelClassType.second); + t.setInfoText("included ticket"); + t.setProductOwnerNum(1080L); + t.setValidRegion(new SequenceOfRegionalValidityType()); + t.getValidRegion().add(getZone()); + t.setValidFromDay(0L); + t.setValidFromTime(1000L); + t.setValidUntilDay(1L); + t.setValidUntilTime(1000L); + t.setTariffs(new SequenceOfTariffType()); + t.getTariffs().add(getTariff()); + return t; + } + + + + + private static RegionalValidityType getZone() { + + RegionalValidityType r = new RegionalValidityType(); + ZoneType z = new ZoneType(); + z.setZoneId(new SequenceOfUnrestrictedLong()); + z.getZoneId().add(100L); + r.setZones(z); + return r; + } + + private static void populateTravelerData(TravelerData td) { + td.setGroupName("myGroup"); + SequenceOfTravelerType trs = new SequenceOfTravelerType(); + TravelerType tr = new TravelerType(); + tr.setIdCard("12345"); + tr.setFirstName("John"); + tr.setSecondName("Dow"); + tr.setTicketHolder(true); + SequenceOfCustomerStatusType ts = new SequenceOfCustomerStatusType(); + CustomerStatusType cst = new CustomerStatusType(); + cst.setCustomerStatusDescr("senior"); + ts.add(cst); + tr.setStatus(ts); + trs.add(tr); + td.setTraveler(trs); + } + + + private static void populateIssuingData(IssuingData issuingDetail) { + issuingDetail.setIssuingYear(2018L); + issuingDetail.setIssuingDay(1L); + issuingDetail.setIssuerPNR("issuerTestPNR"); + issuingDetail.setSpecimen(true); + issuingDetail.setSecurePaperTicket(false); + issuingDetail.setActivated(true); + issuingDetail.setIssuedOnLine(12L); + } + + + private static void populateExtensionSequence(SequenceOfExtensionData ed) { + ExtensionData ed1 = new ExtensionData(); + ed1.setExtensionId("1"); + byte[] ba1 = { (byte) 0x82, (byte) 0xDA }; + ed1.setExtensionData(ba1); + ExtensionData ed2 = new ExtensionData(); + ed2.setExtensionId("2"); + byte[] ba2 = { (byte) 0x83, (byte) 0xDA }; + ed2.setExtensionData(ba2); + ed.add(ed1); + ed.add(ed2); + } + + + private static void populate(ControlData controlDetail) { + controlDetail.infoText = "cd"; + controlDetail.setAgeCheckRequired(false); + controlDetail.setIdentificationByIdCard(false); + controlDetail.setIdentificationByPassportId(false); + controlDetail.setOnlineValidationRequired(false); + controlDetail.setPassportValidationRequired(false); + controlDetail.setReductionCardCheckRequired(false); + controlDetail.setIdentificationByCardReference(new SequenceOfCardReferenceType()); + controlDetail.getIdentificationByCardReference().add(populateCardRefrence()); + SequenceOfTicketLinkType sit = new SequenceOfTicketLinkType(); + populateLinkedTickets(sit); + controlDetail.setIncludedTickets(sit); + } + + + /* + * + */ + private static void populateLinkedTickets(SequenceOfTicketLinkType sequenceOfTicketLinkType) { + TicketLinkType tlt = new TicketLinkType(); + tlt.productOwnerIA5="test"; + tlt.setTicketType(TicketType.pass); + tlt.setIssuerPNR("PNR"); + tlt.setReferenceIA5("UED12435867"); + tlt.setLinkMode(LinkMode.onlyValidInCombination); + tlt.setIssuerName("OEBB"); + sequenceOfTicketLinkType.add(tlt); + } + + /* + { + trailingCardIdNum 100 + } + */ + private static CardReferenceType populateCardRefrence() { + CardReferenceType cr = new CardReferenceType(); + cr.setTrailingCardIdNum(100L); + return cr; + } + + private static TariffType getTariff() { + TariffType t = new TariffType(); + t.setNumberOfPassengers(2L); + t.setPassengerType(PassengerType.adult); + t.setRestrictedToRouteSection(getRouteSection()); + t.setRestrictedToCountryOfResidence(false); + return t; + } + + private static RouteSectionType getRouteSection() { + RouteSectionType r = new RouteSectionType(); + r.setFromStationNum(8000001L); + r.setToStationNum(8010000L); + + return r; + } + + + } diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/OpenTestComplexTicketV2.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/OpenTestComplexTicketV2.java new file mode 100644 index 0000000..b5c5146 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/OpenTestComplexTicketV2.java @@ -0,0 +1,411 @@ +package org.uic.barcode.ticket.api.test.testtickets; + +import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8; +import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong; +import org.uic.barcode.ticket.api.asn.omv2.CardReferenceType; +import org.uic.barcode.ticket.api.asn.omv2.ControlData; +import org.uic.barcode.ticket.api.asn.omv2.CustomerStatusType; +import org.uic.barcode.ticket.api.asn.omv2.DocumentData; +import org.uic.barcode.ticket.api.asn.omv2.ExtensionData; +import org.uic.barcode.ticket.api.asn.omv2.IncludedOpenTicketType; +import org.uic.barcode.ticket.api.asn.omv2.IssuingData; +import org.uic.barcode.ticket.api.asn.omv2.LinkMode; +import org.uic.barcode.ticket.api.asn.omv2.OpenTicketData; +import org.uic.barcode.ticket.api.asn.omv2.PassengerType; +import org.uic.barcode.ticket.api.asn.omv2.RegionalValidityType; +import org.uic.barcode.ticket.api.asn.omv2.RouteSectionType; +import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCardReferenceType; +import org.uic.barcode.ticket.api.asn.omv2.SequenceOfCustomerStatusType; +import org.uic.barcode.ticket.api.asn.omv2.SequenceOfDocumentData; +import org.uic.barcode.ticket.api.asn.omv2.SequenceOfExtensionData; +import org.uic.barcode.ticket.api.asn.omv2.SequenceOfIncludedOpenTicketType; +import org.uic.barcode.ticket.api.asn.omv2.SequenceOfRegionalValidityType; +import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTariffType; +import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTicketLinkType; +import org.uic.barcode.ticket.api.asn.omv2.SequenceOfTravelerType; +import org.uic.barcode.ticket.api.asn.omv2.SequenceOfVatDetail; +import org.uic.barcode.ticket.api.asn.omv2.StationPassageData; +import org.uic.barcode.ticket.api.asn.omv2.TariffType; +import org.uic.barcode.ticket.api.asn.omv2.TicketDetailData; +import org.uic.barcode.ticket.api.asn.omv2.TicketLinkType; +import org.uic.barcode.ticket.api.asn.omv2.TicketType; +import org.uic.barcode.ticket.api.asn.omv2.TokenType; +import org.uic.barcode.ticket.api.asn.omv2.TravelClassType; +import org.uic.barcode.ticket.api.asn.omv2.TravelerData; +import org.uic.barcode.ticket.api.asn.omv2.TravelerType; +import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData; +import org.uic.barcode.ticket.api.asn.omv2.VatDetailType; +import org.uic.barcode.ticket.api.asn.omv2.ZoneType; + + + public class OpenTestComplexTicketV2 { + + public static UicRailTicketData getUicTestTicket() { + UicRailTicketData ticket = new UicRailTicketData(); + populateTicket(ticket); + return ticket; + } + + /* + value UicRailTicketData ::= { + issuingDetail { + issuingYear 2018 + issuingDay 1 + specimen TRUE, + securePaperTicket FALSE, + activated TRUE, + issuerPNR "issuerTestPNR", + issuedOnLine 12 + } + ,travelerDetail{ + traveler { + { + firstName "John" + ,secondName "Dow" + ,idCard "12345" + ,ticketHolder TRUE + ,status {{customerStatusDescr "senior" }} + } + } + ,groupName "myGroup" + } + ,transportDocument { + { + token {tokenProviderIA5 "VDV", token '82DA'H } + ,ticket openTicket : { + returnIncluded FALSE + ,classCode first + ,vatDetail { + { country 80 + ,percentage 70 + ,amount 10 + ,vatId "IUDGTE" + } + } + ,infoText "openTicketInfo" + ,includedAddOns { + { productOwnerNum 1080 + ,validRegion { zones : { zoneId { 100 } } } + ,validFromDay 0 + ,validFromTime 1000 + ,validUntilDay 1 + ,validUntilTime 1000 + ,classCode second + ,tariffs { + { numberOfPassengers 2 + ,passengerType adult + ,restrictedToCountryOfResidence FALSE + ,restrictedToRouteSection { fromStationNum 8000001 , toStationNum 8010000 } + } + } + ,infoText "included ticket" + } + } + } + } + ,{ + ticket stationPassage : { + productName "passage" + ,stationNameUTF8 { "Amsterdam" } + ,validFromDay 0 + ,numberOfDaysValid 123 + } + } + } + ,controlDetail { + identificationByCardReference { + { trailingCardIdNum 100 } + } + ,identificationByIdCard FALSE + ,identificationByPassportId FALSE + ,passportValidationRequired FALSE + ,onlineValidationRequired FALSE + ,ageCheckRequired FALSE + ,reductionCardCheckRequired FALSE + ,infoText "cd" + ,includedTickets { + { referenceIA5 "UED12435867" + ,issuerName "OEBB" + ,issuerPNR "PNR" + ,productOwnerIA5 "test" + ,ticketType pass + ,linkMode onlyValidInCombination + + } + } + } + ,extension { + { extensionId "1", extensionData '82DA'H } + ,{ extensionId "2", extensionData '83DA'H } + } + } + */ + + + + public static String getEncodingHex() { + return + "78022020050DD3CF9F5CBCAA65E7D284EA40218A02D00041129BDA1B80D11BDD" + + "C158B266D1AC0441B9E5DDA77F2076D7947726F757002501D689580A0B684000" + + "0004070040713C46010A069356247A91439BDC195B951A58DAD95D125B999BC0" + + "502B418086E0240080202C8FA004FA0402C4002050F42400F4721E1ED2DCC6D8" + + "EAC8CAC840E8D2C6D6CAE8240440207706173736167650109416D73746572646" + + "16D00405ED300802016400098D90056E17562C462C9A336AE1B37044F4542420" + + "3A13A90274CBCFA140805881416D00B20283DA"; + } + + + + private static void populateTicket(UicRailTicketData ticket) { + + ticket.setControlDetail(new ControlData()); + populate(ticket.getControlDetail()); + + + ticket.setIssuingDetail(new IssuingData()); + populateIssuingData(ticket.getIssuingDetail()); + + TravelerData td = new TravelerData(); + populateTravelerData(td); + ticket.setTravelerDetail(td); + + SequenceOfDocumentData ds = new SequenceOfDocumentData(); + + + //OpenTicket + DocumentData do1 = new DocumentData(); + addOpenTicketData(do1); + ds.add(do1); + + //StationPassage + DocumentData do2 = new DocumentData(); + addStationPassage(do2); + ds.add(do2); + + ticket.setTransportDocument(ds); + + SequenceOfExtensionData ed = new SequenceOfExtensionData(); + populateExtensionSequence(ed); + ticket.setExtension(ed); + + } + + private static void addStationPassage(DocumentData dd) { + TicketDetailData tdd = new TicketDetailData(); + StationPassageData sp = new StationPassageData(); + sp.setProductName("passage"); + sp.setValidFromDay(0L); + sp.setNumberOfDaysValid(123L); + SequenceOfStringUTF8 ss = new SequenceOfStringUTF8(); + ss.add("Amsterdam"); + sp.setStationNameUTF8(ss); + tdd.setStationPassage(sp); + dd.setTicket(tdd); + } + + /* + * + * returnIncluded FALSE + ,classCode first + ,vatDetail { + { country 80 + ,percentage 70 + ,amount 10 + ,vatId "IUDGTE" + } + } + ,infoText "openTicketInfo" + */ + private static void addOpenTicketData(DocumentData dd) { + TokenType to = new TokenType(); + to.setTokenProviderIA5("VDV"); + byte[] ba = { (byte) 0x82, (byte) 0xDA }; + to.setToken(ba); + dd.setToken(to); + + TicketDetailData tdd = new TicketDetailData(); + OpenTicketData otd = new OpenTicketData(); + otd.setInfoText("openTicketInfo"); + otd.setClassCode(TravelClassType.first); + otd.setReturnIncluded(false); + + otd.setIncludedAddOns(new SequenceOfIncludedOpenTicketType()); + otd.getIncludedAddOns().add(getIncludedOpenTicket()); + + otd.setVatDetails(new SequenceOfVatDetail()); + otd.getVatDetails().add(getVatDetail()); + + tdd.setOpenTicket(otd); + dd.setTicket(tdd); + + } + + private static VatDetailType getVatDetail() { + VatDetailType v = new VatDetailType(); + v.setAmount(10L); + v.setCountry(80L); + v.setPercentage(70L); + v.setVatId("IUDGTE"); + return v; + } + + /* + { productOwnerNum 1080 + ,validRegion { zones : { zoneId { 100 } } } + ,validFromDay 0 + ,validFromTime 1000 + ,validUntilDay 1 + ,validUntilTime 1000 + ,classCode second + ,tariffs { + { numberOfPassengers 2 + ,passengerType adult + ,restrictedToCountryOfResidence FALSE + ,restrictedToRouteSection { fromStationNum 8000001 , toStationNum 8010000 } + } + } + ,infoText "included ticket" + } + */ + + private static IncludedOpenTicketType getIncludedOpenTicket() { + IncludedOpenTicketType t = new IncludedOpenTicketType(); + t.setClassCode(TravelClassType.second); + t.setInfoText("included ticket"); + t.setProductOwnerNum(1080L); + t.setValidRegion(new SequenceOfRegionalValidityType()); + t.getValidRegion().add(getZone()); + t.setValidFromDay(0L); + t.setValidFromTime(1000L); + t.setValidUntilDay(1L); + t.setValidUntilTime(1000L); + t.setTariffs(new SequenceOfTariffType()); + t.getTariffs().add(getTariff()); + return t; + } + + + + + private static RegionalValidityType getZone() { + + RegionalValidityType r = new RegionalValidityType(); + ZoneType z = new ZoneType(); + z.setZoneId(new SequenceOfUnrestrictedLong()); + z.getZoneId().add(100L); + r.setZones(z); + return r; + } + + private static void populateTravelerData(TravelerData td) { + td.setGroupName("myGroup"); + SequenceOfTravelerType trs = new SequenceOfTravelerType(); + TravelerType tr = new TravelerType(); + tr.setIdCard("12345"); + tr.setFirstName("John"); + tr.setSecondName("Dow"); + tr.setTicketHolder(true); + SequenceOfCustomerStatusType ts = new SequenceOfCustomerStatusType(); + CustomerStatusType cst = new CustomerStatusType(); + cst.setCustomerStatusDescr("senior"); + ts.add(cst); + tr.setStatus(ts); + trs.add(tr); + td.setTraveler(trs); + } + +/* + * issuingDetail { + issuingYear 2018 + issuingDay 1 + specimen TRUE, + securePaperTicket FALSE, + activated TRUE, + issuerPNR "issuerTestPNR", + issuedOnLine 12 + } + */ + private static void populateIssuingData(IssuingData issuingDetail) { + issuingDetail.setIssuingYear(2018L); + issuingDetail.setIssuingDay(1L); + issuingDetail.setIssuerPNR("issuerTestPNR"); + issuingDetail.setSpecimen(true); + issuingDetail.setSecurePaperTicket(false); + issuingDetail.setActivated(true); + issuingDetail.setIssuedOnLine(12L); + } + + + private static void populateExtensionSequence(SequenceOfExtensionData ed) { + ExtensionData ed1 = new ExtensionData(); + ed1.setExtensionId("1"); + byte[] ba1 = { (byte) 0x82, (byte) 0xDA }; + ed1.setExtensionData(ba1); + ExtensionData ed2 = new ExtensionData(); + ed2.setExtensionId("2"); + byte[] ba2 = { (byte) 0x83, (byte) 0xDA }; + ed2.setExtensionData(ba2); + ed.add(ed1); + ed.add(ed2); + } + + + private static void populate(ControlData controlDetail) { + controlDetail.infoText = "cd"; + controlDetail.setAgeCheckRequired(false); + controlDetail.setIdentificationByIdCard(false); + controlDetail.setIdentificationByPassportId(false); + controlDetail.setOnlineValidationRequired(false); + controlDetail.setPassportValidationRequired(false); + controlDetail.setReductionCardCheckRequired(false); + controlDetail.setIdentificationByCardReference(new SequenceOfCardReferenceType()); + controlDetail.getIdentificationByCardReference().add(populateCardRefrence()); + SequenceOfTicketLinkType sit = new SequenceOfTicketLinkType(); + populateLinkedTickets(sit); + controlDetail.setIncludedTickets(sit); + } + + + /* + * + */ + private static void populateLinkedTickets(SequenceOfTicketLinkType sequenceOfTicketLinkType) { + TicketLinkType tlt = new TicketLinkType(); + tlt.productOwnerIA5="test"; + tlt.setTicketType(TicketType.pass); + tlt.setIssuerPNR("PNR"); + tlt.setReferenceIA5("UED12435867"); + tlt.setLinkMode(LinkMode.onlyValidInCombination); + tlt.setIssuerName("OEBB"); + sequenceOfTicketLinkType.add(tlt); + } + + /* + { + trailingCardIdNum 100 + } + */ + private static CardReferenceType populateCardRefrence() { + CardReferenceType cr = new CardReferenceType(); + cr.setTrailingCardIdNum(100L); + return cr; + } + + private static TariffType getTariff() { + TariffType t = new TariffType(); + t.setNumberOfPassengers(2L); + t.setPassengerType(PassengerType.adult); + t.setRestrictedToRouteSection(getRouteSection()); + t.setRestrictedToCountryOfResidence(false); + return t; + } + + private static RouteSectionType getRouteSection() { + RouteSectionType r = new RouteSectionType(); + r.setFromStationNum(8000001L); + r.setToStationNum(8010000L); + + return r; + } + + } -- cgit v1.2.3