ONAP-REST DAO Sonar/Checkstyle clean and knock-on
[policy/engine.git] / ONAP-PAP-REST / src / test / java / org / onap / policy / pap / xacml / rest / ConsoleAndApiServiceTest.java
index 0cd70f9..e78151f 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP-PAP-REST
  * ================================================================================
  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +27,7 @@ import static org.mockito.Mockito.when;
 import com.att.research.xacml.util.XACMLProperties;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ObjectWriter;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
@@ -34,10 +36,13 @@ import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
+
 import org.apache.commons.io.IOUtils;
 import org.hibernate.SessionFactory;
 import org.junit.Before;
@@ -46,16 +51,16 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.mockito.Mockito;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
 import org.onap.policy.pap.xacml.rest.components.ConfigPolicy;
 import org.onap.policy.pap.xacml.rest.components.Policy;
-import org.onap.policy.pap.xacml.rest.components.PolicyDBDao;
+import org.onap.policy.pap.xacml.rest.components.PolicyDbDao;
 import org.onap.policy.pap.xacml.rest.components.PolicyDBDaoTest;
-import org.onap.policy.pap.xacml.rest.components.PolicyDBDaoTransaction;
+import org.onap.policy.pap.xacml.rest.components.PolicyDbDaoTransaction;
 import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
 import org.onap.policy.pap.xacml.rest.policycontroller.PolicyCreation;
 import org.onap.policy.rest.adapter.PolicyRestAdapter;
-import org.onap.policy.rest.dao.PolicyDBException;
+import org.onap.policy.rest.dao.PolicyDbException;
 import org.onap.policy.xacml.std.pap.StdEngine;
 import org.onap.policy.xacml.std.pap.StdPDP;
 import org.springframework.mock.web.DelegatingServletInputStream;
@@ -83,8 +88,8 @@ public class ConsoleAndApiServiceTest {
     private static final String USER_ID = "userId";
     private static final String APIFLAG = "apiflag";
     private static final String ENVIRONMENT_HEADER = "Environment";
-    private static final ONAPLoggingContext logContext = Mockito.mock(ONAPLoggingContext.class);
-    private static PolicyDBDao dbd;
+    private static final OnapLoggingContext logContext = Mockito.mock(OnapLoggingContext.class);
+    private static PolicyDbDao dbd;
     private static StdEngine stdEngine = null;
     private static SessionFactory sessionFactory = null;
     private static List<String> headers = new ArrayList<>();
@@ -105,9 +110,9 @@ public class ConsoleAndApiServiceTest {
     public static void setUpBeforeClass() throws Exception {
         System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "src/test/resources/xacml.pap.properties");
         sessionFactory = PolicyDBDaoTest.setupH2DbDaoImpl("testConsoleApi");
-        PolicyDBDao.setJunit(true);
-        dbd = PolicyDBDao.getPolicyDBDaoInstance();
-        PolicyDBDao.setJunit(true);
+        PolicyDbDao.setJunit(true);
+        dbd = PolicyDbDao.getPolicyDbDaoInstance();
+        PolicyDbDao.setJunit(true);
         consoleAndApi = new ConsoleAndApiService();
 
         servletConfig = Mockito.mock(MockServletConfig.class);
@@ -119,7 +124,6 @@ public class ConsoleAndApiServiceTest {
         pap.init(servletConfig);
     }
 
-
     /**
      * Sets the up.
      *
@@ -228,7 +232,6 @@ public class ConsoleAndApiServiceTest {
         consoleAndApi.doAcPost(httpServletRequest, httpServletResponse, TESTGRP5, logContext, stdEngine);
         assertTrue(HttpServletResponse.SC_NO_CONTENT == httpServletResponse.getStatus());
 
-
         Mockito.when(httpServletRequest.getParameter(GROUP_DESCRIPTION)).thenReturn(null);
         Mockito.when(httpServletRequest.getParameter(PDP_ID)).thenReturn("http://localhost:4344/pdp/");
         Mockito.when(httpServletRequest.getMethod()).thenReturn(PUT);
@@ -240,7 +243,6 @@ public class ConsoleAndApiServiceTest {
         consoleAndApi.doAcPut(httpServletRequest, httpServletResponse, TESTGRP5, logContext, stdEngine);
         assertTrue(HttpServletResponse.SC_NO_CONTENT == httpServletResponse.getStatus());
 
-
         httpServletRequest = Mockito.mock(HttpServletRequest.class);
         httpServletResponse = new MockHttpServletResponse();
         Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn(DEVL);
@@ -252,7 +254,6 @@ public class ConsoleAndApiServiceTest {
         consoleAndApi.doAcPost(httpServletRequest, httpServletResponse, TESTGRP4, logContext, stdEngine);
         assertTrue(HttpServletResponse.SC_NO_CONTENT == httpServletResponse.getStatus());
 
-
         httpServletRequest = Mockito.mock(HttpServletRequest.class);
         httpServletResponse = new MockHttpServletResponse();
         Mockito.when(httpServletRequest.getHeader(ENVIRONMENT_HEADER)).thenReturn(DEVL);
@@ -264,7 +265,6 @@ public class ConsoleAndApiServiceTest {
         consoleAndApi.doAcDelete(httpServletRequest, httpServletResponse, TESTGRP4, logContext, stdEngine);
         assertTrue(HttpServletResponse.SC_NO_CONTENT == httpServletResponse.getStatus());
 
-
     }
 
     @Test
@@ -293,7 +293,7 @@ public class ConsoleAndApiServiceTest {
         assertTrue(HttpServletResponse.SC_OK == httpServletResponse.getStatus());
     }
 
-    private static void populatePolicyInDb() throws IOException, PolicyDBException {
+    private static void populatePolicyInDb() throws IOException, PolicyDbException {
         CommonClassDaoImpl.setSessionfactory(sessionFactory);
         PolicyCreation.setCommonClassDao(new CommonClassDaoImpl());
         Policy policyObject = new ConfigPolicy();
@@ -318,7 +318,7 @@ public class ConsoleAndApiServiceTest {
         policyObject.policyAdapter.setParentPath(IOUtils.toString(
                 ConsoleAndApiServiceTest.class.getClassLoader().getResourceAsStream("Config_SampleTest1206.1.xml")));
 
-        PolicyDBDaoTransaction transaction = dbd.getNewTransaction();
+        PolicyDbDaoTransaction transaction = dbd.getNewTransaction();
         transaction.createPolicy(policyObject, API);
         transaction.commitTransaction();
     }