From a035aefb6f6357bcc08202928e958f5dfeabb317 Mon Sep 17 00:00:00 2001 From: Tomasz Gwozdecki Date: Wed, 13 Mar 2019 04:40:42 -0400 Subject: junits for PombaClientImpl -Added new test to check Exception handling Change-Id: I3ddd8ac2e6a3e77ebf751fed8e4bc0ca6cc61e2f Issue-ID: VID-418 Signed-off-by: Tomasz Gwozdecki --- .../test/java/org/onap/vid/aai/PombaClientImplTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'vid-app-common') diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java index 222bf1e5b..c41a479d9 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java @@ -19,6 +19,7 @@ */ package org.onap.vid.aai; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.then; @@ -60,6 +61,20 @@ public class PombaClientImplTest { then(pombaRestInterface).should().RestPost("VidAaiController", expectedUrl, expectedPayload); } + @Test + public void should_handleException_withoutRethrowing() throws IOException { + //Given + String expectedUrl = "http://localhost/dummyUrl"; + String expectedPayload = readExpectedPombaJsonRequest(); + given(systemPropertiesWrapper.getProperty("pomba.server.url")).willReturn(expectedUrl); + given(pombaRestInterface.RestPost("VidAaiController", expectedUrl, expectedPayload)) + .willThrow(new NullPointerException()); + PombaRequest pombaRequest = createPombaRequest(); + + //When //Then + assertThatCode(() -> pombaClient.verify(pombaRequest)).doesNotThrowAnyException(); + } + private String readExpectedPombaJsonRequest() throws IOException { URL url = PombaClientImplTest.class.getClassLoader().getResource("pomba_request.json"); PombaRequest expectedPombaRequest = new ObjectMapper().readValue(url, PombaRequest.class); -- cgit 1.2.3-korg