@@ -41,12 +41,16 @@ public class PicaMultiscriptRemodelerTest {
41
41
private static final String FIELD_021C = "021C" ;
42
42
private static final String SCRIPT_LATIN = "Latn" ;
43
43
private static final String SCRIPT_GREEK = "Grek" ;
44
+ private static final String SCRIPT_ARABIC = "Arab" ;
45
+ private static final String SCRIPT_HEBREW = "Hebr" ;
44
46
45
47
private static final String VALUE_1 = "Subfield 1" ;
46
48
private static final String VALUE_2 = "Subfield 2" ;
47
49
private static final String VALUE_3 = "Subfield 3" ;
48
50
private static final String VALUE_1_GREEK = "ĸµ 1" ;
49
51
private static final String VALUE_2_GREEK = "ĸµ 2" ;
52
+ private static final String VALUE_1_ARABIC = "Subfield/Arabic 1" ;
53
+ private static final String VALUE_1_HEBREW = "Subfield/Hebrew 1" ;
50
54
51
55
private PicaMultiscriptRemodeler remodeler ;
52
56
@@ -215,6 +219,34 @@ public void shouldPassThroughIncompleteMultiscriptFields() {
215
219
ordered .verify (receiver ).endRecord ();
216
220
}
217
221
222
+ @ Test
223
+ public void shouldLabelArabicAsNonLatinRightToLeftScript () {
224
+ remodeler .startRecord (RECORD_ID );
225
+ emitMultscriptField (FIELD_021A , "01" , SCRIPT_LATIN , VALUE_1 );
226
+ emitMultscriptField (FIELD_021A , "01" , SCRIPT_ARABIC , VALUE_1_ARABIC );
227
+ remodeler .endRecord ();
228
+
229
+ final InOrder ordered = inOrder (receiver );
230
+ ordered .verify (receiver ).startRecord (RECORD_ID );
231
+ verifyMultiscriptField (ordered , FIELD_021A , "01" , SCRIPT_LATIN ,
232
+ VALUE_1 , SCRIPT_ARABIC , VALUE_1_ARABIC );
233
+ ordered .verify (receiver ).endRecord ();
234
+ }
235
+
236
+ @ Test
237
+ public void shouldLabelHebrewAsNonLatinRightToLeftScript () {
238
+ remodeler .startRecord (RECORD_ID );
239
+ emitMultscriptField (FIELD_021A , "01" , SCRIPT_LATIN , VALUE_1 );
240
+ emitMultscriptField (FIELD_021A , "01" , SCRIPT_HEBREW , VALUE_1_HEBREW );
241
+ remodeler .endRecord ();
242
+
243
+ final InOrder ordered = inOrder (receiver );
244
+ ordered .verify (receiver ).startRecord (RECORD_ID );
245
+ verifyMultiscriptField (ordered , FIELD_021A , "01" , SCRIPT_LATIN ,
246
+ VALUE_1 , SCRIPT_HEBREW , VALUE_1_HEBREW );
247
+ ordered .verify (receiver ).endRecord ();
248
+ }
249
+
218
250
@ Test
219
251
public void shouldClearStateOnResetStream () {
220
252
remodeler .startRecord (RECORD_ID );
@@ -247,12 +279,12 @@ private void verifyMultiscriptField(final InOrder ordered,
247
279
final String value1 , final String script2 , final String value2 ) {
248
280
249
281
ordered .verify (receiver ).startEntity (field );
250
- ordered .verify (receiver ).startEntity (script1 );
282
+ ordered .verify (receiver ).startEntity (mapScriptToEntityName ( script1 ) );
251
283
ordered .verify (receiver ).literal ("T" , groupNumber );
252
284
ordered .verify (receiver ).literal ("U" , script1 );
253
285
ordered .verify (receiver ).literal ("a" , value1 );
254
286
ordered .verify (receiver ).endEntity ();
255
- ordered .verify (receiver ).startEntity (script2 );
287
+ ordered .verify (receiver ).startEntity (mapScriptToEntityName ( script2 ) );
256
288
ordered .verify (receiver ).literal ("T" , groupNumber );
257
289
ordered .verify (receiver ).literal ("U" , script2 );
258
290
ordered .verify (receiver ).literal ("a" , value2 );
@@ -270,4 +302,14 @@ private void verifySingleMultiscriptField(final InOrder ordered,
270
302
ordered .verify (receiver ).endEntity ();
271
303
}
272
304
305
+ private String mapScriptToEntityName (final String script ) {
306
+ if (SCRIPT_LATIN .equals (script )) {
307
+ return PicaMultiscriptRemodeler .ENTITY_NAME_FOR_LATIN ;
308
+ } else if (SCRIPT_ARABIC .equals (script )
309
+ || SCRIPT_HEBREW .equals (script )) {
310
+ return PicaMultiscriptRemodeler .ENTITY_NAME_FOR_NON_LATIN_RL ;
311
+ }
312
+ return PicaMultiscriptRemodeler .ENTITY_NAME_FOR_NON_LATIN_LR ;
313
+ }
314
+
273
315
}
0 commit comments