summaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2023-02-02 14:46:18 +0000
committerliamfallon <liam.fallon@est.tech>2023-02-02 17:32:43 +0000
commit5a9b9d9513a021c00415f9bee0698ea9c497c238 (patch)
tree2bbe69e15c3fd5b37a7306b7f8918de78752973e /main/src/test
parent6763c4b787593fa0a11668971ba2cb5cc87ad4c5 (diff)
Replace Eclipselink with Hibernate
Issue-ID: POLICY-4533 Change-Id: I8ba51dce05f537778a92547bceff6eb6d6099144 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandlerTest.java46
1 files changed, 28 insertions, 18 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandlerTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandlerTest.java
index 5129bf5f..f3ba51ab 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandlerTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandlerTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,8 +24,17 @@ package org.onap.policy.pap.main.comm;
import static org.assertj.core.api.Assertions.assertThat;
import java.sql.SQLIntegrityConstraintViolationException;
-import org.eclipse.persistence.exceptions.EclipseLinkException;
+import org.hibernate.HibernateException;
import org.junit.Test;
+import org.onap.policy.pap.main.PolicyPapApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest(
+ classes = PolicyPapApplication.class,
+ webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
+ properties = {
+ "db.initialize=false"
+ })
public class PdpStatusMessageHandlerTest {
@@ -34,68 +44,68 @@ public class PdpStatusMessageHandlerTest {
// @formatter:off
// null exception
- assertThat(PdpStatusMessageHandler.isDuplicateKeyException(null)).isFalse();
+ assertThat(PdpStatusMessageHandler.isDuplicateKeyException(null, HibernateException.class)).isFalse();
// plain exception
assertThat(PdpStatusMessageHandler.isDuplicateKeyException(
- new Exception()))
+ new Exception(), HibernateException.class))
.isFalse();
// cause is also plain
assertThat(PdpStatusMessageHandler.isDuplicateKeyException(
new Exception(
- new Exception())))
+ new Exception()), HibernateException.class))
.isFalse();
// dup key
assertThat(PdpStatusMessageHandler.isDuplicateKeyException(
- new SQLIntegrityConstraintViolationException()))
+ new SQLIntegrityConstraintViolationException(), HibernateException.class))
.isTrue();
// cause is dup key
assertThat(PdpStatusMessageHandler.isDuplicateKeyException(
new Exception(
- new SQLIntegrityConstraintViolationException())))
+ new SQLIntegrityConstraintViolationException()), HibernateException.class))
.isTrue();
// eclipselink exception, no internal exception
assertThat(PdpStatusMessageHandler.isDuplicateKeyException(
- new MyEclipseLinkException()))
+ new MyHibernateException(), HibernateException.class))
.isFalse();
// eclipselink exception, cause is plain
assertThat(PdpStatusMessageHandler.isDuplicateKeyException(
- new MyEclipseLinkException(
- new Exception())))
+ new MyHibernateException(
+ new Exception()), HibernateException.class))
.isFalse();
// eclipselink exception, cause is dup
assertThat(PdpStatusMessageHandler.isDuplicateKeyException(
- new MyEclipseLinkException(
- new SQLIntegrityConstraintViolationException())))
+ new MyHibernateException(
+ new SQLIntegrityConstraintViolationException()), HibernateException.class))
.isTrue();
// multiple cause both inside and outside of the eclipselink exception
assertThat(PdpStatusMessageHandler.isDuplicateKeyException(
new Exception(
new Exception(
- new MyEclipseLinkException(
+ new MyHibernateException(
new Exception(
- new SQLIntegrityConstraintViolationException()))))))
+ new SQLIntegrityConstraintViolationException())))), HibernateException.class))
.isTrue();
// @formatter:on
}
- public static class MyEclipseLinkException extends EclipseLinkException {
+ public static class MyHibernateException extends HibernateException {
private static final long serialVersionUID = 1L;
- public MyEclipseLinkException() {
- // do nothing
+ public MyHibernateException() {
+ super("");
}
- public MyEclipseLinkException(Exception exception) {
- setInternalException(exception);
+ public MyHibernateException(Exception exception) {
+ super(exception);
}
}
}