Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#461: fix JSON merger to create file #462

Merged
merged 4 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}