diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2020-07-28 17:56:59 +0200 |
---|---|---|
committer | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2020-07-28 17:56:59 +0200 |
commit | aaeb77f8f58ebc01fd241139439a8d290765e5fc (patch) | |
tree | 4ce4a7300af0360d16e35156cde8a164779dd96a /src/org/uic/ticket/api/test | |
parent | bugfix activated day (diff) | |
download | UIC-barcode-aaeb77f8f58ebc01fd241139439a8d290765e5fc.tar UIC-barcode-aaeb77f8f58ebc01fd241139439a8d290765e5fc.tar.gz UIC-barcode-aaeb77f8f58ebc01fd241139439a8d290765e5fc.tar.bz2 UIC-barcode-aaeb77f8f58ebc01fd241139439a8d290765e5fc.tar.lz UIC-barcode-aaeb77f8f58ebc01fd241139439a8d290765e5fc.tar.xz UIC-barcode-aaeb77f8f58ebc01fd241139439a8d290765e5fc.tar.zst UIC-barcode-aaeb77f8f58ebc01fd241139439a8d290765e5fc.zip |
Diffstat (limited to 'src/org/uic/ticket/api/test')
-rw-r--r-- | src/org/uic/ticket/api/test/UperEncodeTicketTestV1.java | 221 |
1 files changed, 3 insertions, 218 deletions
diff --git a/src/org/uic/ticket/api/test/UperEncodeTicketTestV1.java b/src/org/uic/ticket/api/test/UperEncodeTicketTestV1.java index 9fed854..621dedb 100644 --- a/src/org/uic/ticket/api/test/UperEncodeTicketTestV1.java +++ b/src/org/uic/ticket/api/test/UperEncodeTicketTestV1.java @@ -205,8 +205,7 @@ DA016405 07B4 @Test public void testEncodeTicket() throws IllegalArgumentException, IllegalAccessException { - UicRailTicketData ticket = new UicRailTicketData(); - populateTicket(ticket); + UicRailTicketData ticket = SimpleUicTestTicket.getUicTestTicket(); byte[] encoded = UperEncoder.encode(ticket); String hex = UperEncoder.hexStringFromBytes(encoded); UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); @@ -219,8 +218,7 @@ DA016405 07B4 } @Test public void testDecodeTicket() throws IllegalArgumentException, IllegalAccessException { - UicRailTicketData ticket = new UicRailTicketData(); - populateTicket(ticket); + UicRailTicketData ticket = SimpleUicTestTicket.getUicTestTicket(); byte[] encoded = UperEncoder.encode(ticket); String hex = UperEncoder.hexStringFromBytes(encoded); UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); @@ -232,219 +230,6 @@ DA016405 07B4 assertEquals(decodedTicket.controlDetail.getInfoText() , "cd" ); assertEquals(decodedTicket.controlDetail.getIncludedTickets().get(0).getProductOwnerIA5() , "test" ); assert(decodedTicket.controlDetail.getIdentificationByCardReference().get(0).getTrailingCardIdNum() == 100L ); - } - - private 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); - - } - - /* - ticket stationPassage : { - productName "passage" - ,stationNameUTF8 { "Amsterdam" } - ,validFromDay 0 - ,numberOfDaysValid 123 - } - */ - private 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); - } - - /* - { - token {tokenProviderIA5 "VDV", token '82DA'H } - ,ticket openTicket : { - returnIncluded FALSE - infoText "openTicketInfo" - } - } - */ - - private 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.setReturnIncluded(false); - tdd.setOpenTicket(otd); - dd.setTicket(tdd); - } - - - /* - ,travelerDetail{ - traveler { - { - firstName "John" - ,secondName "Dow" - ,idCard "12345" - ,ticketHolder TRUE - ,status {{customerStatusDescr "senior" }} - } - } - ,groupName "myGroup" - } - */ - - private 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 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); - } - - /* - ,extension { - { extensionId "1", extensionData '82DA'H } - ,{ extensionId "2", extensionData '83DA'H } - } - */ - private 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); - } - - /* - ,controlDetail { - identificationByCardReference { - { trailingCardIdNum 100 } - } - ,identificationByIdCard FALSE - ,identificationByPassportId FALSE - ,passportValidationRequired FALSE - ,onlineValidationRequired FALSE - ,ageCheckRequired FALSE - ,reductionCardCheckRequired FALSE - ,infoText "cd" - ,includedTickets { - { productOwnerIA5 "test" } - } - } - */ - private 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(); - populateIncludedTickets(sit); - controlDetail.setIncludedTickets(sit); - } - - - /* - * - */ - private void populateIncludedTickets(SequenceOfTicketLinkType sequenceOfTicketLinkType) { - TicketLinkType tlt = new TicketLinkType(); - tlt.productOwnerIA5="test"; - sequenceOfTicketLinkType.add(tlt); - } - - /* - { - trailingCardIdNum 100 - } - */ - private CardReferenceType populateCardRefrence() { - CardReferenceType cr = new CardReferenceType(); - cr.setTrailingCardIdNum(100L); - return cr; - } - - - - - - - + } } |