From d41ef90610aadb5aa3372d5922155e4fc4e0a407 Mon Sep 17 00:00:00 2001 From: sblimkie Date: Thu, 15 Mar 2018 13:53:15 -0400 Subject: Add junit tests Add junit tests Change-Id: Iaa22b0faa206114ef39648d451a5275205d14d9a Issue-ID: AAI-885 Signed-off-by: sblimkie --- .../java/org/onap/crud/service/BulkPayload.java | 41 ---------------------- .../org/onap/crud/service/CrudRestService.java | 7 ++++ 2 files changed, 7 insertions(+), 41 deletions(-) (limited to 'src/main') 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 po = p.getObjects(); - List ids = new ArrayList(); - for (JsonElement e : po) { - Set> entries = e.getAsJsonObject().entrySet(); - - for (Map.Entry 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 -- cgit 1.2.3-korg