Skip to content

Commit

Permalink
#461: fix JSON merger to create file (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Sep 14, 2020
1 parent e451a41 commit 251afef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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; // JSON to merge does not exist and needs to be created
}
switch (json.getValueType()) {
case OBJECT:
return mergeAndResolveObject((JsonObject) json, (JsonObject) mergeJson, resolver, status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"key": "value"
}

0 comments on commit 251afef

Please sign in to comment.