-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...rs/src/main/java/com/yahoo/elide/contrib/testhelpers/jsonapi/elements/PatchOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2019, Yahoo Inc. | ||
* Licensed under the Apache License, Version 2.0 | ||
* See LICENSE file in project root for terms. | ||
*/ | ||
|
||
package com.yahoo.elide.contrib.testhelpers.jsonapi.elements; | ||
|
||
import java.util.LinkedHashMap; | ||
|
||
public class PatchOperation extends LinkedHashMap<String, Object> { | ||
|
||
/** | ||
* @param operation the operation type | ||
* @param path the operation path | ||
* @param value the operation value | ||
*/ | ||
public PatchOperation(PatchOperationType operation, String path, Resource value) { | ||
this.put("op", operation.name()); | ||
this.put("path", path); | ||
this.put("value", value); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...rc/main/java/com/yahoo/elide/contrib/testhelpers/jsonapi/elements/PatchOperationType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.yahoo.elide.contrib.testhelpers.jsonapi.elements; | ||
|
||
public enum PatchOperationType { | ||
add, remove, replace | ||
} |
35 changes: 35 additions & 0 deletions
35
...-helpers/src/main/java/com/yahoo/elide/contrib/testhelpers/jsonapi/elements/PatchSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2019, Yahoo Inc. | ||
* Licensed under the Apache License, Version 2.0 | ||
* See LICENSE file in project root for terms. | ||
*/ | ||
|
||
package com.yahoo.elide.contrib.testhelpers.jsonapi.elements; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
public class PatchSet extends ArrayList { | ||
|
||
static private final Gson GSON_INSTANCE = new GsonBuilder() | ||
.serializeNulls().create(); | ||
|
||
/** | ||
* @param patchOperations the set of patch operations | ||
*/ | ||
public PatchSet(PatchOperation... patchOperations) { | ||
this.addAll(Arrays.asList(patchOperations)); | ||
} | ||
|
||
/** | ||
* To json string. | ||
* | ||
* @return the string | ||
*/ | ||
public String toJSON() { | ||
return GSON_INSTANCE.toJson(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters