From 618844a329cac33c1114a199c3db81f06a5b7ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Mon, 14 Oct 2024 16:39:09 +0200 Subject: [PATCH 1/9] Add new function add_array and add_hash #374 The are a copy of the current implementation of set_array and set_hash. This is a preparation for #309 --- .../java/org/metafacture/metafix/FixMethod.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/metafix/src/main/java/org/metafacture/metafix/FixMethod.java b/metafix/src/main/java/org/metafacture/metafix/FixMethod.java index 8eddcfe5..059efec2 100644 --- a/metafix/src/main/java/org/metafacture/metafix/FixMethod.java +++ b/metafix/src/main/java/org/metafacture/metafix/FixMethod.java @@ -164,12 +164,29 @@ public void apply(final Metafix metafix, final Record record, final List // RECORD-LEVEL METHODS: + add_array { + @Override + public void apply(final Metafix metafix, final Record record, final List params, final Map options) { + final String field = params.get(0); + final Value newValue = newArray(params.subList(1, params.size()).stream().map(Value::new)); + record.set(field, newValue); + newValue.asArray().forEach(value -> value.withPathSet(newValue.getPath() + "." + value.getPath())); + } + }, add_field { @Override public void apply(final Metafix metafix, final Record record, final List params, final Map options) { record.set(params.get(0), new Value(params.get(1))); } }, + add_hash { + @Override + public void apply(final Metafix metafix, final Record record, final List params, final Map options) { + final String field = params.get(0); + final Value newValue = Value.newHash(h -> options.forEach((f, v) -> h.put(f, new Value(v)))); + record.set(field, newValue); + } + }, array { // array-from-hash @Override public void apply(final Metafix metafix, final Record record, final List params, final Map options) { From 19051fb17b09af4730b76e6d8c1087f0e79c12e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Wed, 16 Oct 2024 14:52:14 +0200 Subject: [PATCH 2/9] Use add_array instead of set_array in integration tests #374 As a preliminary work for #309 since set_array will change its behaviour but add_array will keep the functionality. --- .../toJson/lookupInDeeplyNestedArrayOfObjects/test.fix | 8 ++++---- .../test.fix | 2 +- .../expected.json | 0 .../input.json | 0 .../toJson/add_arrayIntoArrayOfObjectsWithAppend/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../add_arrayIntoArrayOfObjectsWithAsterisk/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../toJson/add_arrayIntoArrayOfObjectsWithLast/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../add_arrayNestedSimpleWithMultipleValues/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../toJson/add_arrayNestedSimpleWithSingleValue/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../toJson/add_arrayNestedSimpleWithoutValues/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../fromJson/toJson/add_arraySimpleDestructive/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../toJson/add_arraySimpleWithMultipleValues/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../toJson/add_arraySimpleWithSingleValue/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../fromJson/toJson/add_arraySimpleWithoutValues/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../test.fix | 2 +- .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../test.fix | 2 +- .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../test.fix | 2 +- .../test.flux | 0 .../todo.txt | 0 .../toJson/copy_fieldToArrayOfStringsWithIndex/test.fix | 2 +- .../toJson/set_arrayIntoArrayOfObjectsWithAppend/test.fix | 1 - .../set_arrayIntoArrayOfObjectsWithAsterisk/test.fix | 1 - .../toJson/set_arrayIntoArrayOfObjectsWithLast/test.fix | 1 - .../set_arrayNestedSimpleWithMultipleValues/test.fix | 1 - .../toJson/set_arrayNestedSimpleWithSingleValue/test.fix | 1 - .../toJson/set_arrayNestedSimpleWithoutValues/test.fix | 1 - .../fromJson/toJson/set_arraySimpleDestructive/test.fix | 1 - .../toJson/set_arraySimpleWithMultipleValues/test.fix | 1 - .../toJson/set_arraySimpleWithSingleValue/test.fix | 1 - .../fromJson/toJson/set_arraySimpleWithoutValues/test.fix | 1 - 66 files changed, 19 insertions(+), 19 deletions(-) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayIntoArrayOfObjectsWithAppend => add_arrayIntoArrayOfObjectsWithAppend}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayIntoArrayOfObjectsWithAppend => add_arrayIntoArrayOfObjectsWithAppend}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayIntoArrayOfObjectsWithAppend => add_arrayIntoArrayOfObjectsWithAppend}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayIntoArrayOfObjectsWithAsterisk => add_arrayIntoArrayOfObjectsWithAsterisk}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayIntoArrayOfObjectsWithAsterisk => add_arrayIntoArrayOfObjectsWithAsterisk}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayIntoArrayOfObjectsWithAsterisk => add_arrayIntoArrayOfObjectsWithAsterisk}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayIntoArrayOfObjectsWithLast => add_arrayIntoArrayOfObjectsWithLast}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayIntoArrayOfObjectsWithLast => add_arrayIntoArrayOfObjectsWithLast}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayIntoArrayOfObjectsWithLast => add_arrayIntoArrayOfObjectsWithLast}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayNestedSimpleWithMultipleValues => add_arrayNestedSimpleWithMultipleValues}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayNestedSimpleWithMultipleValues => add_arrayNestedSimpleWithMultipleValues}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayNestedSimpleWithMultipleValues => add_arrayNestedSimpleWithMultipleValues}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayNestedSimpleWithSingleValue => add_arrayNestedSimpleWithSingleValue}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayNestedSimpleWithSingleValue => add_arrayNestedSimpleWithSingleValue}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayNestedSimpleWithSingleValue => add_arrayNestedSimpleWithSingleValue}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayNestedSimpleWithoutValues => add_arrayNestedSimpleWithoutValues}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayNestedSimpleWithoutValues => add_arrayNestedSimpleWithoutValues}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayNestedSimpleWithoutValues => add_arrayNestedSimpleWithoutValues}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arraySimpleDestructive => add_arraySimpleDestructive}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arraySimpleDestructive => add_arraySimpleDestructive}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arraySimpleDestructive => add_arraySimpleDestructive}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arraySimpleWithMultipleValues => add_arraySimpleWithMultipleValues}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arraySimpleWithMultipleValues => add_arraySimpleWithMultipleValues}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arraySimpleWithMultipleValues => add_arraySimpleWithMultipleValues}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arraySimpleWithSingleValue => add_arraySimpleWithSingleValue}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arraySimpleWithSingleValue => add_arraySimpleWithSingleValue}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arraySimpleWithSingleValue => add_arraySimpleWithSingleValue}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arraySimpleWithoutValues => add_arraySimpleWithoutValues}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arraySimpleWithoutValues => add_arraySimpleWithoutValues}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arraySimpleWithoutValues => add_arraySimpleWithoutValues}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/input.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/test.fix (50%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/input.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/test.fix (61%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/input.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/test.fix (68%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/todo.txt (100%) delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/test.fix diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/lookup/fromXml/toJson/lookupInDeeplyNestedArrayOfObjects/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/lookup/fromXml/toJson/lookupInDeeplyNestedArrayOfObjects/test.fix index 6a9c42c5..6a94986c 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/lookup/fromXml/toJson/lookupInDeeplyNestedArrayOfObjects/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/lookup/fromXml/toJson/lookupInDeeplyNestedArrayOfObjects/test.fix @@ -1,11 +1,11 @@ put_map("rswk-indicator", s: "SubjectHeading") if exists("6890?") - set_array("subject[].$append.type[]", "ComplexSubject") - set_array("subject[].$last.label") - set_array("subject[].$last.componentList[]") + add_array("subject[].$append.type[]", "ComplexSubject") + add_array("subject[].$last.label") + add_array("subject[].$last.componentList[]") do list(path: "6890?", "var": "$i") - set_array("subject[].$last.componentList[].$append.type[]") + add_array("subject[].$last.componentList[].$append.type[]") do list(path: "$i.D", "var": "$k") copy_field("$k", "subject[].$last.componentList[].$last.type[].$append") end diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_allInOptionalSubfieldOfRepeatedObjectsWithAsterisk/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_allInOptionalSubfieldOfRepeatedObjectsWithAsterisk/test.fix index 9c1c1c44..7640d1b1 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_allInOptionalSubfieldOfRepeatedObjectsWithAsterisk/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_allInOptionalSubfieldOfRepeatedObjectsWithAsterisk/test.fix @@ -1,4 +1,4 @@ -set_array("RSWK[]") +add_array("RSWK[]") do list(path: "650??", "var": "$i") copy_field("$i.a", "RSWK[].$append.subjectTopicName") copy_field("$i.v", "RSWK[].$last.subjectGenre") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/test.fix new file mode 100644 index 00000000..4d1b7dd6 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/test.fix @@ -0,0 +1 @@ +add_array("animals_2[].$append.test[]", "test", "test", "test") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/test.fix new file mode 100644 index 00000000..100ed906 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/test.fix @@ -0,0 +1 @@ +add_array("animals[].*.test[]", "test") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/test.fix new file mode 100644 index 00000000..9646ad25 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/test.fix @@ -0,0 +1 @@ +add_array("animals_2[].$last.test[]", "test", "test") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/test.fix new file mode 100644 index 00000000..f89d1fa5 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/test.fix @@ -0,0 +1 @@ +add_array("object.test[]", "dog", "cat", "bird") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/test.fix new file mode 100644 index 00000000..7e3807e3 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/test.fix @@ -0,0 +1 @@ +add_array("object.test[]", "dog") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/test.fix new file mode 100644 index 00000000..d1c64633 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/test.fix @@ -0,0 +1 @@ +add_array("object.test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/test.fix new file mode 100644 index 00000000..f522fb86 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/test.fix @@ -0,0 +1 @@ +add_array("test[]", "dog", "cat", "bird") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/test.fix new file mode 100644 index 00000000..f522fb86 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/test.fix @@ -0,0 +1 @@ +add_array("test[]", "dog", "cat", "bird") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/test.fix new file mode 100644 index 00000000..a378e2f3 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/test.fix @@ -0,0 +1 @@ +add_array("test[]", "dog") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/test.fix new file mode 100644 index 00000000..b9d3a4c5 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/test.fix @@ -0,0 +1 @@ +add_array("test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix similarity index 50% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix index e302aa39..be7b5c3e 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix @@ -1,2 +1,2 @@ -set_array("test[]", "dog", "cat", "bird") +add_array("test[]", "dog", "cat", "bird") move_field("test[]", "animals[].1.test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix similarity index 61% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix index d82575a5..081eb775 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix @@ -1,2 +1,2 @@ -set_array("test[]", "dog") +add_array("test[]", "dog") move_field("test[]", "animals[].1.test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix similarity index 68% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix index 1b67b8e9..75db882f 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix @@ -1,2 +1,2 @@ -set_array("test[]") +add_array("test[]") move_field("test[]", "animals[].1.test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/todo.txt b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/todo.txt similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/todo.txt rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/todo.txt diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/copy_fieldToArrayOfStringsWithIndex/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/copy_fieldToArrayOfStringsWithIndex/test.fix index 42ce081d..9e04e9e8 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/copy_fieldToArrayOfStringsWithIndex/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/copy_fieldToArrayOfStringsWithIndex/test.fix @@ -1,4 +1,4 @@ -set_array("test[]") +add_array("test[]") copy_field("key", "test[].1") copy_field("key_2", "test[].2") copy_field("key_3", "test[].3") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/test.fix deleted file mode 100644 index 93e0a331..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/test.fix +++ /dev/null @@ -1 +0,0 @@ -set_array("animals_2[].$append.test[]", "test", "test", "test") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/test.fix deleted file mode 100644 index db69c8ad..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/test.fix +++ /dev/null @@ -1 +0,0 @@ -set_array("animals[].*.test[]", "test") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/test.fix deleted file mode 100644 index 2a7556c6..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/test.fix +++ /dev/null @@ -1 +0,0 @@ -set_array("animals_2[].$last.test[]", "test", "test") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/test.fix deleted file mode 100644 index 908eb3cc..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/test.fix +++ /dev/null @@ -1 +0,0 @@ -set_array("object.test[]", "dog", "cat", "bird") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/test.fix deleted file mode 100644 index 50056eb6..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/test.fix +++ /dev/null @@ -1 +0,0 @@ -set_array("object.test[]", "dog") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/test.fix deleted file mode 100644 index bef482f3..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/test.fix +++ /dev/null @@ -1 +0,0 @@ -set_array("object.test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/test.fix deleted file mode 100644 index 3bbe705d..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/test.fix +++ /dev/null @@ -1 +0,0 @@ -set_array("test[]", "dog", "cat", "bird") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/test.fix deleted file mode 100644 index 3bbe705d..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/test.fix +++ /dev/null @@ -1 +0,0 @@ -set_array("test[]", "dog", "cat", "bird") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/test.fix deleted file mode 100644 index ae3c2a8e..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/test.fix +++ /dev/null @@ -1 +0,0 @@ -set_array("test[]", "dog") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/test.fix deleted file mode 100644 index 9e4b09ee..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/test.fix +++ /dev/null @@ -1 +0,0 @@ -set_array("test[]") From 00838b677ace44ffce79abcc37c8c3767fa61801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Wed, 16 Oct 2024 14:53:11 +0200 Subject: [PATCH 3/9] Use add_hash instead of set_hash in integration tests #374 As a preliminary work for #309 since set_array will change its behaviour but add_array will keep the functionality. --- .../integration/method/fromXml/toJson/replace_toUpper/test.fix | 2 +- .../replace_toUpperStrictnessHandlesProcessExceptions/test.fix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpper/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpper/test.fix index 6bc9cbcd..9b6c18bb 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpper/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpper/test.fix @@ -1,5 +1,5 @@ do list(path: "700[01] ", "var": "$i") - set_hash("contribution[].$append.agent") + add_hash("contribution[].$append.agent") copy_field("$i.a", "contribution[].$last.agent.label") end diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpperStrictnessHandlesProcessExceptions/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpperStrictnessHandlesProcessExceptions/test.fix index 6bc9cbcd..9b6c18bb 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpperStrictnessHandlesProcessExceptions/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpperStrictnessHandlesProcessExceptions/test.fix @@ -1,5 +1,5 @@ do list(path: "700[01] ", "var": "$i") - set_hash("contribution[].$append.agent") + add_hash("contribution[].$append.agent") copy_field("$i.a", "contribution[].$last.agent.label") end From aea03a81d36aaf82b4a6ed3e0f6a5944cea7acd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Wed, 16 Oct 2024 15:04:41 +0200 Subject: [PATCH 4/9] Change further use of set_array to add_array and set_hash to set_hash #374 Additional preliminary work for #309 when the set-fixes change their functionality. --- README.md | 28 +++++++++- .../metafacture/metafix/MetafixBindTest.java | 32 +++++------ .../metafacture/metafix/MetafixIfTest.java | 8 +-- .../metafix/MetafixLookupTest.java | 44 +++++++-------- .../metafix/MetafixMethodTest.java | 44 +++++++-------- .../metafix/MetafixRecordTest.java | 56 +++++++++---------- .../metafix/MetafixScriptTest.java | 4 +- .../org/metafacture/metafix/fixes/include.fix | 2 +- .../org/metafacture/metafix/fixes/nested.fix | 2 +- 9 files changed, 123 insertions(+), 97 deletions(-) diff --git a/README.md b/README.md index b5d82efb..ce118d85 100644 --- a/README.md +++ b/README.md @@ -303,6 +303,19 @@ Options: #### Record-level functions +##### `add_array` + +Creates a new array (with optional values). + +```perl +add_array("") +add_array("", ""[, ...]) +``` + +[Example in Playground](https://metafacture.org/playground/?example=add_array) + +[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_array+{") + ##### `add_field` Creates a field with a defined value. @@ -315,6 +328,19 @@ add_field("", "") [Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_field+{") +##### `add_hash` + +Creates a new hash (with optional values). + +```perl +add_hash("") +add_hash("", "subfieldName": ""[, ...]) +``` + +[Example in Playground](https://metafacture.org/playground/?example=add_hash) + +[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_hash+{") + ##### `array` Converts a hash/object into an array. @@ -1027,7 +1053,7 @@ E.g.: ```perl # "ccm:university":["https://ror.org/0304hq317"] # "ccm:university_DISPLAYNAME":["Gottfried Wilhelm Leibniz Universität Hannover"] -set_array("sourceOrga[]") +add_array("sourceOrga[]") do list_as(orgId: "ccm:university[]", orgName: "ccm:university_DISPLAYNAME[]") copy_field(orgId, "sourceOrga[].$append.id") copy_field(orgName, "sourceOrga[].$last.name") diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java index 88917916..9ea85d1e 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java @@ -64,7 +64,7 @@ public void doList() { @Test public void doListExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('author')", + "add_array('author')", "do list('path': 'name', 'var': 'n')", " upcase('n')", " trim('n')", @@ -212,7 +212,7 @@ public void doListPathWithDots() { @Test public void doListPathWithDotsExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('author')", + "add_array('author')", "do list('path': 'some.name', 'var': 'n')", " upcase('n')", " trim('n')", @@ -237,7 +237,7 @@ public void doListPathWithDotsExplicitAppend() { @Test public void doListWithAppendAndLast() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('author[]')", + "add_array('author[]')", "do list('path': 'creator', 'var': 'c')", " copy_field('c.name', 'author[].$append.name')", " add_field('author[].$last.type', 'Default')", @@ -295,7 +295,7 @@ public void doListEntitesToLiterals() { @Test public void doListEntitesToLiteralsExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('author')", + "add_array('author')", "do list('path': 'creator', 'var': 'c')", " upcase('c.name')", " trim('c.name')", @@ -322,7 +322,7 @@ public void doListEntitesToLiteralsExplicitAppend() { @Test public void doListEntitesToEntities() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('author[]')", + "add_array('author[]')", "do list('path': 'creator', 'var': 'c')", " copy_field('c.name', 'author[].$append.name')", " if all_contain('c.name', 'University')", @@ -359,7 +359,7 @@ public void doListEntitesToEntities() { @Test public void wildcardForNestedEntities() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('author[]')", + "add_array('author[]')", "do list('path': 'creator', 'var': 'c')", " if any_match('c.role.*.roleTerm.*.value','aut|cre')", " copy_field('c.name', 'author[].$append.name')", @@ -430,7 +430,7 @@ public void doListIndexedArray() { @Test public void doListIndexedArrayToArrayOfObjects() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('author[]')", + "add_array('author[]')", "do list('path': 'name[]', 'var': 'n')", " copy_field('n', 'author[].$append.name')", "end", @@ -483,7 +483,7 @@ public void doListIndexedArrayOfObjects() { @Test public void doListIndexedArrayOfObjectsExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('author')", + "add_array('author')", "do list('path': 'name[]', 'var': 'n')", " copy_field('n.name', 'author.$append')", "end", @@ -510,7 +510,7 @@ public void doListIndexedArrayOfObjectsExplicitAppend() { @Test public void doListIndexedArrayOfObjectsToArrayOfObjects() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('author[]')", + "add_array('author[]')", "do list('path': 'name[]', 'var': 'n')", " copy_field('n.name', 'author[].$append.name')", "end", @@ -670,7 +670,7 @@ public void ifInCollectorCombine() { private void shouldIterateOverList(final String path, final int expectedCount) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('trace')", + "add_array('trace')", "do list(path: '" + path + "', 'var': '$i')", " add_field('trace.$append', 'true')", "end", @@ -716,7 +716,7 @@ public void shouldIterateOverListWithWildcard() { private void shouldIterateOverListOfHashes(final String path, final int expectedCount) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('trace')", + "add_array('trace')", "do list(path: '" + path + "', 'var': '$i')", " add_field('trace.$append', 'true')", "end", @@ -771,7 +771,7 @@ public void shouldIterateOverListOfHashesWithWildcard() { // See https://github.com/metafacture/metafacture-fix/issues/119 public void shouldPerformComplexOperationWithPathWildcard() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('coll[]')", + "add_array('coll[]')", "do list(path: 'feld?', 'var': '$i')", " add_field('coll[].$append.feldtest', 'true')", " copy_field('$i.a.value', 'coll[].$last.a')", @@ -847,7 +847,7 @@ public void shouldPerformComplexOperationWithPathWildcard() { @Test public void shouldDoListAsWithSingleList() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('sourceOrga[]')", + "add_array('sourceOrga[]')", "do list_as(orgId: 'ccm:university[]')", " copy_field(orgId, 'sourceOrga[].$append.id')", "end" @@ -881,7 +881,7 @@ public void shouldDoListAsWithSingleList() { @Test public void shouldDoListAsWithMultipleLists() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('sourceOrga[]')", + "add_array('sourceOrga[]')", "do list_as(orgId: 'ccm:university[]', orgName: 'ccm:university_DISPLAYNAME[]', orgLoc: 'ccm:university_LOCATION[]')", " copy_field(orgId, 'sourceOrga[].$append.id')", " copy_field(orgName, 'sourceOrga[].$last.name')", @@ -937,9 +937,9 @@ public void shouldDoListAsWithMultipleLists() { @Test // checkstyle-disable-line JavaNCSS public void shouldDoListAsWithMultipleListsOfDifferentSizes() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('sourceOrga[]')", + "add_array('sourceOrga[]')", "do list_as(orgId: 'ccm:university[]', orgName: 'ccm:university_DISPLAYNAME[]', orgLoc: 'ccm:university_LOCATION[]')", - " set_hash('sourceOrga[].$append')", + " add_hash('sourceOrga[].$append')", " copy_field(orgId, 'sourceOrga[].$last.id')", " copy_field(orgName, 'sourceOrga[].$last.name')", " copy_field(orgLoc, 'sourceOrga[].$last.location')", diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixIfTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixIfTest.java index 5b8000dc..35ab30fb 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixIfTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixIfTest.java @@ -1624,7 +1624,7 @@ public void shouldReportArrayEntityAsArray() { @Test public void shouldReportEmptyArrayAsArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array(foo)", + "add_array(foo)", "if is_array(foo)", " add_field(test,ok)", "end" @@ -1767,7 +1767,7 @@ public void shouldReportEmptyArrayEntityAsEmpty() { @Test public void shouldReportEmptyArrayAsEmpty() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array(foo)", + "add_array(foo)", "if is_empty(foo)", " add_field(test,ok)", "end" @@ -2127,7 +2127,7 @@ public void shouldReportHashAsObject() { @Test public void shouldReportEmptyHashAsObject() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_hash(foo)", + "add_hash(foo)", "if is_object(foo)", " add_field(test,ok)", "end" @@ -2499,7 +2499,7 @@ public void shouldMatchString() { @Test public void shouldTestMacroVariable() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('type')", + "add_array('type')", "do put_macro('test')", " if str_contain('name', 'a$[var]')", " add_field('type.$append', 'Organization: $[var]')", diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixLookupTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixLookupTest.java index d527fb80..579b2e19 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixLookupTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixLookupTest.java @@ -144,7 +144,7 @@ public void inlineDotNotationNested() { @Test public void shouldLookupInternalArrayWithAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('title', 'Aloha')", + "add_array('title', 'Aloha')", LOOKUP + " Aloha: Alohaeha)" ), i -> { @@ -162,7 +162,7 @@ public void shouldLookupInternalArrayWithAsterisk() { @Test public void shouldLookupDeduplicatedInternalArrayWithAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('title', 'Aloha', 'Aloha')", + "add_array('title', 'Aloha', 'Aloha')", "uniq('title')", LOOKUP + " Aloha: Alohaeha)" ), @@ -182,8 +182,8 @@ public void shouldLookupDeduplicatedInternalArrayWithAsterisk() { public void shouldNotLookupCopiedInternalArrayWithAsterisk() { MetafixTestHelpers.assertExecutionException(IllegalStateException.class, "Expected Array or Hash, got String", () -> MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('data', 'Aloha')", - "set_array('title')", + "add_array('data', 'Aloha')", + "add_array('title')", "copy_field('data', 'title')", LOOKUP + " Aloha: Alohaeha)" ), @@ -200,8 +200,8 @@ public void shouldNotLookupCopiedInternalArrayWithAsterisk() { @Test public void shouldLookupCopiedInternalArrayWithAsteriskExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('data', 'Aloha')", - "set_array('title')", + "add_array('data', 'Aloha')", + "add_array('title')", "copy_field('data', 'title.$append')", LOOKUP + " Aloha: Alohaeha)" ), @@ -222,9 +222,9 @@ public void shouldLookupCopiedInternalArrayWithAsteriskExplicitAppend() { public void shouldNotLookupCopiedDeduplicatedInternalArrayWithAsterisk() { MetafixTestHelpers.assertExecutionException(IllegalStateException.class, "Expected Array or Hash, got String", () -> MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('data', 'Aloha', 'Aloha')", + "add_array('data', 'Aloha', 'Aloha')", "uniq('data')", - "set_array('title')", + "add_array('title')", "copy_field('data', 'title')", LOOKUP + " Aloha: Alohaeha)" ), @@ -241,9 +241,9 @@ public void shouldNotLookupCopiedDeduplicatedInternalArrayWithAsterisk() { @Test public void shouldLookupCopiedDeduplicatedInternalArrayWithAsteriskExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('data', 'Aloha', 'Aloha')", + "add_array('data', 'Aloha', 'Aloha')", "uniq('data')", - "set_array('title')", + "add_array('title')", "copy_field('data', 'title.$append')", LOOKUP + " Aloha: Alohaeha)" ), @@ -263,7 +263,7 @@ public void shouldLookupCopiedDeduplicatedInternalArrayWithAsteriskExplicitAppen @Test public void shouldLookupCopiedExternalArrayWithAsteriskExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('title')", + "add_array('title')", "copy_field('data', 'title.$append')", LOOKUP + " Aloha: Alohaeha)" ), @@ -285,7 +285,7 @@ public void shouldLookupCopiedExternalArrayWithAsteriskExplicitAppend() { public void shouldLookupCopiedDeduplicatedExternalArrayWithAsteriskExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "uniq('data')", - "set_array('title')", + "add_array('title')", "copy_field('data', 'title.$append')", LOOKUP + " Aloha: Alohaeha)" ), @@ -309,7 +309,7 @@ public void shouldNotLookupMovedDeduplicatedExternalArrayWithAsterisk() { MetafixTestHelpers.assertExecutionException(IllegalStateException.class, "Expected Array or Hash, got String", () -> MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "uniq('data')", - "set_array('title')", + "add_array('title')", "move_field('data', 'title')", LOOKUP + " Aloha: Alohaeha)" ), @@ -329,7 +329,7 @@ public void shouldNotLookupMovedDeduplicatedExternalArrayWithAsterisk() { public void shouldLookupMovedDeduplicatedExternalArrayWithAsteriskExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "uniq('data')", - "set_array('title')", + "add_array('title')", "move_field('data', 'title.$append')", LOOKUP + " Aloha: Alohaeha)" ), @@ -351,7 +351,7 @@ public void shouldLookupMovedDeduplicatedExternalArrayWithAsteriskExplicitAppend public void shouldNotLookupMovedExternalArrayWithAsterisk() { MetafixTestHelpers.assertExecutionException(IllegalStateException.class, "Expected Array or Hash, got String", () -> MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('title')", + "add_array('title')", "move_field('data', 'title')", LOOKUP + " Aloha: Alohaeha)" ), @@ -369,7 +369,7 @@ public void shouldNotLookupMovedExternalArrayWithAsterisk() { @Test public void shouldLookupMovedExternalArrayWithAsteriskExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('title')", + "add_array('title')", "move_field('data', 'title.$append')", LOOKUP + " Aloha: Alohaeha)" ), @@ -994,9 +994,9 @@ public void shouldLookupInCopiedNestedArraysCreatedWithPrepend() { private void shouldLookupInCopiedNestedArraysCreatedWith(final String reservedField) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "put_map('rswk-indicator', s: 'SubjectHeading')", - "set_array('subject[]')", - "set_array('subject[]." + reservedField + ".componentList[]')", - "set_array('subject[].$last.componentList[]." + reservedField + ".type[]')", + "add_array('subject[]')", + "add_array('subject[]." + reservedField + ".componentList[]')", + "add_array('subject[].$last.componentList[]." + reservedField + ".type[]')", "do list(path: 'D', 'var': '$i')", " copy_field('$i', 'subject[].$last.componentList[].$last.type[]." + reservedField + "')", "end", @@ -1247,7 +1247,7 @@ public void shouldExplicitLookupRdfUrlWithRedirection() { @Test // Scenario 1 public void shouldLookupInExternalRdfMapGetObjectOfSubjectWithTargetedPredicateOfSpecificLanguage() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('prefLabel', 'https://w3id.org/kim/hochschulfaechersystematik/n4')", + "add_array('prefLabel', 'https://w3id.org/kim/hochschulfaechersystematik/n4')", "put_rdfmap('" + RDF_MAP + "', 'rdfmap', target: 'skos:prefLabel', select_language: 'de')", "lookup('prefLabel.*', 'rdfmap')" ), @@ -1266,7 +1266,7 @@ public void shouldLookupInExternalRdfMapGetObjectOfSubjectWithTargetedPredicateO @Test // Scenario 2 public void shouldLookupInExternalRdfMapGetSubjectWithTargetedPredicateOfSpecificLanguage() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('id', 'Mathematics, Natural Sciences')", + "add_array('id', 'Mathematics, Natural Sciences')", "put_rdfmap('" + RDF_MAP + "', 'rdfmap', target: 'skos:prefLabel', select_language: 'en')", "lookup('id.*', 'rdfmap')" ), @@ -1408,7 +1408,7 @@ public void shouldLookupRdfDefinedPropertyToSubject() { private void shouldLookupInExternalRdfMapGetObjectWithTargetedPredicateOfSpecificLanguage(final String target) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('prefLabel', 'Mathematics, Natural Sciences')", + "add_array('prefLabel', 'Mathematics, Natural Sciences')", "put_rdfmap('" + RDF_MAP + "', 'rdfmap', target: '" + target + "', select_language: 'de')", "lookup('prefLabel.*', 'rdfmap')" ), diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java index 8b167257..a430aef6 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java @@ -2153,7 +2153,7 @@ public void replaceAllInOptionalSubfieldInArrayOfObjectsWithAsterisk() { @Test public void inDoBindCopyFieldWithVarInSourceAndTarget() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('RSWK[]')", + "add_array('RSWK[]')", "do list(path: '650??', 'var': '$i')", " copy_field('$i.a', 'RSWK[].$append.subjectTopicName')", " copy_field('$i.v', 'RSWK[].$last.subjectGenre')", @@ -2191,7 +2191,7 @@ public void inDoBindCopyFieldWithVarInSourceAndTarget() { @Test public void replaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('RSWK[]')", + "add_array('RSWK[]')", "do list(path: '650??', 'var': '$i')", " copy_field('$i.a', 'RSWK[].$append.subjectTopicName')", " copy_field('$i.v', 'RSWK[].$last.subjectGenre')", @@ -2230,7 +2230,7 @@ public void replaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget() { @Test public void multipleReplaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('RSWK[]')", + "add_array('RSWK[]')", "do list(path: '650??', 'var': '$i')", " copy_field('$i.a', 'RSWK[].$append.subjectTopicName')", " copy_field('$i.v', 'RSWK[].$last.subjectGenre')", @@ -2271,7 +2271,7 @@ public void multipleReplaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget public void copyFieldToSubfieldOfArrayOfObjectsWithIndexImplicitAppend() { MetafixTestHelpers.assertProcessException(IllegalArgumentException.class, "Can't find: 1 in: null", () -> MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('test[]')", + "add_array('test[]')", "copy_field('key', 'test[].1.field')" ), i -> { @@ -2288,7 +2288,7 @@ public void copyFieldToSubfieldOfArrayOfObjectsWithIndexImplicitAppend() { @Test public void copyFieldToSubfieldOfArrayOfObjectsWithExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('test[]')", + "add_array('test[]')", "copy_field('key', 'test[].$append.field')" ), i -> { @@ -2312,7 +2312,7 @@ public void copyFieldToSubfieldOfArrayOfObjectsWithExplicitAppend() { public void copyFieldToSubfieldOfArrayOfStringsWithIndexImplicitAppend() { MetafixTestHelpers.assertProcessException(IndexOutOfBoundsException.class, "Index 0 out of bounds for length 0", () -> MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('test[]')", + "add_array('test[]')", "copy_field('key', 'test[].1')" ), i -> { @@ -2329,7 +2329,7 @@ public void copyFieldToSubfieldOfArrayOfStringsWithIndexImplicitAppend() { @Test public void copyFieldToSubfieldOfArrayOfStringsWithExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('test[]')", + "add_array('test[]')", "copy_field('key', 'test[].$append')" ), i -> { @@ -2442,7 +2442,7 @@ public void addFieldIntoArrayOfObjectsWithLastWildcardLastEmpty() { @Test public void shouldReplaceAllRegexesInCopiedArraySubField() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('coll[]')", + "add_array('coll[]')", "copy_field('a', 'coll[].$append.a')", "replace_all('coll[].*.a', 'o', '__')" ), @@ -2466,7 +2466,7 @@ public void shouldReplaceAllRegexesInCopiedArraySubField() { @Test public void shouldReplaceAllRegexesInMovedArraySubField() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('coll[]')", + "add_array('coll[]')", "move_field('a', 'coll[].$append.a')", "replace_all('coll[].*.a', 'o', '__')" ), @@ -2489,7 +2489,7 @@ public void shouldReplaceAllRegexesInMovedArraySubField() { @Test public void shouldReplaceAllRegexesInCopiedArraySubFieldOriginal() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('coll[]')", + "add_array('coll[]')", "copy_field('a', 'coll[].$append.a')", "replace_all('a', 'o', '__')" ), @@ -2513,7 +2513,7 @@ public void shouldReplaceAllRegexesInCopiedArraySubFieldOriginal() { @Test public void shouldReplaceAllRegexesInListCopiedArraySubField() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('coll[]')", + "add_array('coll[]')", "do list(path: 'a', 'var': '$i')", " copy_field('$i', 'coll[].$append.a')", "end", @@ -2539,7 +2539,7 @@ public void shouldReplaceAllRegexesInListCopiedArraySubField() { @Test public void shouldCopyBindVarWithDollarAfterLookup() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('@coll[]')", + "add_array('@coll[]')", "do list(path: 'a', 'var': '$i')", " lookup('$i.name')", " copy_field('$i.name', '@coll[].$append')", @@ -2566,7 +2566,7 @@ public void shouldCopyBindVarWithDollarAfterLookup() { @Test public void shouldCopyToFieldWithIndexAndReservedFieldName() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('a[].*.test[]', 'test')", + "add_array('a[].*.test[]', 'test')", "copy_field('some', 'a[].1.test[].$append')", "remove_field('some')" ), @@ -2605,7 +2605,7 @@ public void shouldCopyToFieldWithIndexAndReservedFieldName() { @Test public void shouldCopyToFieldWithTwoReservedFieldNames() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('a[].*.test[]', 'test')", + "add_array('a[].*.test[]', 'test')", "copy_field('some', 'a[].$first.test[].$append')", "remove_field('some')" ), @@ -2807,11 +2807,11 @@ public void addFieldWithReplaceAllArray() { private void addFieldWithReplaceAllArray(final boolean replaceAll) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "do list(path: 'contribution[]', 'var': '$i')", - " set_array('$i.agent.altLabel[]')", + " add_array('$i.agent.altLabel[]')", " add_field('$i.agent.altLabel[].$append', 'contribution')", "end", "do list(path: 'subject[]', 'var': '$i')", - " set_array('$i.altLabel[]')", + " add_array('$i.altLabel[]')", " add_field('$i.altLabel[].$append', 'subject')", "end", replaceAll ? "replace_all('contribution[].*.agent.altLabel[].*', 't', '')" : "", @@ -2864,10 +2864,10 @@ public void setArrayWithReplaceAll() { private void setArrayWithReplaceAll(final boolean replaceAll) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "do list(path: 'contribution[]', 'var': '$i')", - " set_array('$i.agent.altLabel[]', 'contribution')", + " add_array('$i.agent.altLabel[]', 'contribution')", "end", "do list(path: 'subject[]', 'var': '$i')", - " set_array('$i.altLabel[]', 'subject')", + " add_array('$i.altLabel[]', 'subject')", "end", replaceAll ? "replace_all('contribution[].*.agent.altLabel[].*', 't', '')" : "", replaceAll ? "replace_all('subject[].*.altLabel[].*', 't', '')" : "" @@ -2919,11 +2919,11 @@ public void copyFieldWithReplaceAllArray() { private void copyFieldWithReplaceAllArray(final boolean replaceAll) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "do list(path: 'contribution[]', 'var': '$i')", - " set_array('$i.agent.altLabel[]')", + " add_array('$i.agent.altLabel[]')", " copy_field('$i.label', '$i.agent.altLabel[].$append')", "end", "do list(path: 'subject[]', 'var': '$i')", - " set_array('$i.altLabel[]')", + " add_array('$i.altLabel[]')", " copy_field('$i.label', '$i.altLabel[].$append')", "end", replaceAll ? "replace_all('contribution[].*.agent.altLabel[].*', 't', '')" : "", @@ -2976,11 +2976,11 @@ public void pasteWithReplaceAll() { private void pasteWithReplaceAll(final boolean replaceAll) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "do list(path: 'contribution[]', 'var': '$i')", - " set_array('$i.agent.altLabel[]')", + " add_array('$i.agent.altLabel[]')", " paste('$i.agent.altLabel[].$append', '$i.label', '~!')", "end", "do list(path: 'subject[]', 'var': '$i')", - " set_array('$i.altLabel[]')", + " add_array('$i.altLabel[]')", " paste('$i.altLabel[].$append', '$i.label', '~!')", "end", replaceAll ? "replace_all('contribution[].*.agent.altLabel[].*', ' !', '')" : "", diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixRecordTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixRecordTest.java index b8c13b87..0d17e6d1 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixRecordTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixRecordTest.java @@ -261,7 +261,7 @@ public void add() { @Test public void addWithAppendInNewArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('my.name')", + "add_array('my.name')", "add_field('my.name.$append','patrick')", "add_field('my.name.$append','nicolas')" ), @@ -634,7 +634,7 @@ public void complexAppendWithArrayOfObjects() { @Test public void appendWithWildcard() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('stringimals[]')", + "add_array('stringimals[]')", "copy_field('?nimal', 'stringimals[].$append')" ), i -> { @@ -697,7 +697,7 @@ public void simpleCopyWithWildcard() { @Test public void appendWithMultipleWildcards() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('stringimals[]')", + "add_array('stringimals[]')", "copy_field('?ni??l', 'stringimals[].$append')" ), i -> { @@ -728,7 +728,7 @@ public void appendWithMultipleWildcards() { @Test public void appendWithAsteriksWildcard() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('stringimals[]')", + "add_array('stringimals[]')", "copy_field('*al', 'stringimals[].$append')" ), i -> { @@ -758,7 +758,7 @@ public void appendWithAsteriksWildcard() { @Test public void appendWithBracketWildcard() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('stringimals[]')", + "add_array('stringimals[]')", "copy_field('[ac]nimal', 'stringimals[].$append')" ), i -> { @@ -788,7 +788,7 @@ public void appendWithBracketWildcard() { // See https://github.com/metafacture/metafacture-fix/issues/89 public void appendWithAsteriksWildcardAtTheEnd() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('stringimals[]')", + "add_array('stringimals[]')", "copy_field('ani*', 'stringimals[].$append')" ), i -> { @@ -833,7 +833,7 @@ public void appendWithAsteriksWildcardAtTheEnd() { @MetafixToDo("See https://github.com/metafacture/metafacture-fix/pull/113") public void shouldCopyArrayFieldWithoutAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('TEST_TWO[]')", + "add_array('TEST_TWO[]')", "copy_field('test[]', 'TEST_TWO[].$append')" ), i -> { @@ -894,7 +894,7 @@ public void copyFieldArrayOfObjectsAndListNewArrayOfObjectsAndMoveSubfield() { // See https://github.com/metafacture/metafacture-fix/issues/121 public void shouldCopyArrayFieldWithAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('TEST_TWO[]')", + "add_array('TEST_TWO[]')", "copy_field('test[].*', 'TEST_TWO[].$append')" ), i -> { @@ -927,7 +927,7 @@ public void shouldCopyArrayFieldWithAsterisk() { // See https://github.com/metafacture/metafacture-fix/issues/121 public void shouldCopyNestedArrayFieldWithAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('TEST_4[]')", + "add_array('TEST_4[]')", "copy_field('nestedTest[].*.test[].*', 'TEST_4[].$append')" ), i -> { @@ -982,7 +982,7 @@ public void shouldCopyNestedArrayFieldWithAsterisk() { // See https://github.com/metafacture/metafacture-fix/issues/121 public void shouldCopyArraySubFieldWithAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('TEST_5[]')", + "add_array('TEST_5[]')", "copy_field('coll[].*.b', 'TEST_5[].$append')" ), i -> { @@ -1402,7 +1402,7 @@ public void copy() { @Test public void copyIntoArrayOfStrings() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - // "set_array('author')", <- results in separate objects/entities here + // "add_array('author')", <- results in separate objects/entities here "copy_field('your.name','author.name[]')", "remove_field('your')"), i -> { @@ -1582,7 +1582,7 @@ public void copyIntoImplicitArrayPrepend() { @Test public void copyIntoExplicitArrayAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('author[]')", + "add_array('author[]')", "copy_field('your.name','author[].$append.name')", "remove_field('your')"), i -> { @@ -1610,7 +1610,7 @@ public void copyIntoExplicitArrayAppend() { @Test public void copyIntoArrayTopLevel() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('author[]')", + "add_array('author[]')", "copy_field('your.name', 'author[]')", "remove_field('your')"), i -> { @@ -1854,7 +1854,7 @@ public void removeArrayElementsByWildcard() { @Test public void setArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('foo[]','a','b','c')"), + "add_array('foo[]','a','b','c')"), i -> { i.startRecord("1"); i.endRecord(); @@ -1873,7 +1873,7 @@ public void setArray() { // See https://github.com/metafacture/metafacture-fix/issues/111 public void setArrayReplaceExisting() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('foo[]','a','b','c')"), + "add_array('foo[]','a','b','c')"), i -> { i.startRecord("1"); i.startEntity("foo[]"); @@ -1897,7 +1897,7 @@ public void setArrayReplaceExisting() { // See https://github.com/metafacture/metafacture-fix/issues/130 public void setArrayInArrayWithAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('foo[].*.test[]', 'test')"), + "add_array('foo[].*.test[]', 'test')"), i -> { i.startRecord("1"); i.startEntity("foo[]"); @@ -1929,7 +1929,7 @@ public void setArrayInArrayWithAsterisk() { @Test public void setHash() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_hash('foo','a': 'b','c': 'd')"), + "add_hash('foo','a': 'b','c': 'd')"), i -> { i.startRecord("1"); i.endRecord(); @@ -1947,7 +1947,7 @@ public void setHash() { // See https://github.com/metafacture/metafacture-fix/issues/111 public void setHashReplaceExisting() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_hash('foo','a': 'b','c': 'd')"), + "add_hash('foo','a': 'b','c': 'd')"), i -> { i.startRecord("1"); i.startEntity("foo"); @@ -2131,7 +2131,7 @@ public void shouldPrintRecordToFile() throws IOException { @Test public void hashFromArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('foo','a','b','c','d')", + "add_array('foo','a','b','c','d')", "hash('foo')"), i -> { i.startRecord("1"); @@ -2149,7 +2149,7 @@ public void hashFromArray() { @Test public void arrayFromHash() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_hash('foo','a': 'b','c': 'd')", + "add_hash('foo','a': 'b','c': 'd')", "array('foo')"), i -> { i.startRecord("1"); @@ -2167,7 +2167,7 @@ public void arrayFromHash() { @Test public void shouldCallMacro() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('test')", + "add_array('test')", "do put_macro('test')", " add_field('test.$append', '42')", "end", @@ -2206,7 +2206,7 @@ public void shouldNotCallUnknownMacro() { @Test public void shouldCallMacroWithVariables() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('test')", + "add_array('test')", "put_vars(a: '1', b: '2')", // global variables "do put_macro('test', b: '22', c: '33')", // "static" local variables " add_field('test.$append', '$[a]-$[b]-$[c]-$[d]')", @@ -2412,11 +2412,11 @@ public void reject() { } @Test - @MetafixToDo("Is set_array with $append something we need/want? WDCD?") + @MetafixToDo("Is add_array with $append something we need/want? WDCD?") public void appendArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('nums[]', '1')", - "set_array('nums[].$append', '2', '3')"), + "add_array('nums[]', '1')", + "add_array('nums[].$append', '2', '3')"), i -> { i.startRecord("1"); i.endRecord(); @@ -2434,8 +2434,8 @@ public void appendArray() { @Test public void mixedArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('@context[]', 'https://w3id.org/kim/lrmi-profile/draft/context.jsonld')", - "set_hash('@context[].$append', '@language': 'de')"), + "add_array('@context[]', 'https://w3id.org/kim/lrmi-profile/draft/context.jsonld')", + "add_hash('@context[].$append', '@language': 'de')"), i -> { i.startRecord("1"); i.endRecord(); @@ -3384,7 +3384,7 @@ public void shouldAddRandomNumberToMarkedArray() { @Test public void shouldAddObjectWithRandomNumberToMarkedArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('bnimals[]')", + "add_array('bnimals[]')", "random('bnimals[].$append.number', '100')" ), i -> { diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixScriptTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixScriptTest.java index 2141ed05..57c11016 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixScriptTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixScriptTest.java @@ -228,7 +228,7 @@ public void shouldDoNothing() { @Test public void shouldIncludeFixFile() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('trace')", + "add_array('trace')", "add_field('trace.$append', 'before include')", "include('src/test/resources/org/metafacture/metafix/fixes/base.fix')", "add_field('trace.$append', 'after include')" @@ -307,7 +307,7 @@ public void shouldNotLeakVariablesFromIncludingFixFile() { @Test public void shouldIncludeFixFileInBind() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "set_array('trace')", + "add_array('trace')", "add_field('trace.$append', 'before bind')", "do list(path: 'data', 'var': '$i')", " paste('trace.$append', '~before include', '$i')", diff --git a/metafix/src/test/resources/org/metafacture/metafix/fixes/include.fix b/metafix/src/test/resources/org/metafacture/metafix/fixes/include.fix index 9f8f6d39..8bf6cb2a 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/fixes/include.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/fixes/include.fix @@ -1,5 +1,5 @@ unless exists("trace") - set_array("trace") + add_array("trace") end add_field("trace.$append", "before include") include("./base.fix") diff --git a/metafix/src/test/resources/org/metafacture/metafix/fixes/nested.fix b/metafix/src/test/resources/org/metafacture/metafix/fixes/nested.fix index 33c9ede0..6ffe9317 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/fixes/nested.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/fixes/nested.fix @@ -1,4 +1,4 @@ -set_array("trace") +add_array("trace") add_field("trace.$append", "before nested") include("src/test/resources/org/metafacture/metafix/fixes/include.fix") add_field("trace.$append", "after nested") From c9fc49bc1e3538c396a97a6857a9cb4cce86b71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Tue, 29 Oct 2024 11:01:46 +0100 Subject: [PATCH 5/9] Change set_field, set_array and set_hash to aliases #374 --- .../main/java/org/metafacture/metafix/FixMethod.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/metafix/src/main/java/org/metafacture/metafix/FixMethod.java b/metafix/src/main/java/org/metafacture/metafix/FixMethod.java index 059efec2..644e9cc3 100644 --- a/metafix/src/main/java/org/metafacture/metafix/FixMethod.java +++ b/metafix/src/main/java/org/metafacture/metafix/FixMethod.java @@ -408,24 +408,19 @@ public void apply(final Metafix metafix, final Record record, final List set_array { @Override public void apply(final Metafix metafix, final Record record, final List params, final Map options) { - final String field = params.get(0); - final Value newValue = newArray(params.subList(1, params.size()).stream().map(Value::new)); - record.set(field, newValue); - newValue.asArray().forEach(value -> value.withPathSet(newValue.getPath() + "." + value.getPath())); + add_array.apply(metafix, record, params, options); } }, set_field { @Override public void apply(final Metafix metafix, final Record record, final List params, final Map options) { - record.set(params.get(0), new Value(params.get(1))); + add_field.apply(metafix, record, params, options); } }, set_hash { @Override public void apply(final Metafix metafix, final Record record, final List params, final Map options) { - final String field = params.get(0); - final Value newValue = Value.newHash(h -> options.forEach((f, v) -> h.put(f, new Value(v)))); - record.set(field, newValue); + add_hash.apply(metafix, record, params, options); } }, timestamp { From 5d198fd29678a302f295d49d7f11b4e430800e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Tue, 29 Oct 2024 11:02:43 +0100 Subject: [PATCH 6/9] Revert "Use add_array instead of set_array in integration tests #374" This reverts commit 19051fb17b09af4730b76e6d8c1087f0e79c12e2. --- .../toJson/lookupInDeeplyNestedArrayOfObjects/test.fix | 8 ++++---- .../test.fix | 2 +- .../toJson/add_arrayIntoArrayOfObjectsWithAppend/test.fix | 1 - .../add_arrayIntoArrayOfObjectsWithAsterisk/test.fix | 1 - .../toJson/add_arrayIntoArrayOfObjectsWithLast/test.fix | 1 - .../add_arrayNestedSimpleWithMultipleValues/test.fix | 1 - .../toJson/add_arrayNestedSimpleWithSingleValue/test.fix | 1 - .../toJson/add_arrayNestedSimpleWithoutValues/test.fix | 1 - .../fromJson/toJson/add_arraySimpleDestructive/test.fix | 1 - .../toJson/add_arraySimpleWithMultipleValues/test.fix | 1 - .../toJson/add_arraySimpleWithSingleValue/test.fix | 1 - .../fromJson/toJson/add_arraySimpleWithoutValues/test.fix | 1 - .../toJson/copy_fieldToArrayOfStringsWithIndex/test.fix | 2 +- .../expected.json | 0 .../input.json | 0 .../toJson/set_arrayIntoArrayOfObjectsWithAppend/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../set_arrayIntoArrayOfObjectsWithAsterisk/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../toJson/set_arrayIntoArrayOfObjectsWithLast/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../set_arrayNestedSimpleWithMultipleValues/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../toJson/set_arrayNestedSimpleWithSingleValue/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../toJson/set_arrayNestedSimpleWithoutValues/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../fromJson/toJson/set_arraySimpleDestructive/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../toJson/set_arraySimpleWithMultipleValues/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../toJson/set_arraySimpleWithSingleValue/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../fromJson/toJson/set_arraySimpleWithoutValues/test.fix | 1 + .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../test.fix | 2 +- .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../test.fix | 2 +- .../test.flux | 0 .../expected.json | 0 .../input.json | 0 .../test.fix | 2 +- .../test.flux | 0 .../todo.txt | 0 66 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/test.fix delete mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayIntoArrayOfObjectsWithAppend => set_arrayIntoArrayOfObjectsWithAppend}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayIntoArrayOfObjectsWithAppend => set_arrayIntoArrayOfObjectsWithAppend}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayIntoArrayOfObjectsWithAppend => set_arrayIntoArrayOfObjectsWithAppend}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayIntoArrayOfObjectsWithAsterisk => set_arrayIntoArrayOfObjectsWithAsterisk}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayIntoArrayOfObjectsWithAsterisk => set_arrayIntoArrayOfObjectsWithAsterisk}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayIntoArrayOfObjectsWithAsterisk => set_arrayIntoArrayOfObjectsWithAsterisk}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayIntoArrayOfObjectsWithLast => set_arrayIntoArrayOfObjectsWithLast}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayIntoArrayOfObjectsWithLast => set_arrayIntoArrayOfObjectsWithLast}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayIntoArrayOfObjectsWithLast => set_arrayIntoArrayOfObjectsWithLast}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayNestedSimpleWithMultipleValues => set_arrayNestedSimpleWithMultipleValues}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayNestedSimpleWithMultipleValues => set_arrayNestedSimpleWithMultipleValues}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayNestedSimpleWithMultipleValues => set_arrayNestedSimpleWithMultipleValues}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayNestedSimpleWithSingleValue => set_arrayNestedSimpleWithSingleValue}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayNestedSimpleWithSingleValue => set_arrayNestedSimpleWithSingleValue}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayNestedSimpleWithSingleValue => set_arrayNestedSimpleWithSingleValue}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayNestedSimpleWithoutValues => set_arrayNestedSimpleWithoutValues}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayNestedSimpleWithoutValues => set_arrayNestedSimpleWithoutValues}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayNestedSimpleWithoutValues => set_arrayNestedSimpleWithoutValues}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arraySimpleDestructive => set_arraySimpleDestructive}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arraySimpleDestructive => set_arraySimpleDestructive}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arraySimpleDestructive => set_arraySimpleDestructive}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arraySimpleWithMultipleValues => set_arraySimpleWithMultipleValues}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arraySimpleWithMultipleValues => set_arraySimpleWithMultipleValues}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arraySimpleWithMultipleValues => set_arraySimpleWithMultipleValues}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arraySimpleWithSingleValue => set_arraySimpleWithSingleValue}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arraySimpleWithSingleValue => set_arraySimpleWithSingleValue}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arraySimpleWithSingleValue => set_arraySimpleWithSingleValue}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arraySimpleWithoutValues => set_arraySimpleWithoutValues}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arraySimpleWithoutValues => set_arraySimpleWithoutValues}/input.json (100%) create mode 100644 metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/test.fix rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arraySimpleWithoutValues => set_arraySimpleWithoutValues}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/input.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/test.fix (50%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/input.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/test.fix (61%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/expected.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/input.json (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/test.fix (68%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/test.flux (100%) rename metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/{add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects => set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects}/todo.txt (100%) diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/lookup/fromXml/toJson/lookupInDeeplyNestedArrayOfObjects/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/lookup/fromXml/toJson/lookupInDeeplyNestedArrayOfObjects/test.fix index 6a94986c..6a9c42c5 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/lookup/fromXml/toJson/lookupInDeeplyNestedArrayOfObjects/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/lookup/fromXml/toJson/lookupInDeeplyNestedArrayOfObjects/test.fix @@ -1,11 +1,11 @@ put_map("rswk-indicator", s: "SubjectHeading") if exists("6890?") - add_array("subject[].$append.type[]", "ComplexSubject") - add_array("subject[].$last.label") - add_array("subject[].$last.componentList[]") + set_array("subject[].$append.type[]", "ComplexSubject") + set_array("subject[].$last.label") + set_array("subject[].$last.componentList[]") do list(path: "6890?", "var": "$i") - add_array("subject[].$last.componentList[].$append.type[]") + set_array("subject[].$last.componentList[].$append.type[]") do list(path: "$i.D", "var": "$k") copy_field("$k", "subject[].$last.componentList[].$last.type[].$append") end diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_allInOptionalSubfieldOfRepeatedObjectsWithAsterisk/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_allInOptionalSubfieldOfRepeatedObjectsWithAsterisk/test.fix index 7640d1b1..9c1c1c44 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_allInOptionalSubfieldOfRepeatedObjectsWithAsterisk/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_allInOptionalSubfieldOfRepeatedObjectsWithAsterisk/test.fix @@ -1,4 +1,4 @@ -add_array("RSWK[]") +set_array("RSWK[]") do list(path: "650??", "var": "$i") copy_field("$i.a", "RSWK[].$append.subjectTopicName") copy_field("$i.v", "RSWK[].$last.subjectGenre") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/test.fix deleted file mode 100644 index 4d1b7dd6..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/test.fix +++ /dev/null @@ -1 +0,0 @@ -add_array("animals_2[].$append.test[]", "test", "test", "test") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/test.fix deleted file mode 100644 index 100ed906..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/test.fix +++ /dev/null @@ -1 +0,0 @@ -add_array("animals[].*.test[]", "test") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/test.fix deleted file mode 100644 index 9646ad25..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/test.fix +++ /dev/null @@ -1 +0,0 @@ -add_array("animals_2[].$last.test[]", "test", "test") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/test.fix deleted file mode 100644 index f89d1fa5..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/test.fix +++ /dev/null @@ -1 +0,0 @@ -add_array("object.test[]", "dog", "cat", "bird") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/test.fix deleted file mode 100644 index 7e3807e3..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/test.fix +++ /dev/null @@ -1 +0,0 @@ -add_array("object.test[]", "dog") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/test.fix deleted file mode 100644 index d1c64633..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/test.fix +++ /dev/null @@ -1 +0,0 @@ -add_array("object.test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/test.fix deleted file mode 100644 index f522fb86..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/test.fix +++ /dev/null @@ -1 +0,0 @@ -add_array("test[]", "dog", "cat", "bird") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/test.fix deleted file mode 100644 index f522fb86..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/test.fix +++ /dev/null @@ -1 +0,0 @@ -add_array("test[]", "dog", "cat", "bird") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/test.fix deleted file mode 100644 index a378e2f3..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/test.fix +++ /dev/null @@ -1 +0,0 @@ -add_array("test[]", "dog") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/test.fix deleted file mode 100644 index b9d3a4c5..00000000 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/test.fix +++ /dev/null @@ -1 +0,0 @@ -add_array("test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/copy_fieldToArrayOfStringsWithIndex/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/copy_fieldToArrayOfStringsWithIndex/test.fix index 9e04e9e8..42ce081d 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/copy_fieldToArrayOfStringsWithIndex/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/copy_fieldToArrayOfStringsWithIndex/test.fix @@ -1,4 +1,4 @@ -add_array("test[]") +set_array("test[]") copy_field("key", "test[].1") copy_field("key_2", "test[].2") copy_field("key_3", "test[].3") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/test.fix new file mode 100644 index 00000000..93e0a331 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/test.fix @@ -0,0 +1 @@ +set_array("animals_2[].$append.test[]", "test", "test", "test") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAppend/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAppend/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/test.fix new file mode 100644 index 00000000..db69c8ad --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/test.fix @@ -0,0 +1 @@ +set_array("animals[].*.test[]", "test") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithAsterisk/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithAsterisk/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/test.fix new file mode 100644 index 00000000..2a7556c6 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/test.fix @@ -0,0 +1 @@ +set_array("animals_2[].$last.test[]", "test", "test") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayIntoArrayOfObjectsWithLast/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayIntoArrayOfObjectsWithLast/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/test.fix new file mode 100644 index 00000000..908eb3cc --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/test.fix @@ -0,0 +1 @@ +set_array("object.test[]", "dog", "cat", "bird") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithMultipleValues/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithMultipleValues/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/test.fix new file mode 100644 index 00000000..50056eb6 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/test.fix @@ -0,0 +1 @@ +set_array("object.test[]", "dog") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithSingleValue/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithSingleValue/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/test.fix new file mode 100644 index 00000000..bef482f3 --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/test.fix @@ -0,0 +1 @@ +set_array("object.test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayNestedSimpleWithoutValues/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayNestedSimpleWithoutValues/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/test.fix new file mode 100644 index 00000000..3bbe705d --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/test.fix @@ -0,0 +1 @@ +set_array("test[]", "dog", "cat", "bird") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleDestructive/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleDestructive/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/test.fix new file mode 100644 index 00000000..3bbe705d --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/test.fix @@ -0,0 +1 @@ +set_array("test[]", "dog", "cat", "bird") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithMultipleValues/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithMultipleValues/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/test.fix new file mode 100644 index 00000000..ae3c2a8e --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/test.fix @@ -0,0 +1 @@ +set_array("test[]", "dog") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithSingleValue/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithSingleValue/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/test.fix new file mode 100644 index 00000000..9e4b09ee --- /dev/null +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/test.fix @@ -0,0 +1 @@ +set_array("test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arraySimpleWithoutValues/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arraySimpleWithoutValues/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix similarity index 50% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix index be7b5c3e..e302aa39 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix @@ -1,2 +1,2 @@ -add_array("test[]", "dog", "cat", "bird") +set_array("test[]", "dog", "cat", "bird") move_field("test[]", "animals[].1.test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithMultipleValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix similarity index 61% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix index 081eb775..d82575a5 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix @@ -1,2 +1,2 @@ -add_array("test[]", "dog") +set_array("test[]", "dog") move_field("test[]", "animals[].1.test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithSingleValueAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/expected.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/input.json diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix similarity index 68% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix index 75db882f..1b67b8e9 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.fix @@ -1,2 +1,2 @@ -add_array("test[]") +set_array("test[]") move_field("test[]", "animals[].1.test[]") diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/test.flux diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/todo.txt b/metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/todo.txt similarity index 100% rename from metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/add_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/todo.txt rename to metafix/src/test/resources/org/metafacture/metafix/integration/record/fromJson/toJson/set_arrayWithoutValuesAndMove_fieldNewArrayOfStringsIntoArrayOfObjects/todo.txt From 840db075d1ea941949125f0dccd5cd20313e21b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Tue, 29 Oct 2024 11:02:54 +0100 Subject: [PATCH 7/9] Revert "Use add_hash instead of set_hash in integration tests #374" This reverts commit 00838b677ace44ffce79abcc37c8c3767fa61801. --- .../integration/method/fromXml/toJson/replace_toUpper/test.fix | 2 +- .../replace_toUpperStrictnessHandlesProcessExceptions/test.fix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpper/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpper/test.fix index 9b6c18bb..6bc9cbcd 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpper/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpper/test.fix @@ -1,5 +1,5 @@ do list(path: "700[01] ", "var": "$i") - add_hash("contribution[].$append.agent") + set_hash("contribution[].$append.agent") copy_field("$i.a", "contribution[].$last.agent.label") end diff --git a/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpperStrictnessHandlesProcessExceptions/test.fix b/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpperStrictnessHandlesProcessExceptions/test.fix index 9b6c18bb..6bc9cbcd 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpperStrictnessHandlesProcessExceptions/test.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/integration/method/fromXml/toJson/replace_toUpperStrictnessHandlesProcessExceptions/test.fix @@ -1,5 +1,5 @@ do list(path: "700[01] ", "var": "$i") - add_hash("contribution[].$append.agent") + set_hash("contribution[].$append.agent") copy_field("$i.a", "contribution[].$last.agent.label") end From ec7f7a3e87af0a33cdd3fc2493a16534e03147b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Tue, 29 Oct 2024 11:03:41 +0100 Subject: [PATCH 8/9] Revert "Change further use of set_array to add_array and set_hash to set_hash #374" This reverts commit aea03a81d36aaf82b4a6ed3e0f6a5944cea7acd9. --- README.md | 28 +--------- .../metafacture/metafix/MetafixBindTest.java | 32 +++++------ .../metafacture/metafix/MetafixIfTest.java | 8 +-- .../metafix/MetafixLookupTest.java | 44 +++++++-------- .../metafix/MetafixMethodTest.java | 44 +++++++-------- .../metafix/MetafixRecordTest.java | 56 +++++++++---------- .../metafix/MetafixScriptTest.java | 4 +- .../org/metafacture/metafix/fixes/include.fix | 2 +- .../org/metafacture/metafix/fixes/nested.fix | 2 +- 9 files changed, 97 insertions(+), 123 deletions(-) diff --git a/README.md b/README.md index ce118d85..b5d82efb 100644 --- a/README.md +++ b/README.md @@ -303,19 +303,6 @@ Options: #### Record-level functions -##### `add_array` - -Creates a new array (with optional values). - -```perl -add_array("") -add_array("", ""[, ...]) -``` - -[Example in Playground](https://metafacture.org/playground/?example=add_array) - -[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_array+{") - ##### `add_field` Creates a field with a defined value. @@ -328,19 +315,6 @@ add_field("", "") [Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_field+{") -##### `add_hash` - -Creates a new hash (with optional values). - -```perl -add_hash("") -add_hash("", "subfieldName": ""[, ...]) -``` - -[Example in Playground](https://metafacture.org/playground/?example=add_hash) - -[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_hash+{") - ##### `array` Converts a hash/object into an array. @@ -1053,7 +1027,7 @@ E.g.: ```perl # "ccm:university":["https://ror.org/0304hq317"] # "ccm:university_DISPLAYNAME":["Gottfried Wilhelm Leibniz Universität Hannover"] -add_array("sourceOrga[]") +set_array("sourceOrga[]") do list_as(orgId: "ccm:university[]", orgName: "ccm:university_DISPLAYNAME[]") copy_field(orgId, "sourceOrga[].$append.id") copy_field(orgName, "sourceOrga[].$last.name") diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java index 9ea85d1e..88917916 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixBindTest.java @@ -64,7 +64,7 @@ public void doList() { @Test public void doListExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('author')", + "set_array('author')", "do list('path': 'name', 'var': 'n')", " upcase('n')", " trim('n')", @@ -212,7 +212,7 @@ public void doListPathWithDots() { @Test public void doListPathWithDotsExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('author')", + "set_array('author')", "do list('path': 'some.name', 'var': 'n')", " upcase('n')", " trim('n')", @@ -237,7 +237,7 @@ public void doListPathWithDotsExplicitAppend() { @Test public void doListWithAppendAndLast() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('author[]')", + "set_array('author[]')", "do list('path': 'creator', 'var': 'c')", " copy_field('c.name', 'author[].$append.name')", " add_field('author[].$last.type', 'Default')", @@ -295,7 +295,7 @@ public void doListEntitesToLiterals() { @Test public void doListEntitesToLiteralsExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('author')", + "set_array('author')", "do list('path': 'creator', 'var': 'c')", " upcase('c.name')", " trim('c.name')", @@ -322,7 +322,7 @@ public void doListEntitesToLiteralsExplicitAppend() { @Test public void doListEntitesToEntities() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('author[]')", + "set_array('author[]')", "do list('path': 'creator', 'var': 'c')", " copy_field('c.name', 'author[].$append.name')", " if all_contain('c.name', 'University')", @@ -359,7 +359,7 @@ public void doListEntitesToEntities() { @Test public void wildcardForNestedEntities() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('author[]')", + "set_array('author[]')", "do list('path': 'creator', 'var': 'c')", " if any_match('c.role.*.roleTerm.*.value','aut|cre')", " copy_field('c.name', 'author[].$append.name')", @@ -430,7 +430,7 @@ public void doListIndexedArray() { @Test public void doListIndexedArrayToArrayOfObjects() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('author[]')", + "set_array('author[]')", "do list('path': 'name[]', 'var': 'n')", " copy_field('n', 'author[].$append.name')", "end", @@ -483,7 +483,7 @@ public void doListIndexedArrayOfObjects() { @Test public void doListIndexedArrayOfObjectsExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('author')", + "set_array('author')", "do list('path': 'name[]', 'var': 'n')", " copy_field('n.name', 'author.$append')", "end", @@ -510,7 +510,7 @@ public void doListIndexedArrayOfObjectsExplicitAppend() { @Test public void doListIndexedArrayOfObjectsToArrayOfObjects() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('author[]')", + "set_array('author[]')", "do list('path': 'name[]', 'var': 'n')", " copy_field('n.name', 'author[].$append.name')", "end", @@ -670,7 +670,7 @@ public void ifInCollectorCombine() { private void shouldIterateOverList(final String path, final int expectedCount) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('trace')", + "set_array('trace')", "do list(path: '" + path + "', 'var': '$i')", " add_field('trace.$append', 'true')", "end", @@ -716,7 +716,7 @@ public void shouldIterateOverListWithWildcard() { private void shouldIterateOverListOfHashes(final String path, final int expectedCount) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('trace')", + "set_array('trace')", "do list(path: '" + path + "', 'var': '$i')", " add_field('trace.$append', 'true')", "end", @@ -771,7 +771,7 @@ public void shouldIterateOverListOfHashesWithWildcard() { // See https://github.com/metafacture/metafacture-fix/issues/119 public void shouldPerformComplexOperationWithPathWildcard() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('coll[]')", + "set_array('coll[]')", "do list(path: 'feld?', 'var': '$i')", " add_field('coll[].$append.feldtest', 'true')", " copy_field('$i.a.value', 'coll[].$last.a')", @@ -847,7 +847,7 @@ public void shouldPerformComplexOperationWithPathWildcard() { @Test public void shouldDoListAsWithSingleList() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('sourceOrga[]')", + "set_array('sourceOrga[]')", "do list_as(orgId: 'ccm:university[]')", " copy_field(orgId, 'sourceOrga[].$append.id')", "end" @@ -881,7 +881,7 @@ public void shouldDoListAsWithSingleList() { @Test public void shouldDoListAsWithMultipleLists() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('sourceOrga[]')", + "set_array('sourceOrga[]')", "do list_as(orgId: 'ccm:university[]', orgName: 'ccm:university_DISPLAYNAME[]', orgLoc: 'ccm:university_LOCATION[]')", " copy_field(orgId, 'sourceOrga[].$append.id')", " copy_field(orgName, 'sourceOrga[].$last.name')", @@ -937,9 +937,9 @@ public void shouldDoListAsWithMultipleLists() { @Test // checkstyle-disable-line JavaNCSS public void shouldDoListAsWithMultipleListsOfDifferentSizes() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('sourceOrga[]')", + "set_array('sourceOrga[]')", "do list_as(orgId: 'ccm:university[]', orgName: 'ccm:university_DISPLAYNAME[]', orgLoc: 'ccm:university_LOCATION[]')", - " add_hash('sourceOrga[].$append')", + " set_hash('sourceOrga[].$append')", " copy_field(orgId, 'sourceOrga[].$last.id')", " copy_field(orgName, 'sourceOrga[].$last.name')", " copy_field(orgLoc, 'sourceOrga[].$last.location')", diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixIfTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixIfTest.java index 35ab30fb..5b8000dc 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixIfTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixIfTest.java @@ -1624,7 +1624,7 @@ public void shouldReportArrayEntityAsArray() { @Test public void shouldReportEmptyArrayAsArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array(foo)", + "set_array(foo)", "if is_array(foo)", " add_field(test,ok)", "end" @@ -1767,7 +1767,7 @@ public void shouldReportEmptyArrayEntityAsEmpty() { @Test public void shouldReportEmptyArrayAsEmpty() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array(foo)", + "set_array(foo)", "if is_empty(foo)", " add_field(test,ok)", "end" @@ -2127,7 +2127,7 @@ public void shouldReportHashAsObject() { @Test public void shouldReportEmptyHashAsObject() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_hash(foo)", + "set_hash(foo)", "if is_object(foo)", " add_field(test,ok)", "end" @@ -2499,7 +2499,7 @@ public void shouldMatchString() { @Test public void shouldTestMacroVariable() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('type')", + "set_array('type')", "do put_macro('test')", " if str_contain('name', 'a$[var]')", " add_field('type.$append', 'Organization: $[var]')", diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixLookupTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixLookupTest.java index 579b2e19..d527fb80 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixLookupTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixLookupTest.java @@ -144,7 +144,7 @@ public void inlineDotNotationNested() { @Test public void shouldLookupInternalArrayWithAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('title', 'Aloha')", + "set_array('title', 'Aloha')", LOOKUP + " Aloha: Alohaeha)" ), i -> { @@ -162,7 +162,7 @@ public void shouldLookupInternalArrayWithAsterisk() { @Test public void shouldLookupDeduplicatedInternalArrayWithAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('title', 'Aloha', 'Aloha')", + "set_array('title', 'Aloha', 'Aloha')", "uniq('title')", LOOKUP + " Aloha: Alohaeha)" ), @@ -182,8 +182,8 @@ public void shouldLookupDeduplicatedInternalArrayWithAsterisk() { public void shouldNotLookupCopiedInternalArrayWithAsterisk() { MetafixTestHelpers.assertExecutionException(IllegalStateException.class, "Expected Array or Hash, got String", () -> MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('data', 'Aloha')", - "add_array('title')", + "set_array('data', 'Aloha')", + "set_array('title')", "copy_field('data', 'title')", LOOKUP + " Aloha: Alohaeha)" ), @@ -200,8 +200,8 @@ public void shouldNotLookupCopiedInternalArrayWithAsterisk() { @Test public void shouldLookupCopiedInternalArrayWithAsteriskExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('data', 'Aloha')", - "add_array('title')", + "set_array('data', 'Aloha')", + "set_array('title')", "copy_field('data', 'title.$append')", LOOKUP + " Aloha: Alohaeha)" ), @@ -222,9 +222,9 @@ public void shouldLookupCopiedInternalArrayWithAsteriskExplicitAppend() { public void shouldNotLookupCopiedDeduplicatedInternalArrayWithAsterisk() { MetafixTestHelpers.assertExecutionException(IllegalStateException.class, "Expected Array or Hash, got String", () -> MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('data', 'Aloha', 'Aloha')", + "set_array('data', 'Aloha', 'Aloha')", "uniq('data')", - "add_array('title')", + "set_array('title')", "copy_field('data', 'title')", LOOKUP + " Aloha: Alohaeha)" ), @@ -241,9 +241,9 @@ public void shouldNotLookupCopiedDeduplicatedInternalArrayWithAsterisk() { @Test public void shouldLookupCopiedDeduplicatedInternalArrayWithAsteriskExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('data', 'Aloha', 'Aloha')", + "set_array('data', 'Aloha', 'Aloha')", "uniq('data')", - "add_array('title')", + "set_array('title')", "copy_field('data', 'title.$append')", LOOKUP + " Aloha: Alohaeha)" ), @@ -263,7 +263,7 @@ public void shouldLookupCopiedDeduplicatedInternalArrayWithAsteriskExplicitAppen @Test public void shouldLookupCopiedExternalArrayWithAsteriskExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('title')", + "set_array('title')", "copy_field('data', 'title.$append')", LOOKUP + " Aloha: Alohaeha)" ), @@ -285,7 +285,7 @@ public void shouldLookupCopiedExternalArrayWithAsteriskExplicitAppend() { public void shouldLookupCopiedDeduplicatedExternalArrayWithAsteriskExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "uniq('data')", - "add_array('title')", + "set_array('title')", "copy_field('data', 'title.$append')", LOOKUP + " Aloha: Alohaeha)" ), @@ -309,7 +309,7 @@ public void shouldNotLookupMovedDeduplicatedExternalArrayWithAsterisk() { MetafixTestHelpers.assertExecutionException(IllegalStateException.class, "Expected Array or Hash, got String", () -> MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "uniq('data')", - "add_array('title')", + "set_array('title')", "move_field('data', 'title')", LOOKUP + " Aloha: Alohaeha)" ), @@ -329,7 +329,7 @@ public void shouldNotLookupMovedDeduplicatedExternalArrayWithAsterisk() { public void shouldLookupMovedDeduplicatedExternalArrayWithAsteriskExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "uniq('data')", - "add_array('title')", + "set_array('title')", "move_field('data', 'title.$append')", LOOKUP + " Aloha: Alohaeha)" ), @@ -351,7 +351,7 @@ public void shouldLookupMovedDeduplicatedExternalArrayWithAsteriskExplicitAppend public void shouldNotLookupMovedExternalArrayWithAsterisk() { MetafixTestHelpers.assertExecutionException(IllegalStateException.class, "Expected Array or Hash, got String", () -> MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('title')", + "set_array('title')", "move_field('data', 'title')", LOOKUP + " Aloha: Alohaeha)" ), @@ -369,7 +369,7 @@ public void shouldNotLookupMovedExternalArrayWithAsterisk() { @Test public void shouldLookupMovedExternalArrayWithAsteriskExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('title')", + "set_array('title')", "move_field('data', 'title.$append')", LOOKUP + " Aloha: Alohaeha)" ), @@ -994,9 +994,9 @@ public void shouldLookupInCopiedNestedArraysCreatedWithPrepend() { private void shouldLookupInCopiedNestedArraysCreatedWith(final String reservedField) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "put_map('rswk-indicator', s: 'SubjectHeading')", - "add_array('subject[]')", - "add_array('subject[]." + reservedField + ".componentList[]')", - "add_array('subject[].$last.componentList[]." + reservedField + ".type[]')", + "set_array('subject[]')", + "set_array('subject[]." + reservedField + ".componentList[]')", + "set_array('subject[].$last.componentList[]." + reservedField + ".type[]')", "do list(path: 'D', 'var': '$i')", " copy_field('$i', 'subject[].$last.componentList[].$last.type[]." + reservedField + "')", "end", @@ -1247,7 +1247,7 @@ public void shouldExplicitLookupRdfUrlWithRedirection() { @Test // Scenario 1 public void shouldLookupInExternalRdfMapGetObjectOfSubjectWithTargetedPredicateOfSpecificLanguage() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('prefLabel', 'https://w3id.org/kim/hochschulfaechersystematik/n4')", + "set_array('prefLabel', 'https://w3id.org/kim/hochschulfaechersystematik/n4')", "put_rdfmap('" + RDF_MAP + "', 'rdfmap', target: 'skos:prefLabel', select_language: 'de')", "lookup('prefLabel.*', 'rdfmap')" ), @@ -1266,7 +1266,7 @@ public void shouldLookupInExternalRdfMapGetObjectOfSubjectWithTargetedPredicateO @Test // Scenario 2 public void shouldLookupInExternalRdfMapGetSubjectWithTargetedPredicateOfSpecificLanguage() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('id', 'Mathematics, Natural Sciences')", + "set_array('id', 'Mathematics, Natural Sciences')", "put_rdfmap('" + RDF_MAP + "', 'rdfmap', target: 'skos:prefLabel', select_language: 'en')", "lookup('id.*', 'rdfmap')" ), @@ -1408,7 +1408,7 @@ public void shouldLookupRdfDefinedPropertyToSubject() { private void shouldLookupInExternalRdfMapGetObjectWithTargetedPredicateOfSpecificLanguage(final String target) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('prefLabel', 'Mathematics, Natural Sciences')", + "set_array('prefLabel', 'Mathematics, Natural Sciences')", "put_rdfmap('" + RDF_MAP + "', 'rdfmap', target: '" + target + "', select_language: 'de')", "lookup('prefLabel.*', 'rdfmap')" ), diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java index a430aef6..8b167257 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixMethodTest.java @@ -2153,7 +2153,7 @@ public void replaceAllInOptionalSubfieldInArrayOfObjectsWithAsterisk() { @Test public void inDoBindCopyFieldWithVarInSourceAndTarget() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('RSWK[]')", + "set_array('RSWK[]')", "do list(path: '650??', 'var': '$i')", " copy_field('$i.a', 'RSWK[].$append.subjectTopicName')", " copy_field('$i.v', 'RSWK[].$last.subjectGenre')", @@ -2191,7 +2191,7 @@ public void inDoBindCopyFieldWithVarInSourceAndTarget() { @Test public void replaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('RSWK[]')", + "set_array('RSWK[]')", "do list(path: '650??', 'var': '$i')", " copy_field('$i.a', 'RSWK[].$append.subjectTopicName')", " copy_field('$i.v', 'RSWK[].$last.subjectGenre')", @@ -2230,7 +2230,7 @@ public void replaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget() { @Test public void multipleReplaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('RSWK[]')", + "set_array('RSWK[]')", "do list(path: '650??', 'var': '$i')", " copy_field('$i.a', 'RSWK[].$append.subjectTopicName')", " copy_field('$i.v', 'RSWK[].$last.subjectGenre')", @@ -2271,7 +2271,7 @@ public void multipleReplaceAllWithWildcardAfterCopyFieldWithVarInSourceAndTarget public void copyFieldToSubfieldOfArrayOfObjectsWithIndexImplicitAppend() { MetafixTestHelpers.assertProcessException(IllegalArgumentException.class, "Can't find: 1 in: null", () -> MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('test[]')", + "set_array('test[]')", "copy_field('key', 'test[].1.field')" ), i -> { @@ -2288,7 +2288,7 @@ public void copyFieldToSubfieldOfArrayOfObjectsWithIndexImplicitAppend() { @Test public void copyFieldToSubfieldOfArrayOfObjectsWithExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('test[]')", + "set_array('test[]')", "copy_field('key', 'test[].$append.field')" ), i -> { @@ -2312,7 +2312,7 @@ public void copyFieldToSubfieldOfArrayOfObjectsWithExplicitAppend() { public void copyFieldToSubfieldOfArrayOfStringsWithIndexImplicitAppend() { MetafixTestHelpers.assertProcessException(IndexOutOfBoundsException.class, "Index 0 out of bounds for length 0", () -> MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('test[]')", + "set_array('test[]')", "copy_field('key', 'test[].1')" ), i -> { @@ -2329,7 +2329,7 @@ public void copyFieldToSubfieldOfArrayOfStringsWithIndexImplicitAppend() { @Test public void copyFieldToSubfieldOfArrayOfStringsWithExplicitAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('test[]')", + "set_array('test[]')", "copy_field('key', 'test[].$append')" ), i -> { @@ -2442,7 +2442,7 @@ public void addFieldIntoArrayOfObjectsWithLastWildcardLastEmpty() { @Test public void shouldReplaceAllRegexesInCopiedArraySubField() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('coll[]')", + "set_array('coll[]')", "copy_field('a', 'coll[].$append.a')", "replace_all('coll[].*.a', 'o', '__')" ), @@ -2466,7 +2466,7 @@ public void shouldReplaceAllRegexesInCopiedArraySubField() { @Test public void shouldReplaceAllRegexesInMovedArraySubField() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('coll[]')", + "set_array('coll[]')", "move_field('a', 'coll[].$append.a')", "replace_all('coll[].*.a', 'o', '__')" ), @@ -2489,7 +2489,7 @@ public void shouldReplaceAllRegexesInMovedArraySubField() { @Test public void shouldReplaceAllRegexesInCopiedArraySubFieldOriginal() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('coll[]')", + "set_array('coll[]')", "copy_field('a', 'coll[].$append.a')", "replace_all('a', 'o', '__')" ), @@ -2513,7 +2513,7 @@ public void shouldReplaceAllRegexesInCopiedArraySubFieldOriginal() { @Test public void shouldReplaceAllRegexesInListCopiedArraySubField() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('coll[]')", + "set_array('coll[]')", "do list(path: 'a', 'var': '$i')", " copy_field('$i', 'coll[].$append.a')", "end", @@ -2539,7 +2539,7 @@ public void shouldReplaceAllRegexesInListCopiedArraySubField() { @Test public void shouldCopyBindVarWithDollarAfterLookup() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('@coll[]')", + "set_array('@coll[]')", "do list(path: 'a', 'var': '$i')", " lookup('$i.name')", " copy_field('$i.name', '@coll[].$append')", @@ -2566,7 +2566,7 @@ public void shouldCopyBindVarWithDollarAfterLookup() { @Test public void shouldCopyToFieldWithIndexAndReservedFieldName() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('a[].*.test[]', 'test')", + "set_array('a[].*.test[]', 'test')", "copy_field('some', 'a[].1.test[].$append')", "remove_field('some')" ), @@ -2605,7 +2605,7 @@ public void shouldCopyToFieldWithIndexAndReservedFieldName() { @Test public void shouldCopyToFieldWithTwoReservedFieldNames() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('a[].*.test[]', 'test')", + "set_array('a[].*.test[]', 'test')", "copy_field('some', 'a[].$first.test[].$append')", "remove_field('some')" ), @@ -2807,11 +2807,11 @@ public void addFieldWithReplaceAllArray() { private void addFieldWithReplaceAllArray(final boolean replaceAll) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "do list(path: 'contribution[]', 'var': '$i')", - " add_array('$i.agent.altLabel[]')", + " set_array('$i.agent.altLabel[]')", " add_field('$i.agent.altLabel[].$append', 'contribution')", "end", "do list(path: 'subject[]', 'var': '$i')", - " add_array('$i.altLabel[]')", + " set_array('$i.altLabel[]')", " add_field('$i.altLabel[].$append', 'subject')", "end", replaceAll ? "replace_all('contribution[].*.agent.altLabel[].*', 't', '')" : "", @@ -2864,10 +2864,10 @@ public void setArrayWithReplaceAll() { private void setArrayWithReplaceAll(final boolean replaceAll) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "do list(path: 'contribution[]', 'var': '$i')", - " add_array('$i.agent.altLabel[]', 'contribution')", + " set_array('$i.agent.altLabel[]', 'contribution')", "end", "do list(path: 'subject[]', 'var': '$i')", - " add_array('$i.altLabel[]', 'subject')", + " set_array('$i.altLabel[]', 'subject')", "end", replaceAll ? "replace_all('contribution[].*.agent.altLabel[].*', 't', '')" : "", replaceAll ? "replace_all('subject[].*.altLabel[].*', 't', '')" : "" @@ -2919,11 +2919,11 @@ public void copyFieldWithReplaceAllArray() { private void copyFieldWithReplaceAllArray(final boolean replaceAll) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "do list(path: 'contribution[]', 'var': '$i')", - " add_array('$i.agent.altLabel[]')", + " set_array('$i.agent.altLabel[]')", " copy_field('$i.label', '$i.agent.altLabel[].$append')", "end", "do list(path: 'subject[]', 'var': '$i')", - " add_array('$i.altLabel[]')", + " set_array('$i.altLabel[]')", " copy_field('$i.label', '$i.altLabel[].$append')", "end", replaceAll ? "replace_all('contribution[].*.agent.altLabel[].*', 't', '')" : "", @@ -2976,11 +2976,11 @@ public void pasteWithReplaceAll() { private void pasteWithReplaceAll(final boolean replaceAll) { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( "do list(path: 'contribution[]', 'var': '$i')", - " add_array('$i.agent.altLabel[]')", + " set_array('$i.agent.altLabel[]')", " paste('$i.agent.altLabel[].$append', '$i.label', '~!')", "end", "do list(path: 'subject[]', 'var': '$i')", - " add_array('$i.altLabel[]')", + " set_array('$i.altLabel[]')", " paste('$i.altLabel[].$append', '$i.label', '~!')", "end", replaceAll ? "replace_all('contribution[].*.agent.altLabel[].*', ' !', '')" : "", diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixRecordTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixRecordTest.java index 0d17e6d1..b8c13b87 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixRecordTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixRecordTest.java @@ -261,7 +261,7 @@ public void add() { @Test public void addWithAppendInNewArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('my.name')", + "set_array('my.name')", "add_field('my.name.$append','patrick')", "add_field('my.name.$append','nicolas')" ), @@ -634,7 +634,7 @@ public void complexAppendWithArrayOfObjects() { @Test public void appendWithWildcard() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('stringimals[]')", + "set_array('stringimals[]')", "copy_field('?nimal', 'stringimals[].$append')" ), i -> { @@ -697,7 +697,7 @@ public void simpleCopyWithWildcard() { @Test public void appendWithMultipleWildcards() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('stringimals[]')", + "set_array('stringimals[]')", "copy_field('?ni??l', 'stringimals[].$append')" ), i -> { @@ -728,7 +728,7 @@ public void appendWithMultipleWildcards() { @Test public void appendWithAsteriksWildcard() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('stringimals[]')", + "set_array('stringimals[]')", "copy_field('*al', 'stringimals[].$append')" ), i -> { @@ -758,7 +758,7 @@ public void appendWithAsteriksWildcard() { @Test public void appendWithBracketWildcard() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('stringimals[]')", + "set_array('stringimals[]')", "copy_field('[ac]nimal', 'stringimals[].$append')" ), i -> { @@ -788,7 +788,7 @@ public void appendWithBracketWildcard() { // See https://github.com/metafacture/metafacture-fix/issues/89 public void appendWithAsteriksWildcardAtTheEnd() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('stringimals[]')", + "set_array('stringimals[]')", "copy_field('ani*', 'stringimals[].$append')" ), i -> { @@ -833,7 +833,7 @@ public void appendWithAsteriksWildcardAtTheEnd() { @MetafixToDo("See https://github.com/metafacture/metafacture-fix/pull/113") public void shouldCopyArrayFieldWithoutAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('TEST_TWO[]')", + "set_array('TEST_TWO[]')", "copy_field('test[]', 'TEST_TWO[].$append')" ), i -> { @@ -894,7 +894,7 @@ public void copyFieldArrayOfObjectsAndListNewArrayOfObjectsAndMoveSubfield() { // See https://github.com/metafacture/metafacture-fix/issues/121 public void shouldCopyArrayFieldWithAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('TEST_TWO[]')", + "set_array('TEST_TWO[]')", "copy_field('test[].*', 'TEST_TWO[].$append')" ), i -> { @@ -927,7 +927,7 @@ public void shouldCopyArrayFieldWithAsterisk() { // See https://github.com/metafacture/metafacture-fix/issues/121 public void shouldCopyNestedArrayFieldWithAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('TEST_4[]')", + "set_array('TEST_4[]')", "copy_field('nestedTest[].*.test[].*', 'TEST_4[].$append')" ), i -> { @@ -982,7 +982,7 @@ public void shouldCopyNestedArrayFieldWithAsterisk() { // See https://github.com/metafacture/metafacture-fix/issues/121 public void shouldCopyArraySubFieldWithAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('TEST_5[]')", + "set_array('TEST_5[]')", "copy_field('coll[].*.b', 'TEST_5[].$append')" ), i -> { @@ -1402,7 +1402,7 @@ public void copy() { @Test public void copyIntoArrayOfStrings() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - // "add_array('author')", <- results in separate objects/entities here + // "set_array('author')", <- results in separate objects/entities here "copy_field('your.name','author.name[]')", "remove_field('your')"), i -> { @@ -1582,7 +1582,7 @@ public void copyIntoImplicitArrayPrepend() { @Test public void copyIntoExplicitArrayAppend() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('author[]')", + "set_array('author[]')", "copy_field('your.name','author[].$append.name')", "remove_field('your')"), i -> { @@ -1610,7 +1610,7 @@ public void copyIntoExplicitArrayAppend() { @Test public void copyIntoArrayTopLevel() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('author[]')", + "set_array('author[]')", "copy_field('your.name', 'author[]')", "remove_field('your')"), i -> { @@ -1854,7 +1854,7 @@ public void removeArrayElementsByWildcard() { @Test public void setArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('foo[]','a','b','c')"), + "set_array('foo[]','a','b','c')"), i -> { i.startRecord("1"); i.endRecord(); @@ -1873,7 +1873,7 @@ public void setArray() { // See https://github.com/metafacture/metafacture-fix/issues/111 public void setArrayReplaceExisting() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('foo[]','a','b','c')"), + "set_array('foo[]','a','b','c')"), i -> { i.startRecord("1"); i.startEntity("foo[]"); @@ -1897,7 +1897,7 @@ public void setArrayReplaceExisting() { // See https://github.com/metafacture/metafacture-fix/issues/130 public void setArrayInArrayWithAsterisk() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('foo[].*.test[]', 'test')"), + "set_array('foo[].*.test[]', 'test')"), i -> { i.startRecord("1"); i.startEntity("foo[]"); @@ -1929,7 +1929,7 @@ public void setArrayInArrayWithAsterisk() { @Test public void setHash() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_hash('foo','a': 'b','c': 'd')"), + "set_hash('foo','a': 'b','c': 'd')"), i -> { i.startRecord("1"); i.endRecord(); @@ -1947,7 +1947,7 @@ public void setHash() { // See https://github.com/metafacture/metafacture-fix/issues/111 public void setHashReplaceExisting() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_hash('foo','a': 'b','c': 'd')"), + "set_hash('foo','a': 'b','c': 'd')"), i -> { i.startRecord("1"); i.startEntity("foo"); @@ -2131,7 +2131,7 @@ public void shouldPrintRecordToFile() throws IOException { @Test public void hashFromArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('foo','a','b','c','d')", + "set_array('foo','a','b','c','d')", "hash('foo')"), i -> { i.startRecord("1"); @@ -2149,7 +2149,7 @@ public void hashFromArray() { @Test public void arrayFromHash() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_hash('foo','a': 'b','c': 'd')", + "set_hash('foo','a': 'b','c': 'd')", "array('foo')"), i -> { i.startRecord("1"); @@ -2167,7 +2167,7 @@ public void arrayFromHash() { @Test public void shouldCallMacro() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('test')", + "set_array('test')", "do put_macro('test')", " add_field('test.$append', '42')", "end", @@ -2206,7 +2206,7 @@ public void shouldNotCallUnknownMacro() { @Test public void shouldCallMacroWithVariables() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('test')", + "set_array('test')", "put_vars(a: '1', b: '2')", // global variables "do put_macro('test', b: '22', c: '33')", // "static" local variables " add_field('test.$append', '$[a]-$[b]-$[c]-$[d]')", @@ -2412,11 +2412,11 @@ public void reject() { } @Test - @MetafixToDo("Is add_array with $append something we need/want? WDCD?") + @MetafixToDo("Is set_array with $append something we need/want? WDCD?") public void appendArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('nums[]', '1')", - "add_array('nums[].$append', '2', '3')"), + "set_array('nums[]', '1')", + "set_array('nums[].$append', '2', '3')"), i -> { i.startRecord("1"); i.endRecord(); @@ -2434,8 +2434,8 @@ public void appendArray() { @Test public void mixedArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('@context[]', 'https://w3id.org/kim/lrmi-profile/draft/context.jsonld')", - "add_hash('@context[].$append', '@language': 'de')"), + "set_array('@context[]', 'https://w3id.org/kim/lrmi-profile/draft/context.jsonld')", + "set_hash('@context[].$append', '@language': 'de')"), i -> { i.startRecord("1"); i.endRecord(); @@ -3384,7 +3384,7 @@ public void shouldAddRandomNumberToMarkedArray() { @Test public void shouldAddObjectWithRandomNumberToMarkedArray() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('bnimals[]')", + "set_array('bnimals[]')", "random('bnimals[].$append.number', '100')" ), i -> { diff --git a/metafix/src/test/java/org/metafacture/metafix/MetafixScriptTest.java b/metafix/src/test/java/org/metafacture/metafix/MetafixScriptTest.java index 57c11016..2141ed05 100644 --- a/metafix/src/test/java/org/metafacture/metafix/MetafixScriptTest.java +++ b/metafix/src/test/java/org/metafacture/metafix/MetafixScriptTest.java @@ -228,7 +228,7 @@ public void shouldDoNothing() { @Test public void shouldIncludeFixFile() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('trace')", + "set_array('trace')", "add_field('trace.$append', 'before include')", "include('src/test/resources/org/metafacture/metafix/fixes/base.fix')", "add_field('trace.$append', 'after include')" @@ -307,7 +307,7 @@ public void shouldNotLeakVariablesFromIncludingFixFile() { @Test public void shouldIncludeFixFileInBind() { MetafixTestHelpers.assertFix(streamReceiver, Arrays.asList( - "add_array('trace')", + "set_array('trace')", "add_field('trace.$append', 'before bind')", "do list(path: 'data', 'var': '$i')", " paste('trace.$append', '~before include', '$i')", diff --git a/metafix/src/test/resources/org/metafacture/metafix/fixes/include.fix b/metafix/src/test/resources/org/metafacture/metafix/fixes/include.fix index 8bf6cb2a..9f8f6d39 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/fixes/include.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/fixes/include.fix @@ -1,5 +1,5 @@ unless exists("trace") - add_array("trace") + set_array("trace") end add_field("trace.$append", "before include") include("./base.fix") diff --git a/metafix/src/test/resources/org/metafacture/metafix/fixes/nested.fix b/metafix/src/test/resources/org/metafacture/metafix/fixes/nested.fix index 6ffe9317..33c9ede0 100644 --- a/metafix/src/test/resources/org/metafacture/metafix/fixes/nested.fix +++ b/metafix/src/test/resources/org/metafacture/metafix/fixes/nested.fix @@ -1,4 +1,4 @@ -add_array("trace") +set_array("trace") add_field("trace.$append", "before nested") include("src/test/resources/org/metafacture/metafix/fixes/include.fix") add_field("trace.$append", "after nested") From 511347bce3fea1038425ff561c6b7ce1b11b051a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Thu, 7 Nov 2024 10:16:36 +0100 Subject: [PATCH 9/9] Update and add documentation #374 --- README.md | 56 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index b5d82efb..c86640c6 100644 --- a/README.md +++ b/README.md @@ -303,6 +303,19 @@ Options: #### Record-level functions +##### `add_array` + +Creates a new array (with optional values). + +```perl +add_array("") +add_array("", ""[, ...]) +``` + +[Example in Playground](https://metafacture.org/playground/?example=add_array) + +[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_array+{") + ##### `add_field` Creates a field with a defined value. @@ -315,6 +328,19 @@ add_field("", "") [Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_field+{") +##### `add_hash` + +Creates a new hash (with optional values). + +```perl +add_hash("") +add_hash("", "subfieldName": ""[, ...]) +``` + +[Example in Playground](https://metafacture.org/playground/?example=add_hash) + +[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+add_hash+{") + ##### `array` Converts a hash/object into an array. @@ -535,39 +561,21 @@ retain(""[, ...]) ##### `set_array` -Creates a new array (with optional values). +_Currently alias for [`add_array`](#add_array)._ -```perl -set_array("") -set_array("", ""[, ...]) -``` - -[Example in Playground](https://metafacture.org/playground/?example=set_array) - -[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+set_array+{") +We advise you to use [`add_array`](#add_array) instead of `set_array` due to changing behaviour in an upcoming release. For more information see: [#309](https://github.com/metafacture/metafacture-fix/issues/309) ##### `set_field` -Creates (or replaces) a field with a defined value. - -```perl -set_field("", "") -``` +_Currently alias for [`add_field`](#add_field)._ -[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+set_field+{") +We advise you to use [`add_field`](#add_field) instead of `set_field` due to changing behaviour in an upcoming release. For more information see: [#309](https://github.com/metafacture/metafacture-fix/issues/309) ##### `set_hash` -Creates a new hash (with optional values). - -```perl -set_hash("") -set_hash("", "subfieldName": ""[, ...]) -``` - -[Example in Playground](https://metafacture.org/playground/?example=set_hash) +_Currently alias for [`add_hash`](#add_hash)._ -[Java Code](https://github.com/search?type=code&q=repo:metafacture/metafacture-fix+path:FixMethod.java+"+set_hash+{") +We advise you to use [`add_hash`](#add_hash) instead of `set_hash` due to changing behaviour in an upcoming release. For more information see: [#309](https://github.com/metafacture/metafacture-fix/issues/309) ##### `timestamp`