Added testcase to PolicyFinderServiceImpl 77/69277/1
authorezhil <ezhrajam@in.ibm.com>
Thu, 27 Sep 2018 10:40:01 +0000 (16:10 +0530)
committerezhil <ezhrajam@in.ibm.com>
Thu, 27 Sep 2018 10:41:27 +0000 (16:11 +0530)
Added testcase for handle error method in PolicyFinderService
Issue-ID: CCSDK-594
Change-Id: I5ec263001af0cf7ddc5a8065e54d5d162c295e29
Signed-off-by: ezhil <ezhrajam@in.ibm.com>
ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java

index 4dc4fa7..77ec7ee 100644 (file)
 
 package org.onap.ccsdk.apps.ms.neng.service.extinf.impl;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.when;
-
 import com.fasterxml.jackson.databind.ObjectMapper;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.InjectMocks;
@@ -49,8 +39,18 @@ import org.springframework.boot.web.client.RestTemplateBuilder;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.RequestEntity;
 import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.HttpClientErrorException;
+import org.springframework.web.client.HttpStatusCodeException;
 import org.springframework.web.client.RestTemplate;
 
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.when;
+
 @RunWith(MockitoJUnitRunner.class)
 public class PolicyFinderServiceImplTest {
     @InjectMocks
@@ -77,6 +77,13 @@ public class PolicyFinderServiceImplTest {
         assertNull(policyFinder.findPolicy("policy"));
     }
 
+    @SuppressWarnings("unchecked")
+    @Test(expected = NengException.class)
+    public void testHandleError_NOT_FOUND() throws Exception{
+        HttpStatusCodeException e = new HttpClientErrorException(HttpStatus.NOT_FOUND,"",null,StandardCharsets.US_ASCII);
+        policyFinder.handleError(e);
+
+    }
     @SuppressWarnings("unchecked")
     @Test
     public void testmakeOutboundCall() throws Exception {