Skip to content

Commit f868484

Browse files
committed
Add unit test for copy_field() with missing array value. (#711)
1 parent 725599e commit f868484

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

metafix/src/test/java/org/metafacture/metafix/MetafixRecordTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,38 @@ public void shouldCopyMarkedArrayOfHashesIntoMarkedArray() {
17481748
);
17491749
}
17501750

1751+
@Test
1752+
@MetafixToDo("See issue #711")
1753+
public void shouldNotOverwriteHashValueWithMissingArrayValue() {
1754+
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
1755+
"copy_field('array[].*.dummy', 'hash.field1')"
1756+
),
1757+
i -> {
1758+
i.startRecord("1");
1759+
i.startEntity("hash");
1760+
i.literal("field1", "value1");
1761+
i.literal("field2", "value2");
1762+
i.endEntity();
1763+
i.startEntity("array[]");
1764+
i.startEntity("1");
1765+
i.endEntity();
1766+
i.endEntity();
1767+
i.endRecord();
1768+
},
1769+
(o, f) -> {
1770+
o.get().startRecord("1");
1771+
o.get().startEntity("hash");
1772+
o.get().literal("field1", "value1");
1773+
o.get().literal("field2", "value2");
1774+
o.get().endEntity();
1775+
o.get().startEntity("array[]");
1776+
o.get().startEntity("1");
1777+
f.apply(2).endEntity();
1778+
o.get().endRecord();
1779+
}
1780+
);
1781+
}
1782+
17511783
@Test
17521784
public void removeLiteral() {
17531785
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(

0 commit comments

Comments
 (0)