|
33 | 33 | * @author Fabian Steeg
|
34 | 34 | */
|
35 | 35 | @ExtendWith(MockitoExtension.class)
|
| 36 | +@ExtendWith(MetafixToDo.Extension.class) |
36 | 37 | public class MetafixLookupTest {
|
37 | 38 |
|
38 | 39 | private static final String CSV_MAP = "src/test/resources/org/metafacture/metafix/maps/test.csv";
|
@@ -716,6 +717,130 @@ public void shouldDeleteLookupInUnknownInternalMap() {
|
716 | 717 | );
|
717 | 718 | }
|
718 | 719 |
|
| 720 | + @Test // checkstyle-disable-line JavaNCSS |
| 721 | + public void shouldLookupInNestedArrays() { |
| 722 | + MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( |
| 723 | + "put_map('rswk-indicator', s: 'SubjectHeading')", |
| 724 | + "lookup('subject[].*.componentList[].*.type[].*', 'rswk-indicator')" |
| 725 | + ), |
| 726 | + i -> { |
| 727 | + i.startRecord("1"); |
| 728 | + i.startEntity("subject[]"); |
| 729 | + i.startEntity("1"); |
| 730 | + i.startEntity("componentList[]"); |
| 731 | + i.startEntity("1"); |
| 732 | + i.startEntity("type[]"); |
| 733 | + i.literal("1", "s"); |
| 734 | + i.endEntity(); |
| 735 | + i.endEntity(); |
| 736 | + i.startEntity("2"); |
| 737 | + i.startEntity("type[]"); |
| 738 | + i.literal("1", "s"); |
| 739 | + i.endEntity(); |
| 740 | + i.endEntity(); |
| 741 | + i.startEntity("3"); |
| 742 | + i.startEntity("type[]"); |
| 743 | + i.literal("1", "s"); |
| 744 | + i.endEntity(); |
| 745 | + i.endEntity(); |
| 746 | + i.startEntity("4"); |
| 747 | + i.startEntity("type[]"); |
| 748 | + i.literal("1", "s"); |
| 749 | + i.endEntity(); |
| 750 | + i.endEntity(); |
| 751 | + i.startEntity("5"); |
| 752 | + i.startEntity("type[]"); |
| 753 | + i.literal("1", "s"); |
| 754 | + i.endEntity(); |
| 755 | + i.endEntity(); |
| 756 | + i.endEntity(); |
| 757 | + i.endEntity(); |
| 758 | + i.endEntity(); |
| 759 | + i.endRecord(); |
| 760 | + }, |
| 761 | + (o, f) -> { |
| 762 | + o.get().startRecord("1"); |
| 763 | + o.get().startEntity("subject[]"); |
| 764 | + o.get().startEntity("1"); |
| 765 | + o.get().startEntity("componentList[]"); |
| 766 | + o.get().startEntity("1"); |
| 767 | + o.get().startEntity("type[]"); |
| 768 | + o.get().literal("1", "SubjectHeading"); |
| 769 | + f.apply(2).endEntity(); |
| 770 | + o.get().startEntity("2"); |
| 771 | + o.get().startEntity("type[]"); |
| 772 | + o.get().literal("1", "SubjectHeading"); |
| 773 | + f.apply(2).endEntity(); |
| 774 | + o.get().startEntity("3"); |
| 775 | + o.get().startEntity("type[]"); |
| 776 | + o.get().literal("1", "SubjectHeading"); |
| 777 | + f.apply(2).endEntity(); |
| 778 | + o.get().startEntity("4"); |
| 779 | + o.get().startEntity("type[]"); |
| 780 | + o.get().literal("1", "SubjectHeading"); |
| 781 | + f.apply(2).endEntity(); |
| 782 | + o.get().startEntity("5"); |
| 783 | + o.get().startEntity("type[]"); |
| 784 | + o.get().literal("1", "SubjectHeading"); |
| 785 | + f.apply(5).endEntity(); |
| 786 | + o.get().endRecord(); |
| 787 | + } |
| 788 | + ); |
| 789 | + } |
| 790 | + |
| 791 | + @Test |
| 792 | + @MetafixToDo("See https://github.com/hbz/lobid-resources/pull/1354") |
| 793 | + public void shouldLookupInCopiedNestedArrays() { |
| 794 | + MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( |
| 795 | + "put_map('rswk-indicator', s: 'SubjectHeading')", |
| 796 | + "set_array('subject[]')", |
| 797 | + "set_array('subject[].$append.componentList[]')", |
| 798 | + "set_array('subject[].$last.componentList[].$append.type[]')", |
| 799 | + "do list(path: 'D', 'var': '$i')", |
| 800 | + " copy_field('$i', 'subject[].$last.componentList[].$last.type[].$append')", |
| 801 | + "end", |
| 802 | + "lookup('subject[].*.componentList[].*.type[].*', 'rswk-indicator')", |
| 803 | + "retain('subject[]')" |
| 804 | + ), |
| 805 | + i -> { |
| 806 | + i.startRecord("1"); |
| 807 | + i.literal("D", "s"); |
| 808 | + i.literal("D", "s"); |
| 809 | + i.literal("D", "s"); |
| 810 | + i.literal("D", "s"); |
| 811 | + i.literal("D", "s"); |
| 812 | + i.endRecord(); |
| 813 | + }, |
| 814 | + (o, f) -> { |
| 815 | + o.get().startRecord("1"); |
| 816 | + o.get().startEntity("subject[]"); |
| 817 | + o.get().startEntity("1"); |
| 818 | + o.get().startEntity("componentList[]"); |
| 819 | + o.get().startEntity("1"); |
| 820 | + o.get().startEntity("type[]"); |
| 821 | + o.get().literal("1", "SubjectHeading"); |
| 822 | + f.apply(2).endEntity(); |
| 823 | + o.get().startEntity("2"); |
| 824 | + o.get().startEntity("type[]"); |
| 825 | + o.get().literal("1", "SubjectHeading"); |
| 826 | + f.apply(2).endEntity(); |
| 827 | + o.get().startEntity("3"); |
| 828 | + o.get().startEntity("type[]"); |
| 829 | + o.get().literal("1", "SubjectHeading"); |
| 830 | + f.apply(2).endEntity(); |
| 831 | + o.get().startEntity("4"); |
| 832 | + o.get().startEntity("type[]"); |
| 833 | + o.get().literal("1", "SubjectHeading"); |
| 834 | + f.apply(2).endEntity(); |
| 835 | + o.get().startEntity("5"); |
| 836 | + o.get().startEntity("type[]"); |
| 837 | + o.get().literal("1", "SubjectHeading"); |
| 838 | + f.apply(5).endEntity(); |
| 839 | + o.get().endRecord(); |
| 840 | + } |
| 841 | + ); |
| 842 | + } |
| 843 | + |
719 | 844 | @Test
|
720 | 845 | public void shouldFailLookupInUnknownExternalMap() {
|
721 | 846 | MetafixTestHelpers.assertProcessException(MorphExecutionException.class, "File not found: testMap.csv", () ->
|
|
0 commit comments