aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-10-22 07:53:44 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-10-23 13:33:56 -0400
commit1e61676b77dd09659027b8984f050df7e8538526 (patch)
tree115053dba12b4b27a0f92de0e7648a672a66893a /ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test
parentf18fbfc026de9cf02126f57844c37abfee607394 (diff)
Consolidate PolicyRestAdapter setup
Put common code into PolicyEngineUtils that the controllers use to populate the PolicyRestController. Also some more sonar cleanup and formatting of XML files. Shortened 120 line characters. Removed some trailing spaces from comments. Fixed up one JUnit. Licenses. Issue-ID: POLICY-2133 Change-Id: Id7d8ac3ab60331535f048ec0f26aeb17a099414e Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test')
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/UpdateOthersPAPSTest.java22
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java8
2 files changed, 16 insertions, 14 deletions
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/UpdateOthersPAPSTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/UpdateOthersPAPSTest.java
index 5a8e20b26..99902012b 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/UpdateOthersPAPSTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/UpdateOthersPAPSTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.pap.test;
import static org.junit.Assert.assertTrue;
@@ -60,9 +61,9 @@ public class UpdateOthersPAPSTest {
public void setUp() throws Exception {
logger.info("setUp: Entering");
commonClassDao = mock(CommonClassDao.class);
-
- request = mock(HttpServletRequest.class);
- response = new MockHttpServletResponse();
+
+ request = mock(HttpServletRequest.class);
+ response = new MockHttpServletResponse();
List<Object> data = new ArrayList<>();
PolicyDBDaoEntity entity = new PolicyDBDaoEntity();
entity.setPolicyDBDaoUrl("http://localhost:8070/pap");
@@ -76,12 +77,12 @@ public class UpdateOthersPAPSTest {
data.add(entity);
data.add(entity1);
- System.setProperty("xacml.rest.pap.url","http://localhost:8070/pap");
+ System.setProperty("xacml.rest.pap.url", "http://localhost:8070/pap");
when(commonClassDao.getData(PolicyDBDaoEntity.class)).thenReturn(data);
}
@Test
- public void testNotifyOthersPAPsToUpdateConfigurations(){
+ public void testNotifyOthersPAPsToUpdateConfigurations() {
UpdateOthersPAPS updateOtherPaps = new UpdateOthersPAPS();
UpdateOthersPAPS.setCommonClassDao(commonClassDao);
when(request.getParameter("action")).thenReturn("rename");
@@ -98,7 +99,7 @@ public class UpdateOthersPAPSTest {
@PrepareForTest({Policy.class})
@Test
- public void testUpdateConfiguration() throws Exception{
+ public void testUpdateConfiguration() throws Exception {
UpdateOthersPAPS updateOtherPaps = new UpdateOthersPAPS();
UpdateObjectData data = new UpdateObjectData();
PowerMockito.mockStatic(Policy.class);
@@ -109,7 +110,8 @@ public class UpdateOthersPAPSTest {
when(Policy.getActionHome()).thenReturn("test");
File mockedFile = Mockito.mock(File.class);
Mockito.when(mockedFile.exists()).thenReturn(true);
- PowerMockito.whenNew(File.class).withParameterTypes(String.class).withArguments(Matchers.anyString()).thenReturn(mockedFile);
+ PowerMockito.whenNew(File.class).withParameterTypes(String.class).withArguments(Matchers.anyString())
+ .thenReturn(mockedFile);
updateOtherPaps.updateConfiguration(data, response);
assertTrue(response.getStatus() == 200);
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
index 1b65feddb..ebfbf551f 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java
@@ -24,7 +24,9 @@ package org.onap.policy.pap.test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.when;
+
import com.mockrunner.mock.web.MockServletInputStream;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -36,11 +38,13 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tomcat.dbcp.dbcp2.BasicDataSource;
@@ -79,7 +83,6 @@ import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletConfig;
import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder;
-
public class XACMLPAPTest {
private static final Log logger = LogFactory.getLog(XACMLPAPTest.class);
@@ -332,7 +335,6 @@ public class XACMLPAPTest {
Mockito.verify(httpServletResponse).addHeader("operation", "create");
}
-
@Test
public void testDecisonBLGuardPolicy() throws IOException, ServletException, SQLException {
httpServletRequest = Mockito.mock(HttpServletRequest.class);
@@ -445,7 +447,6 @@ public class XACMLPAPTest {
Mockito.verify(httpServletResponse).addHeader("operation", "create");
}
-
private void setPolicyCreation() {
CommonClassDao commonClassDao = Mockito.mock(CommonClassDao.class);
PolicyCreation.setCommonClassDao(commonClassDao);
@@ -694,7 +695,6 @@ public class XACMLPAPTest {
// Verify
Mockito.verify(httpServletResponse).setStatus(HttpServletResponse.SC_OK);
-
httpServletRequest = Mockito.mock(HttpServletRequest.class);
httpServletResponse = Mockito.mock(MockHttpServletResponse.class);
json = "{\"dictionaryFields\":{\"attributeName\":\"TestMMrestAPI1\",\"type\":\"REST\",\"url\":\"testsomeurl"