diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2019-10-10 09:58:54 -0400 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2019-10-10 11:11:27 -0400 |
commit | b86c95c99240e8ed0ef91932a70ebed313dbd60c (patch) | |
tree | bc9eca661739636e41aab6151fbc38b33dcf2696 /POLICY-SDK-APP/src/test/java | |
parent | a446733c9918cb264585ddc35b5e11bf3500bdf8 (diff) |
Checkstyle and some coverage
Address some trailing space from previous review. Mostly this
was checkstyle issues of naming methods and variables, distance
from usage, missing javadoc, 120 character spacing.
Did add a few trivial code coverage tests.
Issue-ID: POLICY-2133
Change-Id: I159d1b27429b6bef046092ea3a4045fbd3a1071c
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'POLICY-SDK-APP/src/test/java')
-rw-r--r-- | POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java index 912f4d9ce..0a24713a6 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyRestControllerTest.java @@ -22,6 +22,9 @@ package org.onap.policy.admin; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -39,6 +42,7 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import org.onap.policy.controller.CreateFirewallController; +import org.onap.policy.controller.PolicyController; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.ActionList; import org.onap.policy.rest.jpa.AddressGroup; @@ -69,10 +73,15 @@ public class PolicyRestControllerTest { private List<Object> tagListData; private List<Object> termListData; + /** + * Before. + * + * @throws Exception exception + */ @Before public void setUp() throws Exception { commonClassDao = mock(CommonClassDao.class); - HttpSession mockSession = mock(HttpSession.class); + final HttpSession mockSession = mock(HttpSession.class); request = mock(HttpServletRequest.class); response = new MockHttpServletResponse(); User user = new User(); @@ -212,6 +221,10 @@ public class PolicyRestControllerTest { @Test public final void testPolicyCreationController() { + assertNull(PolicyRestController.getCommonClassDao()); + PolicyRestController.setCommonClassDao(commonClassDao); + assertNotNull(PolicyRestController.getCommonClassDao()); + PolicyRestController controller = new PolicyRestController(); BufferedReader reader = new BufferedReader(new StringReader(clRequestString)); try { @@ -222,6 +235,7 @@ public class PolicyRestControllerTest { } PolicyRestController controller1 = new PolicyRestController(); CreateFirewallController.setCommonClassDao(commonClassDao); + assertNotNull(CreateFirewallController.getCommonClassDao()); BufferedReader reader1 = new BufferedReader(new StringReader(fwRequestString)); try { Mockito.when(request.getReader()).thenReturn(reader1); @@ -242,6 +256,27 @@ public class PolicyRestControllerTest { } @Test + public final void testSearchPolicy() throws IOException { + PolicyController.setjUnit(true); + PolicyController.setPapUrl("http://localhost:8070/pap/"); + PolicyRestController controller = new PolicyRestController(); + BufferedReader reader = new BufferedReader(new StringReader("{\"foo\":\"bar\"}")); + Mockito.when(request.getReader()).thenReturn(reader); + Mockito.when(request.getRequestURI()).thenReturn("/pap/foo/"); + assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> + controller.searchPolicy(request, response)); + } + + @Test + public final void testSearchDictionaryController() throws IOException { + PolicyRestController controller = new PolicyRestController(); + BufferedReader reader = new BufferedReader(new StringReader("{\"foo\":\"bar\"}")); + Mockito.when(request.getReader()).thenReturn(reader); + Mockito.when(request.getRequestURI()).thenReturn("/pap/foo/"); + assertNull(controller.searchDictionaryController(request, response)); + } + + @Test public final void testDeleteElasticData() { PolicyRestController controller = new PolicyRestController(); try { @@ -250,4 +285,11 @@ public class PolicyRestControllerTest { fail(); } } + + @Test + public final void testNotifyOtherPaps() { + PolicyRestController controller = new PolicyRestController(); + String strReturn = controller.notifyOtherPapsToUpdateConfigurations("mode", "newName", "oldName"); + assertNull(strReturn); + } } |