Coverage for DmaapOutgoingMessage.java 67/39067/3
authoramshegokar <AS00500801@techmahindra.com>
Thu, 29 Mar 2018 07:57:29 +0000 (13:27 +0530)
committerRanda Maher <rx196w@att.com>
Thu, 29 Mar 2018 16:57:42 +0000 (16:57 +0000)
Coverage for DmaapOutgoingMessage.java
Sonar-Link:
https://sonar.onap.org/code?id=org.onap.appc%3Aappc&selected=org.onap.appc%3Aappc-oam-bundle%3Asrc%2Fmain%2Fjava%2Forg%2Fonap%2Fappc%2Foam%2Fmessageadapter%2FDmaapOutgoingMessage.java

Change-Id: Id7a7d8d76ad4bfce2e79ab9b62f39113dc4a8acb
Issue-ID: APPC-797
Signed-off-by: amshegokar <AS00500801@techmahindra.com>
appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/messageadapter/DmaapOutgoingMessageTest.java [new file with mode: 0644]

diff --git a/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/messageadapter/DmaapOutgoingMessageTest.java b/appc-oam/appc-oam-bundle/src/test/java/org/onap/appc/oam/messageadapter/DmaapOutgoingMessageTest.java
new file mode 100644 (file)
index 0000000..eb015e8
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* 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.
+* ============LICENSE_END=========================================================
+*/
+package org.onap.appc.oam.messageadapter;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.onap.appc.oam.messageadapter.DmaapOutgoingMessage.Body;
+
+public class DmaapOutgoingMessageTest {
+    private DmaapOutgoingMessage dmaapOutgoingMessage = new DmaapOutgoingMessage();
+    private Body body = new Body();
+
+    @Test
+    public void testGetServiceInstanceId() {
+        dmaapOutgoingMessage.setType("String");
+        Assert.assertEquals("String", dmaapOutgoingMessage.getType());
+    }
+
+    @Test
+    public void testGetCorrelationId() {
+        dmaapOutgoingMessage.setCorrelationID("ABC");
+        Assert.assertEquals("ABC", dmaapOutgoingMessage.getCorrelationID());
+    }
+
+    @Test
+    public void testGetCambriaPartition() {
+        dmaapOutgoingMessage.setCambriaPartition("cambriaPartition");
+        Assert.assertEquals("cambriaPartition", dmaapOutgoingMessage.getCambriaPartition());
+    }
+
+    @Test
+    public void testGetRpcName() {
+        dmaapOutgoingMessage.setRpcName("rpcName");
+        Assert.assertEquals("rpcName", dmaapOutgoingMessage.getRpcName());
+    }
+
+    @Test
+    public void testToString_ReturnNonEmptyString() {
+        Assert.assertNotEquals(dmaapOutgoingMessage.toString(), "");
+        Assert.assertNotEquals(dmaapOutgoingMessage.toString(), null);
+    }
+
+    @Test
+    public void testToString_ContainsString() {
+        Assert.assertTrue(dmaapOutgoingMessage.toString().contains("cambriaPartition"));
+    }
+
+    @Test
+    public void testGetBody() {
+        dmaapOutgoingMessage.setBody(new Body("This is test"));
+        Assert.assertEquals("This is test", dmaapOutgoingMessage.getBody().getOutput());
+    }
+
+    @Test
+    public void testGetOutput() {
+        dmaapOutgoingMessage.setBody(new Body());
+        dmaapOutgoingMessage.getBody().setOutput("Test Object");
+        Assert.assertEquals("Test Object", dmaapOutgoingMessage.getBody().getOutput());
+    }
+
+    @Test
+    public void testToStringBody_ReturnNonEmptyString() {
+        Assert.assertNotEquals(body.toString(), "");
+        Assert.assertNotEquals(body.toString(), null);
+    }
+
+    @Test
+    public void testToStringBody_ContainsString() {
+        Assert.assertTrue(body.toString().contains("Body"));
+    }
+}