summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrudence Au <prudence.au@amdocs.com>2018-09-14 15:34:57 -0400
committerPrudence Au <prudence.au@amdocs.com>2018-09-14 15:37:35 -0400
commit39d422e9d7995f4ad04b93773da95158d111c4e4 (patch)
tree656a561ef0fa9145219bcf649d9104da5bc2c14c
parentbf4b8e3ac93106cf2373dafb89d5373fc17ef507 (diff)
Add JUnit tests to increase code coverage
Change-Id: I37914bc551d182322142db0fa62221e8eabcdd87 Signed-off-by: Prudence Au <prudence.au@amdocs.com> Issue-ID: LOG-649
-rw-r--r--src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/GenericResponseTest.java40
-rw-r--r--src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/JsonReaderTest.java47
-rw-r--r--src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VserverTest.java88
3 files changed, 175 insertions, 0 deletions
diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/GenericResponseTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/GenericResponseTest.java
new file mode 100644
index 0000000..ce11d61
--- /dev/null
+++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/GenericResponseTest.java
@@ -0,0 +1,40 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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.logging_analytics.pomba.pomba_aai_context_builder;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.onap.pomba.contextbuilder.aai.model.GenericResponse;
+
+public class GenericResponseTest {
+
+ @Test
+ public void testGenericResponse() {
+ GenericResponse response = new GenericResponse();
+
+ response.setFailureReason("failureReason");
+ response.setResponseObj(new Object());
+ response.setStatus("status");
+
+ assertEquals("failureReason", response.getFailureReason());
+ assertEquals("status", response.getStatus());
+ assertTrue(response.getResponseObj() != null);
+
+ }
+}
diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/JsonReaderTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/JsonReaderTest.java
new file mode 100644
index 0000000..b827fbc
--- /dev/null
+++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/JsonReaderTest.java
@@ -0,0 +1,47 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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.logging_analytics.pomba.pomba_aai_context_builder;
+
+import static org.junit.Assert.fail;
+import org.junit.Test;
+import org.onap.pomba.contextbuilder.aai.exception.AuditException;
+import org.onap.pomba.contextbuilder.aai.reader.JsonReader;
+
+public class JsonReaderTest {
+
+ @Test
+ public void testJsonReader() {
+ JsonReader reader = new JsonReader();
+ try {
+ reader.parse("{test:test}");
+ } catch(AuditException e) {
+ fail("This should not throw an exception.");
+ }
+ }
+
+ @Test
+ public void testJsonReaderWithException() {
+ JsonReader reader = new JsonReader();
+ try {
+ reader.parse("{test}");
+ fail("This should throw an exception.");
+ } catch(AuditException e) {
+ //Just a test, no need to log the exception here.
+ }
+ }
+}
diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VserverTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VserverTest.java
new file mode 100644
index 0000000..b42da7e
--- /dev/null
+++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/VserverTest.java
@@ -0,0 +1,88 @@
+/*
+ * ============LICENSE_START===================================================
+ * Copyright (c) 2018 Amdocs
+ * ============================================================================
+ * 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.logging_analytics.pomba.pomba_aai_context_builder;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+import org.onap.pomba.contextbuilder.aai.datatype.Relationship;
+import org.onap.pomba.contextbuilder.aai.datatype.RelationshipList;
+import org.onap.pomba.contextbuilder.aai.datatype.Vserver;
+
+public class VserverTest {
+
+ @Test
+ public void testVserver() {
+ Vserver aVServer = new Vserver();
+ aVServer.setVserverId("vserverId");
+ aVServer.setVserverName("vserverName");
+ aVServer.setVserverName2("vserverName2");
+ aVServer.setVserverSelflink("vserverSelflink");
+ aVServer.setInMaint(true);
+ aVServer.setIsClosedLoopDisabled(true);
+ aVServer.setProvStatus("provStatus");
+ Relationship relationship = new Relationship();
+ List<Relationship> list = new ArrayList<Relationship>();
+ list.add(relationship);
+ RelationshipList relationshipList = new RelationshipList(list);
+ aVServer.setRelationshipList(relationshipList);
+ aVServer.setResourceVersion("resourceVersion");
+
+ assertEquals("vserverId", aVServer.getVserverId());
+ assertEquals("vserverName", aVServer.getVserverName());
+ assertEquals("vserverName2", aVServer.getVserverName2());
+ assertEquals("vserverSelflink", aVServer.getVserverSelflink());
+ assertEquals(true, aVServer.getInMaint());
+ assertEquals(true, aVServer.getIsClosedLoopDisabled());
+ assertEquals("provStatus", aVServer.getProvStatus());
+ assertTrue(aVServer.getRelationshipList().getRelationship().size() == 1);
+ assertEquals("resourceVersion", aVServer.getResourceVersion());
+
+ String vserverToString = aVServer.toString();
+ assertTrue(vserverToString.contains("[vserverId=vserverId,vserverName=vserverName,vserverName2=vserverName2,provStatus=provStatus,vserverSelflink=vserverSelflink,inMaint=true,isClosedLoopDisabled=true,resourceVersion=resourceVersion"));
+ }
+
+ @Test
+ public void testVserverWithParameters() {
+ Vserver aVServer = new Vserver("vserverId", "vserverName", "vserverName2", "provStatus", "vserverSelflink", true, true, "resourceVersion", new RelationshipList());
+
+ assertEquals("vserverId", aVServer.getVserverId());
+ assertEquals("vserverName", aVServer.getVserverName());
+ assertEquals("vserverName2", aVServer.getVserverName2());
+ assertEquals("vserverSelflink", aVServer.getVserverSelflink());
+ assertEquals(true, aVServer.getInMaint());
+ assertEquals(true, aVServer.getIsClosedLoopDisabled());
+ assertEquals("provStatus", aVServer.getProvStatus());
+ assertEquals("resourceVersion", aVServer.getResourceVersion());
+ }
+
+ @Test
+ public void testVserverEquals() {
+ Vserver aVServer1 = new Vserver("vserverId1", "vserverName1", "vserverName2", "provStatus1", "vserverSelflink1", true, true, "resourceVersion1", new RelationshipList());
+ Vserver aVServer2 = new Vserver("vserverId2", "vserverName2", "vserverName2", "provStatus2", "vserverSelflink2", false, false, "resourceVersion2", new RelationshipList());
+ Vserver aVServer3 = new Vserver("vserverId1", "vserverName1", "vserverName2", "provStatus1", "vserverSelflink1", true, true, "resourceVersion1", new RelationshipList());
+
+ assertTrue(aVServer1.equals(aVServer1));
+ assertFalse(aVServer1.equals(aVServer2));
+ assertTrue(aVServer1.equals(aVServer3));
+ }
+
+}