From a687e4a33cf64154668c957e8e9b011634495d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Hohwiller?= Date: Thu, 3 Sep 2020 14:43:39 +0200 Subject: [PATCH 1/3] devonfw/devon4j#289: update travis dist to bionic --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 710720f15..d06075d4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: java +dist: bionic jdk: - openjdk11 sudo: required From eab0a3db7c3de5c9aed83e3d6fac2f2f5c03d36e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Hohwiller?= Date: Mon, 14 Sep 2020 17:33:24 +0200 Subject: [PATCH 2/3] #461: added test for JsonMerger bug and fixed code --- .../com/devonfw/tools/ide/configurator/merge/JsonMerger.java | 5 ++++- .../com/devonfw/tools/ide/configurator/ConfiguratorTest.java | 4 ++++ .../src/test/resources/templates/update/json/update.json | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 configurator/src/test/resources/templates/update/json/update.json diff --git a/configurator/src/main/java/com/devonfw/tools/ide/configurator/merge/JsonMerger.java b/configurator/src/main/java/com/devonfw/tools/ide/configurator/merge/JsonMerger.java index 68a93c0d2..c22f5e82b 100644 --- a/configurator/src/main/java/com/devonfw/tools/ide/configurator/merge/JsonMerger.java +++ b/configurator/src/main/java/com/devonfw/tools/ide/configurator/merge/JsonMerger.java @@ -29,7 +29,7 @@ import com.devonfw.tools.ide.logging.Log; /** - * TODO hohwille This type ... + * Implementation of {@link FileTypeMerger} for JSON. * * @since 3.0.0 */ @@ -125,6 +125,9 @@ private JsonValue mergeAndResolve(JsonValue json, JsonValue mergeJson, VariableR return mergeAndResolve(mergeJson, null, resolver, status); } } else { + if (mergeJson == null) { + status.updated = true; // target file does not exist and needs to be created + } switch (json.getValueType()) { case OBJECT: return mergeAndResolveObject((JsonObject) json, (JsonObject) mergeJson, resolver, status); diff --git a/configurator/src/test/java/com/devonfw/tools/ide/configurator/ConfiguratorTest.java b/configurator/src/test/java/com/devonfw/tools/ide/configurator/ConfiguratorTest.java index 7f8ddb532..136895e2c 100644 --- a/configurator/src/test/java/com/devonfw/tools/ide/configurator/ConfiguratorTest.java +++ b/configurator/src/test/java/com/devonfw/tools/ide/configurator/ConfiguratorTest.java @@ -77,6 +77,10 @@ public void testConfigurator() throws Exception { + " \"foo\": \"" + DEVON_IDE_HOME + "/foo\"\n" // + " }\n" // + "}"); + assertThat(new File(jsonFolder, "update.json")).hasContent("\n" // this newline is rather a bug of JSON-P impl + + "{\n" // + + " \"key\": \"value\"\n" // + + "}"); File configFolder = new File(workspaceDir, "config"); assertThat(configFolder).isDirectory(); diff --git a/configurator/src/test/resources/templates/update/json/update.json b/configurator/src/test/resources/templates/update/json/update.json new file mode 100644 index 000000000..d5df76e7e --- /dev/null +++ b/configurator/src/test/resources/templates/update/json/update.json @@ -0,0 +1,3 @@ +{ + "key": "value" +} \ No newline at end of file From b8eae02a209d544a8e3d01152a1431a4840528dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Hohwiller?= Date: Mon, 14 Sep 2020 17:35:42 +0200 Subject: [PATCH 3/3] updated comment --- .../com/devonfw/tools/ide/configurator/merge/JsonMerger.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configurator/src/main/java/com/devonfw/tools/ide/configurator/merge/JsonMerger.java b/configurator/src/main/java/com/devonfw/tools/ide/configurator/merge/JsonMerger.java index c22f5e82b..f2c06162e 100644 --- a/configurator/src/main/java/com/devonfw/tools/ide/configurator/merge/JsonMerger.java +++ b/configurator/src/main/java/com/devonfw/tools/ide/configurator/merge/JsonMerger.java @@ -126,7 +126,7 @@ private JsonValue mergeAndResolve(JsonValue json, JsonValue mergeJson, VariableR } } else { if (mergeJson == null) { - status.updated = true; // target file does not exist and needs to be created + status.updated = true; // JSON to merge does not exist and needs to be created } switch (json.getValueType()) { case OBJECT: