aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/UpdateOthersPAPSTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/UpdateOthersPAPSTest.java')
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/UpdateOthersPAPSTest.java39
1 files changed, 22 insertions, 17 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..fcec4a652 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-2020 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,12 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.pap.test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.mockito.ArgumentMatchers.anyString;
import java.io.File;
import java.util.ArrayList;
@@ -34,7 +36,6 @@ import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Matchers;
import org.mockito.Mockito;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
@@ -42,13 +43,16 @@ import org.onap.policy.pap.xacml.rest.UpdateOthersPAPS;
import org.onap.policy.pap.xacml.rest.adapters.UpdateObjectData;
import org.onap.policy.pap.xacml.rest.components.Policy;
import org.onap.policy.rest.dao.CommonClassDao;
-import org.onap.policy.rest.jpa.PolicyDBDaoEntity;
+import org.onap.policy.rest.jpa.PolicyDbDaoEntity;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.springframework.mock.web.MockHttpServletResponse;
@RunWith(PowerMockRunner.class)
+@PowerMockIgnore({"com.sun.org.apache.xalan.*", "com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"})
+@PrepareForTest(UpdateOthersPAPS.class)
public class UpdateOthersPAPSTest {
private static Logger logger = FlexLogger.getLogger(UpdateOthersPAPSTest.class);
@@ -60,28 +64,28 @@ 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");
+ PolicyDbDaoEntity entity = new PolicyDbDaoEntity();
+ entity.setPolicyDbDaoUrl("http://localhost:8070/pap");
entity.setUsername("test");
entity.setPassword("test");
- PolicyDBDaoEntity entity1 = new PolicyDBDaoEntity();
- entity1.setPolicyDBDaoUrl("http://localhost:8071/pap");
+ PolicyDbDaoEntity entity1 = new PolicyDbDaoEntity();
+ entity1.setPolicyDbDaoUrl("http://localhost:8071/pap");
entity1.setUsername("test");
entity1.setPassword("test");
data.add(entity);
data.add(entity1);
- System.setProperty("xacml.rest.pap.url","http://localhost:8070/pap");
- when(commonClassDao.getData(PolicyDBDaoEntity.class)).thenReturn(data);
+ 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 +102,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 +113,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(anyString())
+ .thenReturn(mockedFile);
updateOtherPaps.updateConfiguration(data, response);
assertTrue(response.getStatus() == 200);
}