Skip to content

Commit 89a3b26

Browse files
committed
Add entity pass-through test based on use case by @hagbeck.
1 parent 8df3f21 commit 89a3b26

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

metamorph/src/test/java/org/metafacture/metamorph/TestMetamorphBasics.java

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,114 @@ public void shouldNotHandleDataByElseNestedSourceIfDataBelongingToEntityIsRuledB
421421
);
422422
}
423423

424+
// https://github.com/hagbeck/metafacture-sandbox/tree/master/else-nested-entities
425+
@Test
426+
public void shouldHandleUseCaseSandboxElseNestedEntities() {
427+
assertMorph(receiver,
428+
"<rules>" +
429+
"<entity name='85640' flushWith='85640.3' reset='true'>" +
430+
"<data source='85640.u' name='u'>" +
431+
"<contains string='hdl.handle.net/2003/' />" +
432+
"<replace pattern='http://' with='https://' />" +
433+
"</data>" +
434+
"<data source='85640.u' name='u'>" +
435+
"<contains string='doi.org/10.17877/' />" +
436+
"<replace pattern='http://' with='https://' />" +
437+
"<replace pattern='dx.doi.org' with='doi.org' />" +
438+
"</data>" +
439+
"<data source='85640.x' name='x' />" +
440+
"<data source='85640.3' name='3' />" +
441+
"</entity>" +
442+
"<entity name='8564 ' flushWith='8564 .3' reset='true'>" +
443+
"<data source='8564 .u' name='u'>" +
444+
"<contains string='hdl.handle.net/2003/' />" +
445+
"<replace pattern='http://' with='https://' />" +
446+
"</data>" +
447+
"<data source='8564 .u' name='u'>" +
448+
"<contains string='doi.org/10.17877/' />" +
449+
"<replace pattern='http://' with='https://' />" +
450+
"<replace pattern='dx.doi.org' with='doi.org' />" +
451+
"</data>" +
452+
"<data source='8564 .x' name='x' />" +
453+
"<data source='8564 .3' name='3' />" +
454+
"</entity>" +
455+
"<data source='_elseNested' />" +
456+
"</rules>",
457+
i -> {
458+
i.startRecord("ID1687931");
459+
i.literal("leader", "00564nam a2200024 c 4500");
460+
i.literal("001", "1687931");
461+
i.literal("007", "|| ||||||||||||||||||||");
462+
i.literal("008", "||||||nuuuuuuuu|||||| | |||||||||||und||");
463+
i.startEntity("035 ");
464+
i.literal("a", "(UNION_SEAL)HT019953476");
465+
i.endEntity();
466+
i.startEntity("24500");
467+
i.literal("a", "Design and analysis of an asymmetric mutation operator");
468+
i.literal("c", "Thomas Jansen and Dirk Sudholt");
469+
i.endEntity();
470+
i.startEntity("8564 ");
471+
i.literal("z", "Freie Internetressource");
472+
i.endEntity();
473+
i.startEntity("85640");
474+
i.literal("u", "http://hdl.handle.net/2003/22116");
475+
i.literal("x", "Resolving-System");
476+
i.literal("3", "Volltext");
477+
i.endEntity();
478+
i.startEntity("85640");
479+
i.literal("u", "http://dx.doi.org/10.17877/DE290R-14123");
480+
i.literal("x", "Resolving-System");
481+
i.literal("3", "Volltext");
482+
i.endEntity();
483+
i.startEntity("9801 ");
484+
i.literal("e", "HBZ");
485+
i.endEntity();
486+
i.startEntity("997 ");
487+
i.literal("a", "20190130");
488+
i.endEntity();
489+
i.startEntity("9984 ");
490+
i.literal("z", "Freie Internetressource");
491+
i.endEntity();
492+
},
493+
o -> {
494+
o.get().startRecord("ID1687931");
495+
o.get().literal("leader", "00564nam a2200024 c 4500");
496+
o.get().literal("001", "1687931");
497+
o.get().literal("007", "|| ||||||||||||||||||||");
498+
o.get().literal("008", "||||||nuuuuuuuu|||||| | |||||||||||und||");
499+
o.get().startEntity("035 ");
500+
o.get().literal("a", "(UNION_SEAL)HT019953476");
501+
o.get().endEntity();
502+
o.get().startEntity("24500");
503+
o.get().literal("a", "Design and analysis of an asymmetric mutation operator");
504+
o.get().literal("c", "Thomas Jansen and Dirk Sudholt");
505+
o.get().endEntity();
506+
o.get().startEntity("8564 ");
507+
o.get().literal("z", "Freie Internetressource");
508+
o.get().endEntity();
509+
o.get().startEntity("85640");
510+
o.get().literal("u", "https://hdl.handle.net/2003/22116");
511+
o.get().literal("x", "Resolving-System");
512+
o.get().literal("3", "Volltext");
513+
o.get().endEntity();
514+
o.get().startEntity("85640");
515+
o.get().literal("u", "https://doi.org/10.17877/DE290R-14123");
516+
o.get().literal("x", "Resolving-System");
517+
o.get().literal("3", "Volltext");
518+
o.get().endEntity();
519+
o.get().startEntity("9801 ");
520+
o.get().literal("e", "HBZ");
521+
o.get().endEntity();
522+
o.get().startEntity("997 ");
523+
o.get().literal("a", "20190130");
524+
o.get().endEntity();
525+
o.get().startEntity("9984 ");
526+
o.get().literal("z", "Freie Internetressource");
527+
o.get().endEntity();
528+
}
529+
);
530+
}
531+
424532

425533
@Test
426534
public void shouldMatchCharacterWithQuestionMarkWildcard() {

0 commit comments

Comments
 (0)