From 0eb74a3aca9e996ba6954dc102e25120d693067b Mon Sep 17 00:00:00 2001 From: ezhil Date: Thu, 27 Sep 2018 16:10:01 +0530 Subject: Added testcase to PolicyFinderServiceImpl Added testcase for handle error method in PolicyFinderService Issue-ID: CCSDK-594 Change-Id: I5ec263001af0cf7ddc5a8065e54d5d162c295e29 Signed-off-by: ezhil --- .../extinf/impl/PolicyFinderServiceImplTest.java | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java index 4dc4fa7c..77ec7eeb 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java @@ -22,17 +22,7 @@ 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 { -- cgit 1.2.3-korg