summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapMessage.java62
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/conv/ConverterTest.java20
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapIncomingMessageTest.java76
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapMessageTest.java89
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapOutgoingMessageTest.java74
5 files changed, 278 insertions, 43 deletions
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapMessage.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapMessage.java
index 214783d10..e64a9dde4 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapMessage.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapMessage.java
@@ -26,13 +26,13 @@ package org.onap.appc.listener.LCM.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
-public class DmaapMessage{
+public class DmaapMessage {
@JsonProperty("version")
private String version;
@@ -52,53 +52,52 @@ public class DmaapMessage{
@JsonProperty("body")
private JsonNode body;
- public DmaapMessage() {
- }
-
public String getVersion() {
return version;
}
- public void setVersion(String version) {
- this.version = version;
- }
public String getType() {
return type;
}
- public void setType(String type) {
- this.type = type;
- }
-
public String getCorrelationID() {
return correlationID;
}
- public void setCorrelationID(String correlationID) {
- this.correlationID = correlationID;
- }
-
public String getCambriaPartition() {
return cambriaPartition;
}
- public void setCambriaPartition(String cambriaPartition) {
- this.cambriaPartition = cambriaPartition;
- }
-
public String getRpcName() {
return rpcName;
}
- public void setRpcName(String rpcName) {
- this.rpcName = rpcName;
- }
-
public JsonNode getBody() {
return body;
}
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setCorrelationID(String correlationID) {
+ this.correlationID = correlationID;
+ }
+
+ public void setCambriaPartition(String cambriaPartition) {
+ this.cambriaPartition = cambriaPartition;
+ }
+
+ public void setRpcName(String rpcName) {
+ this.rpcName = rpcName;
+ }
+
public void setBody(JsonNode body) {
this.body = body;
}
@@ -106,14 +105,13 @@ public class DmaapMessage{
@Override
public String toString() {
return "DmaapMessage{" +
- "version='" + version + '\'' +
- ", type='" + type + '\'' +
- ", correlationId='" + correlationID + '\'' +
- ", cambriaPartition='" + cambriaPartition + '\'' +
- ", rpcName='" + rpcName + '\'' +
- ", body=" + body +
- '}';
+ "version='" + version + '\'' +
+ ", type='" + type + '\'' +
+ ", correlationId='" + correlationID + '\'' +
+ ", cambriaPartition='" + cambriaPartition + '\'' +
+ ", rpcName='" + rpcName + '\'' +
+ ", body=" + body +
+ '}';
}
-
}
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 f51a6a4d7..d27bcc8f4 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
@@ -28,25 +28,24 @@ import static org.junit.Assert.assertEquals;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
-import org.junit.Assert;
import org.junit.Test;
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.demo.model.OutgoingMessage;
import org.onap.appc.listener.util.Mapper;
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 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 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\"},"
@@ -135,7 +134,6 @@ public class ConverterTest {
}
-
@Test(expected = IllegalArgumentException.class)
public void extractStatusCode_should_throw_given_null_argument() {
Converter.extractStatusCode(null);
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
new file mode 100644
index 000000000..e4b06dff3
--- /dev/null
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapIncomingMessageTest.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2018 Nokia Solutions and Networks
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.appc.listener.LCM.model;
+
+import static org.junit.Assert.assertEquals;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.junit.Before;
+import org.junit.Test;
+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
+ public void setup() {
+ dmaapIncomingMessage = new DmaapIncomingMessage();
+ }
+
+ @Test
+ public void should_set_default_cambria_partition_when_initialized() {
+
+ assertEquals("APP-C", dmaapIncomingMessage.getCambriaPartition());
+ }
+
+ @Test
+ public void toString_should_return_valid_string_representation() {
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
+
+ dmaapIncomingMessage.setVersion("test-version");
+ dmaapIncomingMessage.setType("test-type");
+ dmaapIncomingMessage.setCorrelationID("test-correlation-id");
+ dmaapIncomingMessage.setCambriaPartition("test-cambria-partition");
+ dmaapIncomingMessage.setRpcName("test-rpc-name");
+ dmaapIncomingMessage.setBody(jsonNode);
+
+ assertEquals("DmaapIncomingMessage{DmaapMessage{" +
+ "version='" + dmaapIncomingMessage.getVersion() + '\'' +
+ ", type='" + dmaapIncomingMessage.getType() + '\'' +
+ ", correlationId='" + dmaapIncomingMessage.getCorrelationID() + '\'' +
+ ", cambriaPartition='" + dmaapIncomingMessage.getCambriaPartition() + '\'' +
+ ", rpcName='" + dmaapIncomingMessage.getRpcName() + '\'' +
+ ", body=" + dmaapIncomingMessage.getBody() +
+ "}}", dmaapIncomingMessage.toString());
+ }
+
+
+}
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
new file mode 100644
index 000000000..4d6d03b24
--- /dev/null
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapMessageTest.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2018 Nokia Solutions and Networks
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.appc.listener.LCM.model;
+
+import static org.junit.Assert.assertEquals;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.junit.Before;
+import org.junit.Test;
+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
+ public void setup() {
+ dmaapMessage = new DmaapMessage();
+ }
+
+ @Test
+ public void should_set_properties() {
+
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
+
+ dmaapMessage.setVersion("test-version");
+ dmaapMessage.setType("test-type");
+ dmaapMessage.setCorrelationID("test-correlation-id");
+ dmaapMessage.setCambriaPartition("test-cambria-partition");
+ dmaapMessage.setRpcName("test-rpc-name");
+ dmaapMessage.setBody(jsonNode);
+
+ assertEquals("test-version", dmaapMessage.getVersion());
+ assertEquals("test-type", dmaapMessage.getType());
+ assertEquals("test-correlation-id", dmaapMessage.getCorrelationID());
+ assertEquals("test-cambria-partition", dmaapMessage.getCambriaPartition());
+ assertEquals("test-rpc-name", dmaapMessage.getRpcName());
+ assertEquals(jsonNode, dmaapMessage.getBody());
+ }
+
+ @Test
+ public void toString_should_return_valid_string_representation() {
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
+
+ dmaapMessage.setVersion("test-version");
+ dmaapMessage.setType("test-type");
+ dmaapMessage.setCorrelationID("test-correlation-id");
+ dmaapMessage.setCambriaPartition("test-cambria-partition");
+ dmaapMessage.setRpcName("test-rpc-name");
+ dmaapMessage.setBody(jsonNode);
+
+ assertEquals("DmaapMessage{" +
+ "version='" + dmaapMessage.getVersion() + '\'' +
+ ", type='" + dmaapMessage.getType() + '\'' +
+ ", correlationId='" + dmaapMessage.getCorrelationID() + '\'' +
+ ", cambriaPartition='" + dmaapMessage.getCambriaPartition() + '\'' +
+ ", rpcName='" + dmaapMessage.getRpcName() + '\'' +
+ ", body=" + dmaapMessage.getBody() +
+ '}', dmaapMessage.toString());
+ }
+}
+
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
new file mode 100644
index 000000000..09223ce4f
--- /dev/null
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/onap/appc/listener/LCM/model/DmaapOutgoingMessageTest.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2018 Nokia Solutions and Networks
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.appc.listener.LCM.model;
+
+import static org.junit.Assert.assertEquals;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.junit.Before;
+import org.junit.Test;
+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
+ public void setup() {
+ dmaapOutgoingMessage = new DmaapOutgoingMessage();
+ }
+
+ @Test
+ public void should_set_default_cambria_partition_when_initialized() {
+
+ assertEquals("MSO", dmaapOutgoingMessage.getCambriaPartition());
+ }
+
+ @Test
+ public void toString_should_return_valid_string_representation() {
+ JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
+
+ dmaapOutgoingMessage.setVersion("test-version");
+ dmaapOutgoingMessage.setType("test-type");
+ dmaapOutgoingMessage.setCorrelationID("test-correlation-id");
+ dmaapOutgoingMessage.setCambriaPartition("test-cambria-partition");
+ dmaapOutgoingMessage.setRpcName("test-rpc-name");
+ dmaapOutgoingMessage.setBody(jsonNode);
+
+ assertEquals("DmaapOutgoingMessage{DmaapMessage{" +
+ "version='" + dmaapOutgoingMessage.getVersion() + '\'' +
+ ", type='" + dmaapOutgoingMessage.getType() + '\'' +
+ ", correlationId='" + dmaapOutgoingMessage.getCorrelationID() + '\'' +
+ ", cambriaPartition='" + dmaapOutgoingMessage.getCambriaPartition() + '\'' +
+ ", rpcName='" + dmaapOutgoingMessage.getRpcName() + '\'' +
+ ", body=" + dmaapOutgoingMessage.getBody() +
+ "}}", dmaapOutgoingMessage.toString());
+ }
+}