summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-02-20 13:47:46 +0000
committerTakamune Cho <takamune.cho@att.com>2019-02-21 15:08:02 +0000
commit7c994ce711a14828629c1652444e33457fecb33b (patch)
tree3e64160c880104c08a6351bff05202d45f94f14a
parent76dbfd952b3398bf7699c7a100c777b1881ed53e (diff)
Test coverage in Mapper
Increased coverage to 98% Issue-ID: APPC-1462 Change-Id: Ie6aa2dc885be4ede947c3f7856f93cf9f1efffa0 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/Mapper.java6
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/util/TestMapper.java29
2 files changed, 32 insertions, 3 deletions
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/Mapper.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/Mapper.java
index f64ea8f5e..b9a6a4cc8 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/Mapper.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/Mapper.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,12 +28,10 @@ package org.onap.appc.listener.util;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-
-import com.fasterxml.jackson.databind.JsonNode;
import org.json.JSONObject;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
public class Mapper {
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/util/TestMapper.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/util/TestMapper.java
index 4d568d9b7..2a9483364 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/util/TestMapper.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/util/TestMapper.java
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,9 +37,11 @@ import java.util.List;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
import org.onap.appc.listener.util.Mapper;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
public class TestMapper {
@@ -103,4 +107,29 @@ public class TestMapper {
assertEquals("2", out.get(1).a);
}
+ @Test
+ public void testToJsonString() {
+ JSONObject jsonObject = Mockito.mock(JSONObject.class);
+ assertTrue(Mapper.toJsonString(jsonObject).startsWith("Mock for JSONObject"));
+ }
+
+ @Test
+ public void testToJsonStringNonJsonObject() {
+ assertEquals("\"TEST\"", Mapper.toJsonString("TEST"));
+ }
+
+ @Test
+ public void testToJsonStringException() {
+ assertNull(Mapper.toJsonString(new Mapper()));
+ }
+
+ @Test
+ public void testToJsonNodeFromJsonStringException() {
+ assertNull(Mapper.toJsonNodeFromJsonString("{{}"));
+ }
+
+ @Test
+ public void testToJsonNode() {
+ assertTrue(Mapper.toJsonNode(dummyObj) instanceof JsonNode);
+ }
}