summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/crud/service/BulkPayloadTest.java
diff options
context:
space:
mode:
authorSotiropoulos, Ioannis (is948x) <Ioannis.Sotiropoulos@amdocs.com>2018-07-10 17:57:43 +0100
committerSotiropoulos, Ioannis (is948x) <Ioannis.Sotiropoulos@amdocs.com>2018-07-10 17:57:43 +0100
commitd5322dbd0fa1e32d543b24824a28d6bf0a0b5497 (patch)
tree3fd9c7c2ce924395346601490e96327e47928afc /src/test/java/org/onap/crud/service/BulkPayloadTest.java
parent600ca7e0b82c6932caa4f4ffb53e6c053525d9d5 (diff)
Increase code coverage
Add tests to increase code coverage above 60 percent. Issue-ID: AAI-1198 Change-Id: I4c2f964ce41d01521cc1313e32e34fb6460d49bf Signed-off-by: Sotiropoulos, Ioannis (is948x) <Ioannis.Sotiropoulos@amdocs.com>
Diffstat (limited to 'src/test/java/org/onap/crud/service/BulkPayloadTest.java')
-rw-r--r--src/test/java/org/onap/crud/service/BulkPayloadTest.java36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/test/java/org/onap/crud/service/BulkPayloadTest.java b/src/test/java/org/onap/crud/service/BulkPayloadTest.java
index c768339..7a409ec 100644
--- a/src/test/java/org/onap/crud/service/BulkPayloadTest.java
+++ b/src/test/java/org/onap/crud/service/BulkPayloadTest.java
@@ -20,16 +20,19 @@
*/
package org.onap.crud.service;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-
-import org.junit.Test;
-import org.onap.crud.parser.BulkPayload;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.ws.rs.core.Response.Status;
+import org.junit.Test;
+import org.onap.crud.exception.CrudException;
+import org.onap.crud.parser.BulkPayload;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
public class BulkPayloadTest {
@@ -70,4 +73,23 @@ public class BulkPayloadTest {
System.out.println("root: " + root.toString());
System.out.println("payload ids: " + ids.toString());
}
-} \ No newline at end of file
+
+ @Test
+ public void testExceptionHandling() {
+ String payload = null;
+ try {
+ BulkPayload.fromJson(payload);
+ } catch (CrudException e) {
+ assertThat(e.getHttpStatus(), is(Status.BAD_REQUEST));
+ assertThat(e.getMessage(), is("Invalid Json Payload"));
+ }
+
+ payload = "Invalid Json";
+ try {
+ BulkPayload.fromJson(payload);
+ } catch (CrudException e) {
+ assertThat(e.getHttpStatus(), is(Status.BAD_REQUEST));
+ assertThat(e.getMessage(), is("Invalid Json Payload"));
+ }
+ }
+}