diff options
-rw-r--r-- | ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreationTest.java | 24 | ||||
-rw-r--r-- | POLICY-SDK-APP/pom.xml | 4 |
2 files changed, 26 insertions, 2 deletions
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreationTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreationTest.java index 0c029b433..c182b9bb5 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreationTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreationTest.java @@ -29,14 +29,23 @@ import static org.mockito.ArgumentMatchers.eq; import com.mockrunner.mock.web.MockHttpServletRequest; import java.util.ArrayList; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import org.hibernate.Criteria; +import org.hibernate.Session; +import org.hibernate.SessionFactory; import org.junit.Test; import org.mockito.Mockito; +import org.onap.policy.pap.xacml.rest.components.PolicyDbDao; +import org.onap.policy.pap.xacml.rest.components.PolicyDbDaoTransaction; import org.onap.policy.rest.adapter.PolicyRestAdapter; import org.onap.policy.rest.dao.CommonClassDao; +import org.onap.policy.rest.jpa.PolicyDbDaoEntity; import org.onap.policy.rest.jpa.PolicyVersion; +import org.powermock.reflect.Whitebox; import org.springframework.http.HttpStatus; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.mock.web.MockHttpServletResponse; @@ -92,6 +101,21 @@ public class PolicyCreationTest { .isInstanceOf(IllegalArgumentException.class); policyData.setConfigPolicyType("Base"); Mockito.when(policyData.getRuleData()).thenReturn(new LinkedHashMap<>()); + + SessionFactory mockSessionFactory = Mockito.mock(SessionFactory.class); + Session mockSession = Mockito.mock(Session.class); + Criteria mockCriteria = Mockito.mock(Criteria.class); + List<?> policyDbDaoEntityList = new LinkedList<>(); + + Mockito.when(mockSessionFactory.openSession()).thenReturn(mockSession); + Mockito.when(mockSession.createCriteria(PolicyDbDaoEntity.class)).thenReturn(mockCriteria); + Mockito.when(mockCriteria.list()).thenReturn(policyDbDaoEntityList); + Whitebox.setInternalState(PolicyDbDao.class, "sessionfactory", mockSessionFactory); + + PolicyDbDao mockPolicyDbDao = Mockito.mock(PolicyDbDao.class); + PolicyDbDaoTransaction mockTransaction = Mockito.mock(PolicyDbDaoTransaction.class); + Mockito.when(mockPolicyDbDao.getNewTransaction()).thenReturn(mockTransaction); + assertThatCode(() -> creation.savePolicy(policyData, response)).doesNotThrowAnyException(); policyData.setConfigPolicyType("ClosedLoop_PM"); assertThatThrownBy(() -> creation.savePolicy(policyData, response)) diff --git a/POLICY-SDK-APP/pom.xml b/POLICY-SDK-APP/pom.xml index 14179fafc..aa02984e4 100644 --- a/POLICY-SDK-APP/pom.xml +++ b/POLICY-SDK-APP/pom.xml @@ -274,12 +274,12 @@ <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> - <version>3.17</version> + <version>4.1.1</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> - <version>3.17</version> + <version>4.1.1</version> <exclusions> <exclusion> <groupId>org.apache.xmlbeans</groupId> |