junits for PombaClientImpl 92/82092/1
authorTomasz Gwozdecki <tomasz.gwozdecki@nokia.com>
Wed, 13 Mar 2019 08:40:42 +0000 (04:40 -0400)
committerTomasz Gwozdecki <tomasz.gwozdecki@nokia.com>
Wed, 13 Mar 2019 08:40:42 +0000 (04:40 -0400)
-Added new test to check Exception handling

Change-Id: I3ddd8ac2e6a3e77ebf751fed8e4bc0ca6cc61e2f
Issue-ID: VID-418
Signed-off-by: Tomasz Gwozdecki <tomasz.gwozdecki@nokia.com>
vid-app-common/src/test/java/org/onap/vid/aai/PombaClientImplTest.java

index 222bf1e..c41a479 100644 (file)
@@ -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);