summaryrefslogtreecommitdiffstats
path: root/appc-event-listener/appc-event-listener-bundle
diff options
context:
space:
mode:
Diffstat (limited to 'appc-event-listener/appc-event-listener-bundle')
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/conv/ConverterTest.java48
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/impl/WorkerImplTest.java25
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapIncomingMessageTest.java9
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapMessageTest.java11
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapOutgoingMessageTest.java9
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/InputBodyTest.java32
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/OutputBodyTest.java19
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/operation/GenericProviderOperationsRequestFormatterTest.java17
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/operation/ProviderOperationsTest.java17
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/TestUtil.java82
10 files changed, 115 insertions, 154 deletions
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/conv/ConverterTest.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/conv/ConverterTest.java
index d27bcc8f4..d5a5bbd7b 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/conv/ConverterTest.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/conv/ConverterTest.java
@@ -25,6 +25,10 @@
package org.onap.appc.listener.LCM.conv;
import static org.junit.Assert.assertEquals;
+import static org.onap.appc.listener.TestUtil.JSON_INPUT_BODY_STR;
+import static org.onap.appc.listener.TestUtil.JSON_OUTPUT_BODY_STR;
+import static org.onap.appc.listener.TestUtil.buildDmaapIncomingMessage;
+import static org.onap.appc.listener.TestUtil.buildDmaapOutgoingMessage;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
@@ -36,22 +40,11 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicException;
public class ConverterTest {
- private static final String jsonInputBodyStr =
- "{\"input\":{ \"common-header\": { \"timestamp\": \"2016-08-03T08:50:18.97Z\", "
- + "\"api-ver\": \"1\", \"originator-id\": \"1\", \"request-id\": \"123\", \"sub-request-id\": \"1\", "
- + "\"flags\": { \"force\":\"TRUE\", \"ttl\":\"9900\" } }, \"action\": \"Stop\", "
- + "\"action-identifiers\": { \"vnf-id\": \"TEST\" } }}";
-
- private static final String jsonOutputBodyStr =
- "{\"output\":{\"common-header\":{\"timestamp\":\"2016-08-03T08:50:18.97Z\","
- + "\"api-ver\":\"1\",\"flags\":{\"force\":\"TRUE\",\"ttl\":\"9900\"},\"sub-request-id\":\"1\","
- + "\"request-id\":\"123\",\"originator-id\":\"1\"},\"status\":{\"value\":\"TestException\",\"code\":200}}}";
-
- private static final String expectedDmaapOutgoingMessageAsJsonString = "{\"body\":{\"output\":{\"common-header\":"
- + "{\"timestamp\":\"2016-08-03T08:50:18.97Z\",\"api-ver\":\"1\",\"flags\":{\"force\":\"TRUE\",\"ttl\":\"9900\"},"
- + "\"sub-request-id\":\"1\",\"request-id\":\"123\",\"originator-id\":\"1\"},\"status\":"
- + "{\"value\":\"TestException\",\"code\":200}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"test\"}";
-
+ private static final String EXPECTED_DMAAP_OUTGOING_MESSAGE_AS_JSON_STRING =
+ "{\"body\":{\"output\":{\"common-header\":"
+ + "{\"timestamp\":\"2016-08-03T08:50:18.97Z\",\"api-ver\":\"1\",\"flags\":{\"force\":\"TRUE\",\"ttl\":\"9900\"},"
+ + "\"sub-request-id\":\"1\",\"request-id\":\"123\",\"originator-id\":\"1\"},\"locked\":\"test-locked\",\""
+ + "status\":{\"message\":\"test message\",\"code\":200}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"test\"}";
@Test(expected = IllegalArgumentException.class)
public void convertJsonNodeToDmaapOutgoingMessage_should_throw_when_given_null_arguments() {
@@ -66,7 +59,7 @@ public class ConverterTest {
message.setRpcName("test");
message.setCorrelationID("test-1");
message.setVersion("v1");
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_INPUT_BODY_STR);
message.setBody(jsonNode);
DmaapOutgoingMessage result = Converter.convertJsonNodeToDmaapOutgoingMessage(message, jsonNode);
@@ -90,10 +83,10 @@ public class ConverterTest {
DmaapOutgoingMessage message = new DmaapOutgoingMessage();
message.setRpcName("test");
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonOutputBodyStr);
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_OUTPUT_BODY_STR);
message.setBody(jsonNode);
- assertEquals(expectedDmaapOutgoingMessageAsJsonString,
+ assertEquals(EXPECTED_DMAAP_OUTGOING_MESSAGE_AS_JSON_STRING,
Converter.convertDmaapOutgoingMessageToJsonString(message));
}
@@ -147,22 +140,5 @@ public class ConverterTest {
assertEquals(200L, statusCode.longValue());
}
- private DmaapIncomingMessage buildDmaapIncomingMessage() {
- DmaapIncomingMessage dmaapIncomingMessage = new DmaapIncomingMessage();
- dmaapIncomingMessage.setRpcName("test");
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
- dmaapIncomingMessage.setBody(jsonNode);
- return dmaapIncomingMessage;
-
- }
-
- private DmaapOutgoingMessage buildDmaapOutgoingMessage() {
- DmaapOutgoingMessage dmaapOutgoingMessage = new DmaapOutgoingMessage();
- dmaapOutgoingMessage.setRpcName("test");
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonOutputBodyStr);
- dmaapOutgoingMessage.setBody(jsonNode);
- return dmaapOutgoingMessage;
-
- }
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/impl/WorkerImplTest.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/impl/WorkerImplTest.java
index 9d08d834c..391a0b5cb 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/impl/WorkerImplTest.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/impl/WorkerImplTest.java
@@ -28,27 +28,18 @@ import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import static org.onap.appc.listener.TestUtil.JSON_OUTPUT_BODY_STR;
+import static org.onap.appc.listener.TestUtil.buildDmaapMessage;
import com.fasterxml.jackson.databind.JsonNode;
import org.junit.Test;
import org.onap.appc.exceptions.APPCException;
import org.onap.appc.listener.EventHandler;
-import org.onap.appc.listener.LCM.model.DmaapMessage;
import org.onap.appc.listener.LCM.operation.ProviderOperations;
import org.onap.appc.listener.util.Mapper;
public class WorkerImplTest {
- private static final String jsonInputBodyStr =
- "{\"input\":{ \"common-header\": { \"timestamp\": \"2016-08-03T08:50:18.97Z\", "
- + "\"api-ver\": \"1\", \"originator-id\": \"1\", \"request-id\": \"123\", \"sub-request-id\": \"1\", "
- + "\"flags\": { \"force\":\"TRUE\", \"ttl\":\"9900\" } }, \"action\": \"Stop\", "
- + "\"action-identifiers\": { \"vnf-id\": \"TEST\" } }}";
-
- private static final String jsonOutputBodyStr = "{\"output\":{\"common-header\":{\"timestamp\":\"2016-08-03T08:50:18.97Z\","
- + "\"api-ver\":\"1\",\"flags\":{\"force\":\"TRUE\",\"ttl\":\"9900\"},\"sub-request-id\":\"1\","
- + "\"request-id\":\"123\",\"originator-id\":\"1\"},\"status\":{\"value\":\"TestException\",\"code\":200}}}";
-
private EventHandler mockEventHandler = mock(EventHandler.class);
private ProviderOperations mockProviderOperations = mock(ProviderOperations.class);
@@ -76,7 +67,7 @@ public class WorkerImplTest {
@Test
public void should_post_message_to_dmaap_on_successful_run() throws APPCException {
- JsonNode testOutputJsonNode = Mapper.toJsonNodeFromJsonString(jsonOutputBodyStr);
+ JsonNode testOutputJsonNode = Mapper.toJsonNodeFromJsonString(JSON_OUTPUT_BODY_STR);
when(mockProviderOperations.topologyDG(anyString(), any(JsonNode.class)))
.thenReturn(testOutputJsonNode);
@@ -85,14 +76,4 @@ public class WorkerImplTest {
verify(mockEventHandler).postStatus(anyString(), anyString());
}
-
-
- private DmaapMessage buildDmaapMessage() {
-
- DmaapMessage dmaapMessage = new DmaapMessage();
- dmaapMessage.setRpcName("test");
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
- dmaapMessage.setBody(jsonNode);
- return dmaapMessage;
- }
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapIncomingMessageTest.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapIncomingMessageTest.java
index e4b06dff3..4f0e84adc 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapIncomingMessageTest.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapIncomingMessageTest.java
@@ -24,6 +24,7 @@
package org.onap.appc.listener.LCM.model;
import static org.junit.Assert.assertEquals;
+import static org.onap.appc.listener.TestUtil.JSON_INPUT_BODY_STR;
import com.fasterxml.jackson.databind.JsonNode;
import org.junit.Before;
@@ -32,12 +33,6 @@ import org.onap.appc.listener.util.Mapper;
public class DmaapIncomingMessageTest {
- private static final String jsonInputBodyStr =
- "{\"input\":{ \"common-header\": { \"timestamp\": \"2016-08-03T08:50:18.97Z\", "
- + "\"api-ver\": \"1\", \"originator-id\": \"1\", \"request-id\": \"123\", \"sub-request-id\": \"1\", "
- + "\"flags\": { \"force\":\"TRUE\", \"ttl\":\"9900\" } }, \"action\": \"Stop\", "
- + "\"action-identifiers\": { \"vnf-id\": \"TEST\" } }}";
-
private DmaapIncomingMessage dmaapIncomingMessage;
@Before
@@ -53,7 +48,7 @@ public class DmaapIncomingMessageTest {
@Test
public void toString_should_return_valid_string_representation() {
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_INPUT_BODY_STR);
dmaapIncomingMessage.setVersion("test-version");
dmaapIncomingMessage.setType("test-type");
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapMessageTest.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapMessageTest.java
index 4d6d03b24..7b42a754a 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapMessageTest.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapMessageTest.java
@@ -24,6 +24,7 @@
package org.onap.appc.listener.LCM.model;
import static org.junit.Assert.assertEquals;
+import static org.onap.appc.listener.TestUtil.JSON_INPUT_BODY_STR;
import com.fasterxml.jackson.databind.JsonNode;
import org.junit.Before;
@@ -32,12 +33,6 @@ import org.onap.appc.listener.util.Mapper;
public class DmaapMessageTest {
- private static final String jsonInputBodyStr =
- "{\"input\":{ \"common-header\": { \"timestamp\": \"2016-08-03T08:50:18.97Z\", "
- + "\"api-ver\": \"1\", \"originator-id\": \"1\", \"request-id\": \"123\", \"sub-request-id\": \"1\", "
- + "\"flags\": { \"force\":\"TRUE\", \"ttl\":\"9900\" } }, \"action\": \"Stop\", "
- + "\"action-identifiers\": { \"vnf-id\": \"TEST\" } }}";
-
private DmaapMessage dmaapMessage;
@Before
@@ -48,7 +43,7 @@ public class DmaapMessageTest {
@Test
public void should_set_properties() {
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_INPUT_BODY_STR);
dmaapMessage.setVersion("test-version");
dmaapMessage.setType("test-type");
@@ -67,7 +62,7 @@ public class DmaapMessageTest {
@Test
public void toString_should_return_valid_string_representation() {
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_INPUT_BODY_STR);
dmaapMessage.setVersion("test-version");
dmaapMessage.setType("test-type");
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapOutgoingMessageTest.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapOutgoingMessageTest.java
index 09223ce4f..6a3ad7b3f 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapOutgoingMessageTest.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapOutgoingMessageTest.java
@@ -24,6 +24,7 @@
package org.onap.appc.listener.LCM.model;
import static org.junit.Assert.assertEquals;
+import static org.onap.appc.listener.TestUtil.JSON_INPUT_BODY_STR;
import com.fasterxml.jackson.databind.JsonNode;
import org.junit.Before;
@@ -32,12 +33,6 @@ import org.onap.appc.listener.util.Mapper;
public class DmaapOutgoingMessageTest {
- private static final String jsonInputBodyStr =
- "{\"input\":{ \"common-header\": { \"timestamp\": \"2016-08-03T08:50:18.97Z\", "
- + "\"api-ver\": \"1\", \"originator-id\": \"1\", \"request-id\": \"123\", \"sub-request-id\": \"1\", "
- + "\"flags\": { \"force\":\"TRUE\", \"ttl\":\"9900\" } }, \"action\": \"Stop\", "
- + "\"action-identifiers\": { \"vnf-id\": \"TEST\" } }}";
-
private DmaapOutgoingMessage dmaapOutgoingMessage;
@Before
@@ -53,7 +48,7 @@ public class DmaapOutgoingMessageTest {
@Test
public void toString_should_return_valid_string_representation() {
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_INPUT_BODY_STR);
dmaapOutgoingMessage.setVersion("test-version");
dmaapOutgoingMessage.setType("test-type");
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/InputBodyTest.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/InputBodyTest.java
index 0593eb2dc..69ee2b4bf 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/InputBodyTest.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/InputBodyTest.java
@@ -26,9 +26,9 @@ package org.onap.appc.listener.LCM.model;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.onap.appc.listener.TestUtil.buildActionIdentifiers;
+import static org.onap.appc.listener.TestUtil.buildCommonHeader;
-import java.util.HashMap;
-import java.util.Map;
import org.junit.Before;
import org.junit.Test;
@@ -67,32 +67,4 @@ public class InputBodyTest {
}
- private CommonHeader buildCommonHeader() {
-
- CommonHeader commonHeader = new CommonHeader();
- commonHeader.setTimeStamp("test-timestamp");
- commonHeader.setApiVer("test-api-version");
- commonHeader.setOriginatorId("test-originator-id");
- commonHeader.setRequestID("test-request-id");
- commonHeader.setSubRequestId("test-subrequest-id");
-
- Map<String, String> flags = new HashMap<>();
- flags.put("key1", "flag1");
- flags.put("key2", "flag2");
- flags.put("key3", "flag3");
-
- commonHeader.setFlags(flags);
- return commonHeader;
- }
-
- private ActionIdentifiers buildActionIdentifiers() {
-
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- actionIdentifiers.setServiceInstanceId("test-instance-id");
- actionIdentifiers.setVnfID("test-vnf-id");
- actionIdentifiers.setVnfcName("test-name");
- actionIdentifiers.setVserverId("test-vserver-id");
-
- return actionIdentifiers;
- }
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/OutputBodyTest.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/OutputBodyTest.java
index 2d73aa5d8..65b9dd1a6 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/OutputBodyTest.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/OutputBodyTest.java
@@ -25,6 +25,7 @@ package org.onap.appc.listener.LCM.model;
import static junit.framework.TestCase.assertNotNull;
import static org.junit.Assert.assertEquals;
+import static org.onap.appc.listener.TestUtil.buildCommonHeader;
import java.util.HashMap;
import java.util.Map;
@@ -92,22 +93,4 @@ public class OutputBodyTest {
assertEquals("test-locked", response.get("locked"));
assertEquals("{\"payload\": \"value\"", response.get("payload"));
}
-
- private CommonHeader buildCommonHeader() {
-
- CommonHeader commonHeader = new CommonHeader();
- commonHeader.setTimeStamp("test-timestamp");
- commonHeader.setApiVer("test-api-version");
- commonHeader.setOriginatorId("test-originator-id");
- commonHeader.setRequestID("test-request-id");
- commonHeader.setSubRequestId("test-subrequest-id");
-
- Map<String, String> flags = new HashMap<>();
- flags.put("key1", "flag1");
- flags.put("key2", "flag2");
- flags.put("key3", "flag3");
-
- commonHeader.setFlags(flags);
- return commonHeader;
- }
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/operation/GenericProviderOperationsRequestFormatterTest.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/operation/GenericProviderOperationsRequestFormatterTest.java
index 4eaa86a59..285404dec 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/operation/GenericProviderOperationsRequestFormatterTest.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/operation/GenericProviderOperationsRequestFormatterTest.java
@@ -25,6 +25,7 @@ package org.onap.appc.listener.LCM.operation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.onap.appc.listener.TestUtil.JSON_OUTPUT_BODY_STR;
import com.fasterxml.jackson.databind.JsonNode;
import java.net.MalformedURLException;
@@ -39,13 +40,7 @@ import org.onap.appc.listener.util.Mapper;
public class GenericProviderOperationsRequestFormatterTest {
- private static final String jsonOutputBodyStr =
- "{\"output\":{\"common-header\":{\"timestamp\":\"2016-08-03T08:50:18.97Z\","
- + "\"api-ver\":\"1\",\"flags\":{\"force\":\"TRUE\",\"ttl\":\"9900\"},\"sub-request-id\":\"1\","
- + "\"request-id\":\"123\",\"originator-id\":\"1\"},\"locked\": \"test-locked\","
- + "\"status\":{\"message\":\"test message\",\"code\":200}}}";
-
- private static final String invalidJsonOutputBodyStr =
+ private static final String INVALID_JSON_OUTPUT_BODY_STR =
"{\"output\":{\"common-header\":{\"timestamp\":\"2016-08-03T08:50:18.97Z\","
+ "\"api-ver\":\"1\",\"flags\":{\"force\":\"TRUE\",\"ttl\":\"9900\"},\"sub-request-id\":\"1\","
+ "\"request-id\":\"123\",\"originator-id\":\"1\"}}}";
@@ -76,14 +71,14 @@ public class GenericProviderOperationsRequestFormatterTest {
@Test(expected = APPCException.class)
public void should_throw_when_invalid_json() throws APPCException {
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(invalidJsonOutputBodyStr);
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(INVALID_JSON_OUTPUT_BODY_STR);
requestFormatter.getResponseStatus(jsonNode);
}
@Test
public void should_extract_response_status() throws APPCException {
- JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonOutputBodyStr);
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_OUTPUT_BODY_STR);
ResponseStatus status = requestFormatter.getResponseStatus(jsonNode);
assertEquals("test message", status.getValue());
@@ -93,7 +88,7 @@ public class GenericProviderOperationsRequestFormatterTest {
@Test
public void should_return_extract_locked_field() throws APPCException {
- assertNull(requestFormatter.getLocked(new JSONObject(invalidJsonOutputBodyStr)));
- assertEquals("test-locked", requestFormatter.getLocked(new JSONObject(jsonOutputBodyStr)));
+ assertNull(requestFormatter.getLocked(new JSONObject(INVALID_JSON_OUTPUT_BODY_STR)));
+ assertEquals("test-locked", requestFormatter.getLocked(new JSONObject(JSON_OUTPUT_BODY_STR)));
}
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/operation/ProviderOperationsTest.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/operation/ProviderOperationsTest.java
index 42881f12f..0c435dc04 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/operation/ProviderOperationsTest.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/operation/ProviderOperationsTest.java
@@ -31,7 +31,6 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyString;
import com.att.aft.dme2.internal.jersey.core.util.Base64;
-import com.fasterxml.jackson.databind.JsonNode;
import java.io.IOException;
import java.net.Socket;
import java.net.SocketException;
@@ -45,17 +44,9 @@ import org.junit.Test;
import org.mockito.Mock;
import org.onap.appc.exceptions.APPCException;
import org.onap.appc.listener.LCM.operation.ProviderOperations.MySSLSocketFactory;
-import org.onap.appc.listener.util.Mapper;
public class ProviderOperationsTest {
- private static final String jsonInputBodyStr =
- "{\"input\":{ \"common-header\": { \"timestamp\": \"2016-08-03T08:50:18.97Z\", "
- + "\"api-ver\": \"1\", \"originator-id\": \"1\", \"request-id\": \"123\", \"sub-request-id\": \"1\", "
- + "\"flags\": { \"force\":\"TRUE\", \"ttl\":\"9900\" } }, \"action\": \"Stop\", "
- + "\"action-identifiers\": { \"vnf-id\": \"TEST\" } }}";
- private final JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
-
private ProviderOperations providerOperations;
private MySSLSocketFactory socketFactory;
@@ -104,12 +95,6 @@ public class ProviderOperationsTest {
providerOperations.topologyDG("test-rpc-name", null);
}
- @Test
- public void todo() throws APPCException {
- //TODO write some test cases for topologyDG method
-// JsonNode result = providerOperations.topologyDG("test", jsonNode);
- }
-
@Test(expected = SocketException.class)
public void sslSocketFactory_should_throw_when_socket_not_connected() throws IOException {
Socket socket = socketFactory.createSocket();
@@ -117,4 +102,6 @@ public class ProviderOperationsTest {
socketFactory.createSocket(socket, "127.0.0.1", 123, true);
}
+
+ //TODO write some test cases for topologyDG method
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/TestUtil.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/TestUtil.java
new file mode 100644
index 000000000..f28ad83b5
--- /dev/null
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/TestUtil.java
@@ -0,0 +1,82 @@
+package org.onap.appc.listener;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.util.HashMap;
+import java.util.Map;
+import org.onap.appc.listener.LCM.model.ActionIdentifiers;
+import org.onap.appc.listener.LCM.model.CommonHeader;
+import org.onap.appc.listener.LCM.model.DmaapIncomingMessage;
+import org.onap.appc.listener.LCM.model.DmaapMessage;
+import org.onap.appc.listener.LCM.model.DmaapOutgoingMessage;
+import org.onap.appc.listener.util.Mapper;
+
+public class TestUtil {
+
+ public static final String JSON_INPUT_BODY_STR =
+ "{\"input\":{ \"common-header\": { \"timestamp\": \"2016-08-03T08:50:18.97Z\", "
+ + "\"api-ver\": \"1\", \"originator-id\": \"1\", \"request-id\": \"123\", \"sub-request-id\": \"1\", "
+ + "\"flags\": { \"force\":\"TRUE\", \"ttl\":\"9900\" } }, \"action\": \"Stop\", "
+ + "\"action-identifiers\": { \"vnf-id\": \"TEST\" } }}";
+
+ public static final String JSON_OUTPUT_BODY_STR =
+ "{\"output\":{\"common-header\":{\"timestamp\":\"2016-08-03T08:50:18.97Z\","
+ + "\"api-ver\":\"1\",\"flags\":{\"force\":\"TRUE\",\"ttl\":\"9900\"},\"sub-request-id\":\"1\","
+ + "\"request-id\":\"123\",\"originator-id\":\"1\"},\"locked\": \"test-locked\", "
+ + "\"status\":{\"message\":\"test message\",\"code\":200}}}";
+
+ public static DmaapMessage buildDmaapMessage() {
+
+ DmaapMessage dmaapMessage = new DmaapMessage();
+ dmaapMessage.setRpcName("test");
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_INPUT_BODY_STR);
+ dmaapMessage.setBody(jsonNode);
+ return dmaapMessage;
+ }
+
+ public static DmaapIncomingMessage buildDmaapIncomingMessage() {
+ DmaapIncomingMessage dmaapIncomingMessage = new DmaapIncomingMessage();
+ dmaapIncomingMessage.setRpcName("test");
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_INPUT_BODY_STR);
+ dmaapIncomingMessage.setBody(jsonNode);
+ return dmaapIncomingMessage;
+
+ }
+
+ public static DmaapOutgoingMessage buildDmaapOutgoingMessage() {
+ DmaapOutgoingMessage dmaapOutgoingMessage = new DmaapOutgoingMessage();
+ dmaapOutgoingMessage.setRpcName("test");
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_OUTPUT_BODY_STR);
+ dmaapOutgoingMessage.setBody(jsonNode);
+ return dmaapOutgoingMessage;
+
+ }
+
+ public static CommonHeader buildCommonHeader() {
+
+ CommonHeader commonHeader = new CommonHeader();
+ commonHeader.setTimeStamp("test-timestamp");
+ commonHeader.setApiVer("test-api-version");
+ commonHeader.setOriginatorId("test-originator-id");
+ commonHeader.setRequestID("test-request-id");
+ commonHeader.setSubRequestId("test-subrequest-id");
+
+ Map<String, String> flags = new HashMap<>();
+ flags.put("key1", "flag1");
+ flags.put("key2", "flag2");
+ flags.put("key3", "flag3");
+
+ commonHeader.setFlags(flags);
+ return commonHeader;
+ }
+
+ public static ActionIdentifiers buildActionIdentifiers() {
+
+ ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
+ actionIdentifiers.setServiceInstanceId("test-instance-id");
+ actionIdentifiers.setVnfID("test-vnf-id");
+ actionIdentifiers.setVnfcName("test-name");
+ actionIdentifiers.setVserverId("test-vserver-id");
+
+ return actionIdentifiers;
+ }
+}