summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorsblimkie <steven.blimkie@amdocs.com>2018-03-15 13:53:15 -0400
committersblimkie <steven.blimkie@amdocs.com>2018-03-15 13:53:15 -0400
commitd41ef90610aadb5aa3372d5922155e4fc4e0a407 (patch)
tree14e2a48d3d8aa4b1bce5c49c052fcd9e93e69227 /src/main
parentb6ec637f5ee03c573855431e65fcb6ab0f321851 (diff)
Add junit tests
Add junit tests Change-Id: Iaa22b0faa206114ef39648d451a5275205d14d9a Issue-ID: AAI-885 Signed-off-by: sblimkie <steven.blimkie@amdocs.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/crud/service/BulkPayload.java41
-rw-r--r--src/main/java/org/onap/crud/service/CrudRestService.java7
2 files changed, 7 insertions, 41 deletions
diff --git a/src/main/java/org/onap/crud/service/BulkPayload.java b/src/main/java/org/onap/crud/service/BulkPayload.java
index 9b7b4cf..8dc99c4 100644
--- a/src/main/java/org/onap/crud/service/BulkPayload.java
+++ b/src/main/java/org/onap/crud/service/BulkPayload.java
@@ -22,16 +22,12 @@ package org.onap.crud.service;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
import org.onap.crud.exception.CrudException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
import javax.ws.rs.core.Response.Status;
@@ -81,41 +77,4 @@ public class BulkPayload {
return "BulkPayload [objects=" + objects + ", relationships=" + relationships + "]";
}
- public static void main(String[] args) throws Exception {
- BulkPayload p = new BulkPayload();
- JsonObject root = new JsonObject();
- JsonArray vertices = new JsonArray();
- JsonObject v1 = new JsonObject();
- JsonObject v2 = new JsonObject();
- JsonObject prop = new JsonObject();
-
- prop.addProperty("p1", "value1");
- prop.addProperty("p2", "value2");
- v1.add("v1", prop);
- v2.add("v2", prop);
-
- vertices.add(v1);
- vertices.add(v2);
-
- root.add("objects", vertices);
-
- String s = "{\"objects\":[{\"v1\":{\"p1\":\"value1\",\"p2\":\"value2\"}},{\"v2\":{\"p1\":\"value1\",\"p2\":\"value2\"}}]}";
-
- p = BulkPayload.fromJson(s);
-
- List<JsonElement> po = p.getObjects();
- List<String> ids = new ArrayList<String>();
- for (JsonElement e : po) {
- Set<Map.Entry<String, JsonElement>> entries = e.getAsJsonObject().entrySet();
-
- for (Map.Entry<String, JsonElement> entry : entries) {
- ids.add(entry.getKey());
- }
- }
-
- System.out.println("root: " + root.toString());
- System.out.println("payload ids: " + ids.toString());
-
- }
-
} \ No newline at end of file
diff --git a/src/main/java/org/onap/crud/service/CrudRestService.java b/src/main/java/org/onap/crud/service/CrudRestService.java
index dbe9d68..2af205a 100644
--- a/src/main/java/org/onap/crud/service/CrudRestService.java
+++ b/src/main/java/org/onap/crud/service/CrudRestService.java
@@ -72,6 +72,13 @@ public class CrudRestService {
this.graphDataService = graphDataService;
this.auth = new Auth(CrudServiceConstants.CRD_AUTH_FILE);
}
+
+ // For unit testing
+ public CrudRestService(AbstractGraphDataService graphDataService, Auth auth) throws Exception {
+ this.graphDataService = graphDataService;
+ this.auth = auth;
+ }
+
public enum Action {
POST, GET, PUT, DELETE, PATCH