From a92189c6161f7bb8494cb8ea519885533bc34f53 Mon Sep 17 00:00:00 2001 From: "Sanchez, Gabriel (gs882h)" Date: Mon, 11 Mar 2019 17:14:03 +0000 Subject: Increase code coverage to 55% for Dublin Remove unused class and add some exception coverage test using exceptionRule Issue-ID: AAI-2221 Change-Id: I022f7a24f7247fe6dd213ddf9631823b3c1b5d1b Signed-off-by: Sanchez, Gabriel (gs882h) --- .../spike/event/incoming/GizmoGraphEventTest.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/test') diff --git a/src/test/java/org/onap/aai/spike/event/incoming/GizmoGraphEventTest.java b/src/test/java/org/onap/aai/spike/event/incoming/GizmoGraphEventTest.java index 87b298f..49fb5ef 100644 --- a/src/test/java/org/onap/aai/spike/event/incoming/GizmoGraphEventTest.java +++ b/src/test/java/org/onap/aai/spike/event/incoming/GizmoGraphEventTest.java @@ -24,7 +24,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import java.io.IOException; import java.net.URISyntaxException; + +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.spike.OXMModelLoaderSetup; @@ -36,6 +39,11 @@ import org.onap.aai.spike.test.util.TestFileReader; @RunWith(MockitoJUnitRunner.Silent.class) public class GizmoGraphEventTest extends OXMModelLoaderSetup { + private static final String SPIKE_EXCEPTION_MESSAGE = "Unable to parse JSON string: Empty or null JSON string."; + + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + @Test public void TestToSpikeGraphEvent() throws SpikeException, IOException, URISyntaxException { String champNotification = @@ -63,6 +71,8 @@ public class GizmoGraphEventTest extends OXMModelLoaderSetup { gizmoGraphEvent = new GizmoGraphEvent(); GizmoEdge relationship = new GizmoEdge(); + relationship.setSource(vertex); + relationship.setTarget(vertex); relationship.setId("909d"); gizmoGraphEvent.setRelationship(relationship); @@ -99,4 +109,32 @@ public class GizmoGraphEventTest extends OXMModelLoaderSetup { objectType = gizmoGraphEvent.getObjectType(); assertNull(objectType); } + + @Test + public void TestGizmoEdgeExceptionEmpty() throws SpikeException { + exceptionRule.expect(SpikeException.class); + exceptionRule.expectMessage(SPIKE_EXCEPTION_MESSAGE); + GizmoEdge.fromJson(""); + } + + @Test + public void TestGizmoEdgeExceptionNull() throws SpikeException { + exceptionRule.expect(SpikeException.class); + exceptionRule.expectMessage(SPIKE_EXCEPTION_MESSAGE); + GizmoEdge.fromJson(null); + } + + @Test + public void TestGizmoVertexExceptionEmpty() throws SpikeException { + exceptionRule.expect(SpikeException.class); + exceptionRule.expectMessage(SPIKE_EXCEPTION_MESSAGE); + GizmoVertex.fromJson(""); + } + + @Test + public void TestGizmoVertexExceptionNull() throws SpikeException { + exceptionRule.expect(SpikeException.class); + exceptionRule.expectMessage(SPIKE_EXCEPTION_MESSAGE); + GizmoVertex.fromJson(null); + } } -- cgit 1.2.3-korg