@@ -42,9 +42,10 @@ public final class PicaDecoderTest {
42
42
private static final String VALUE_D = "Umberto" ;
43
43
private static final String COMPOSED_UTF8 = "Über" ; // 'Ü' constructed from U and diacritics
44
44
private static final String STANDARD_UTF8 = "Über" ; // 'Ü' is a single character
45
-
46
- private static final String SUBFIELD_MARKER = "\u001f " ;
45
+
46
+ private static final String RECORD_MARKER = "\u001d " ;
47
47
private static final String FIELD_MARKER = "\u001e " ;
48
+ private static final String SUBFIELD_MARKER = "\u001f " ;
48
49
private static final String FIELD_END_MARKER = "\n " ;
49
50
50
51
private static final String FIELD_001AT_0_TEST = "001@ " + SUBFIELD_MARKER + "0test" ;
@@ -70,7 +71,103 @@ public void cleanup() {
70
71
}
71
72
72
73
@ Test
73
- public void testShouldParseRecordStartingWithFieldNameAndEndingWithFieldMarker () {
74
+ public void testShouldParseRecordStartingWithRecordMarker () {
75
+ picaDecoder .process (
76
+ RECORD_MARKER + FIELD_001AT_0_TEST +
77
+ FIELD_MARKER + FIELD_003AT_0_ID );
78
+
79
+
80
+ final InOrder ordered = inOrder (receiver );
81
+ ordered .verify (receiver ).startRecord (RECORD_ID );
82
+ verify001At0Test (ordered );
83
+ verify003At0ID (ordered );
84
+ ordered .verify (receiver ).endRecord ();
85
+ }
86
+
87
+ @ Test
88
+ public void testShouldParseRecordStartingWithFieldMarker () {
89
+ picaDecoder .process (
90
+ FIELD_MARKER + FIELD_001AT_0_TEST +
91
+ FIELD_MARKER + FIELD_003AT_0_ID );
92
+
93
+
94
+ final InOrder ordered = inOrder (receiver );
95
+ ordered .verify (receiver ).startRecord (RECORD_ID );
96
+ verify001At0Test (ordered );
97
+ verify003At0ID (ordered );
98
+ ordered .verify (receiver ).endRecord ();
99
+ }
100
+
101
+ @ Test
102
+ public void testShouldParseRecordStartingWithSubfieldMarker () {
103
+ picaDecoder .process (
104
+ SUBFIELD_MARKER + NAME_A + VALUE_A +
105
+ FIELD_MARKER + FIELD_003AT_0_ID );
106
+
107
+ final InOrder ordered = inOrder (receiver );
108
+ ordered .verify (receiver ).startRecord (RECORD_ID );
109
+ ordered .verify (receiver ).startEntity ("" );
110
+ ordered .verify (receiver ).literal (NAME_A , VALUE_A );
111
+ ordered .verify (receiver ).endEntity ();
112
+ verify003At0ID (ordered );
113
+ ordered .verify (receiver ).endRecord ();
114
+ }
115
+
116
+ @ Test
117
+ public void testShouldParseRecordStartingWithEmptySubfield () {
118
+ picaDecoder .process (
119
+ SUBFIELD_MARKER +
120
+ FIELD_MARKER + FIELD_003AT_0_ID );
121
+
122
+ final InOrder ordered = inOrder (receiver );
123
+ ordered .verify (receiver ).startRecord (RECORD_ID );
124
+ verify003At0ID (ordered );
125
+ ordered .verify (receiver ).endRecord ();
126
+ }
127
+
128
+ @ Test
129
+ public void testShouldParseRecordStartingWithFieldEndMarker () {
130
+ picaDecoder .process (
131
+ FIELD_END_MARKER + FIELD_001AT_0_TEST +
132
+ FIELD_MARKER + FIELD_003AT_0_ID );
133
+
134
+
135
+ final InOrder ordered = inOrder (receiver );
136
+ ordered .verify (receiver ).startRecord (RECORD_ID );
137
+ verify001At0Test (ordered );
138
+ verify003At0ID (ordered );
139
+ ordered .verify (receiver ).endRecord ();
140
+ }
141
+
142
+ @ Test
143
+ public void testShouldParseRecordStartingWithFieldName () {
144
+ picaDecoder .process (
145
+ FIELD_001AT_0_TEST +
146
+ FIELD_MARKER + FIELD_003AT_0_ID );
147
+
148
+
149
+ final InOrder ordered = inOrder (receiver );
150
+ ordered .verify (receiver ).startRecord (RECORD_ID );
151
+ verify001At0Test (ordered );
152
+ verify003At0ID (ordered );
153
+ ordered .verify (receiver ).endRecord ();
154
+ }
155
+
156
+ @ Test
157
+ public void testShouldParseRecordEndingWithRecordMarker () {
158
+ picaDecoder .process (
159
+ FIELD_003AT_0_ID + FIELD_MARKER +
160
+ FIELD_001AT_0_TEST + RECORD_MARKER );
161
+
162
+ final InOrder ordered = inOrder (receiver );
163
+ ordered .verify (receiver ).startRecord (RECORD_ID );
164
+ verify003At0ID (ordered );
165
+ verify001At0Test (ordered );
166
+ ordered .verify (receiver ).endRecord ();
167
+ }
168
+
169
+ @ Test
170
+ public void testShouldParseRecordEndingWithFieldMarker () {
74
171
picaDecoder .process (
75
172
FIELD_003AT_0_ID + FIELD_MARKER +
76
173
FIELD_001AT_0_TEST + FIELD_MARKER );
@@ -138,38 +235,33 @@ public void testShouldParseRecordEndingWithFieldName() {
138
235
}
139
236
140
237
@ Test
141
- public void testShouldParseRecordStartingWithFieldMarker () {
238
+ public void testShouldParseMultiLineRecordFormat () {
142
239
picaDecoder .process (
143
- FIELD_MARKER + FIELD_001AT_0_TEST +
144
- FIELD_MARKER + FIELD_003AT_0_ID );
240
+ RECORD_MARKER + FIELD_END_MARKER +
241
+ FIELD_MARKER + FIELD_001AT_0_TEST + FIELD_END_MARKER +
242
+ FIELD_MARKER + FIELD_003AT_0_ID + FIELD_END_MARKER );
145
243
146
-
147
244
final InOrder ordered = inOrder (receiver );
148
245
ordered .verify (receiver ).startRecord (RECORD_ID );
149
246
verify001At0Test (ordered );
150
247
verify003At0ID (ordered );
151
248
ordered .verify (receiver ).endRecord ();
152
249
}
153
-
250
+
154
251
@ Test
155
- public void testShouldParseRecordStartingWithSubfieldMarker () {
252
+ public void testShouldParseRecordIdAfterRecordMarker () {
156
253
picaDecoder .process (
157
- SUBFIELD_MARKER + NAME_A + VALUE_A +
158
- FIELD_MARKER + FIELD_003AT_0_ID );
159
-
254
+ RECORD_MARKER + FIELD_003AT_0_ID );
255
+
160
256
final InOrder ordered = inOrder (receiver );
161
257
ordered .verify (receiver ).startRecord (RECORD_ID );
162
- ordered .verify (receiver ).startEntity ("" );
163
- ordered .verify (receiver ).literal (NAME_A , VALUE_A );
164
- ordered .verify (receiver ).endEntity ();
165
258
verify003At0ID (ordered );
166
259
ordered .verify (receiver ).endRecord ();
167
260
}
168
-
261
+
169
262
@ Test
170
- public void testShouldParseRecordStartingWithEmptySubfield () {
263
+ public void testShouldParseRecordIdAfterFieldMarker () {
171
264
picaDecoder .process (
172
- SUBFIELD_MARKER +
173
265
FIELD_MARKER + FIELD_003AT_0_ID );
174
266
175
267
final InOrder ordered = inOrder (receiver );
@@ -179,28 +271,23 @@ public void testShouldParseRecordStartingWithEmptySubfield() {
179
271
}
180
272
181
273
@ Test
182
- public void testShouldParseRecordStartingWithFieldEndMarker () {
274
+ public void testShouldParseRecordIdAfterFieldEndMarker () {
183
275
picaDecoder .process (
184
- FIELD_END_MARKER + FIELD_001AT_0_TEST +
185
- FIELD_MARKER + FIELD_003AT_0_ID );
276
+ FIELD_END_MARKER + FIELD_003AT_0_ID );
186
277
187
-
188
278
final InOrder ordered = inOrder (receiver );
189
279
ordered .verify (receiver ).startRecord (RECORD_ID );
190
- verify001At0Test (ordered );
191
280
verify003At0ID (ordered );
192
281
ordered .verify (receiver ).endRecord ();
193
282
}
194
-
283
+
195
284
@ Test
196
- public void testShouldParseRecordWitFieldEndMarkers () {
285
+ public void testShouldParseRecordIdFollowedByRecordMarker () {
197
286
picaDecoder .process (
198
- FIELD_MARKER + FIELD_001AT_0_TEST + FIELD_END_MARKER +
199
- FIELD_MARKER + FIELD_003AT_0_ID + FIELD_END_MARKER );
287
+ FIELD_003AT_0_ID + RECORD_MARKER );
200
288
201
289
final InOrder ordered = inOrder (receiver );
202
290
ordered .verify (receiver ).startRecord (RECORD_ID );
203
- verify001At0Test (ordered );
204
291
verify003At0ID (ordered );
205
292
ordered .verify (receiver ).endRecord ();
206
293
}
@@ -248,28 +335,6 @@ public void testShouldParseRecordIdAtRecordEnd() {
248
335
verify003At0ID (ordered );
249
336
ordered .verify (receiver ).endRecord ();
250
337
}
251
-
252
- @ Test
253
- public void testShouldParseRecordIdAfterFieldMarker () {
254
- picaDecoder .process (
255
- FIELD_MARKER + FIELD_003AT_0_ID );
256
-
257
- final InOrder ordered = inOrder (receiver );
258
- ordered .verify (receiver ).startRecord (RECORD_ID );
259
- verify003At0ID (ordered );
260
- ordered .verify (receiver ).endRecord ();
261
- }
262
-
263
- @ Test
264
- public void testShouldParseRecordIdAfterFieldEndMarker () {
265
- picaDecoder .process (
266
- FIELD_END_MARKER + FIELD_003AT_0_ID );
267
-
268
- final InOrder ordered = inOrder (receiver );
269
- ordered .verify (receiver ).startRecord (RECORD_ID );
270
- verify003At0ID (ordered );
271
- ordered .verify (receiver ).endRecord ();
272
- }
273
338
274
339
@ Test
275
340
public void testShouldSkipUnnamedFieldsWithNoSubFields () {
0 commit comments