Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
Add test with explicit $append for arrays of hashes (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Dec 7, 2021
1 parent 1c4050a commit b853073
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public void copyIntoArrayOfStrings() {
}

@Test
public void copyIntoArrayOfObjects() {
public void copyIntoArrayOfHashesImplicitAppend() {
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
"set_array('author[]')",
"copy_field('your.name','author[].name')",
Expand All @@ -427,6 +427,34 @@ public void copyIntoArrayOfObjects() {
});
}

@Test
public void copyIntoArrayOfHashesExplicitAppend() {
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
"set_array('author[]')",
"copy_field('your.name','author[].$append.name')",
"remove_field('your')"),
i -> {
i.startRecord("1");
i.startEntity("your");
i.literal("name", "max");
i.endEntity();
i.startEntity("your");
i.literal("name", "mo");
i.endEntity();
i.endRecord();
}, (o, f) -> {
o.get().startRecord("1");
o.get().startEntity("author[]");
o.get().startEntity("1");
o.get().literal("name", "max");
o.get().endEntity();
o.get().startEntity("2");
o.get().literal("name", "mo");
f.apply(2).endEntity();
o.get().endRecord();
});
}

@Test
public void copyIntoArrayTopLevel() {
MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList(
Expand Down

0 comments on commit b853073

Please sign in to comment.