1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
package org.uic.barcode.test.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.uic.ticket.api.impl.SimpleCardReference;
import org.uic.ticket.api.impl.SimpleControlDetail;
import org.uic.ticket.api.impl.SimpleCustomerStatusDescription;
import org.uic.ticket.api.impl.SimpleExtension;
import org.uic.ticket.api.impl.SimpleIssuingDetail;
import org.uic.ticket.api.impl.SimpleOpenTicket;
import org.uic.ticket.api.impl.SimpleStationPassage;
import org.uic.ticket.api.impl.SimpleTicketLink;
import org.uic.ticket.api.impl.SimpleToken;
import org.uic.ticket.api.impl.SimpleTraveler;
import org.uic.ticket.api.impl.SimpleTravelerDetail;
import org.uic.ticket.api.impl.SimpleUicRailTicket;
import org.uic.ticket.api.spec.ICardReference;
import org.uic.ticket.api.spec.IControlDetail;
import org.uic.ticket.api.spec.ICustomerStatusDescription;
import org.uic.ticket.api.spec.IExtension;
import org.uic.ticket.api.spec.IIssuingDetail;
import org.uic.ticket.api.spec.ILinkMode;
import org.uic.ticket.api.spec.IOpenTicket;
import org.uic.ticket.api.spec.IStationPassage;
import org.uic.ticket.api.spec.ITicketLink;
import org.uic.ticket.api.spec.IToken;
import org.uic.ticket.api.spec.ITraveler;
import org.uic.ticket.api.spec.IUicRailTicket;
public class SimpleUICTestTicket {
public static IUicRailTicket getUicTestTicket() {
IUicRailTicket ticket = new SimpleUicRailTicket();
populateTicket(ticket);
return ticket;
}
private static void populateTicket(IUicRailTicket ticket) {
ticket.setControlDetails(new SimpleControlDetail());
populate(ticket.getControlDetails());
ticket.setIssuerDetails(new SimpleIssuingDetail());
populateIssuingData(ticket.getIssuerDetails());
SimpleTravelerDetail td = new SimpleTravelerDetail();
populateTravelerData(td);
ticket.setTravelerDetails(td);
//OpenTicket
IOpenTicket do1 = new SimpleOpenTicket();
populate(do1);
ticket.addOpenTicket(do1);
//StationPassage
IStationPassage do2 = new SimpleStationPassage();
populateStationPassage(do2);
ticket.addStationPassage(do2);
//token
IToken to = new SimpleToken();
to.setTokenProvider("VDV");
byte[] ba = { (byte) 0x82, (byte) 0xDA };
to.setToken(ba);
ticket.addExtension(populateExtension());
}
/*
ticket stationPassage : {
productName "passage"
,station {8312345}
,stationNameUTF8 { "Amsterdam" }
,validFromDay 0
,validUntilDay 4
}
*/
private static void populateStationPassage(IStationPassage sp) {
sp.setProductName("passage");
try {
Date date = new SimpleDateFormat("dd/MM/yyyy").parse("01/01/2018");
sp.setValidFrom(date);
} catch (ParseException e) {
e.printStackTrace();
}
try {
Date date = new SimpleDateFormat("dd/MM/yyyy").parse("04/01/2018");
sp.setValidUntil(date);
} catch (ParseException e) {
e.printStackTrace();
}
sp.addStation("8312345");
sp.addStationName("Amsterdam");
}
/*
{
token {tokenProviderIA5 "VDV", token '82DA'H }
,ticket openTicket : {
returnIncluded FALSE
infoText "openTicketInfo"
}
}
*/
private static void populate(IOpenTicket otd) {
otd.setInfoText("openTicketInfo");
otd.setReturnIncluded(false);
}
/*
,travelerDetail{
traveler {
{
firstName "John"
,secondName "Dow"
,idCard "12345"
,ticketHolder TRUE
,status {{customerStatusDescr "senior" }}
}
}
,groupName "myGroup"
}
*/
private static void populateTravelerData(SimpleTravelerDetail td) {
td.setGroupName("myGroup");
ITraveler tr = new SimpleTraveler();
tr.setIdCard("12345");
tr.setFirstName("John");
tr.setSecondName("Dow");
tr.setTicketHolder(true);
ICustomerStatusDescription cst = new SimpleCustomerStatusDescription();
tr.addStatusDescription(cst);
cst.setDescription("senior");
td.addTraveler(tr);
}
/*
,issuingDetail {
issuerNum 1080
issuingYear 2018
issuingDay 1
specimen TRUE,
securePaperTicket FALSE,
activated TRUE,
issuerPNR "issuerTestPNR",
issuedOnLine 12
}
*/
private static void populateIssuingData(IIssuingDetail iIssuingDetail) {
try {
Date date = new SimpleDateFormat("dd/MM/yyyy").parse("01/01/2018");
iIssuingDetail.setIssuer("1080");
iIssuingDetail.setIssuingDate(date);
} catch (ParseException e) {
e.printStackTrace();
}
iIssuingDetail.setIssuerPNR("issuerTestPNR");
iIssuingDetail.setSpecimen(true);
iIssuingDetail.setSecurePaperTicket(false);
iIssuingDetail.setActivated(true);
iIssuingDetail.setIssuedOnLine(12);
}
/*
,extension {
{ extensionId "1", extensionData '82DA'H }
,{ extensionId "2", extensionData '83DA'H }
}
*/
private static IExtension populateExtension() {
IExtension ed1 = new SimpleExtension();
ed1.setId("1");
byte[] ba1 = { (byte) 0x82, (byte) 0xDA };
ed1.setBinarydata(ba1);
return ed1;
}
/*
,controlDetail {
identificationByCardReference {
{ trailingCardIdNum 100 }
}
,identificationByIdCard FALSE
,identificationByPassportId FALSE
,passportValidationRequired FALSE
,onlineValidationRequired FALSE
,ageCheckRequired FALSE
,reductionCardCheckRequired FALSE
,infoText "cd"
,includedTickets {
{ productOwnerIA5 "test" }
}
}
*/
private static void populate(IControlDetail iControlDetail) {
iControlDetail.setInfoText("cd");
iControlDetail.setAgeCheckRequired(false);
iControlDetail.setIdentificationByIdCard(false);
iControlDetail.setIdentificationByPassportId(false);
iControlDetail.setOnlineValidationRequired(false);
iControlDetail.setPassportValidationRequired(false);
iControlDetail.setReductionCardCheckRequired(false);
iControlDetail.getIdentificationByCardReference().add(populateCardRefrence());
iControlDetail.addLinkedTicket(populateLinkedTicket());
}
/*
*
*/
private static ITicketLink populateLinkedTicket() {
ITicketLink it = new SimpleTicketLink();
it.setProductOwner("test");
it.setLinkMode(ILinkMode.issuedTogether);
return it;
}
/*
{
trailingCardIdNum 100
}
*/
private static ICardReference populateCardRefrence() {
ICardReference cr = new SimpleCardReference();
cr.setTrailingCardId("100");
return cr;
}
public static void compare(IUicRailTicket ticket1, IUicRailTicket ticket2) {
assert(ticket1.getIssuerDetails().getIssuer().equals(ticket2.getIssuerDetails().getIssuer()));
}
}
|