summaryrefslogtreecommitdiffstats
path: root/models-pdp/src/test
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2023-02-02 14:43:12 +0000
committerliamfallon <liam.fallon@est.tech>2023-02-07 09:17:33 +0000
commite53df8d3f8ab0464b0876bdb339fa91dc9085cd2 (patch)
treee01029186ff980f7e00901c28aba09b80a85f8e8 /models-pdp/src/test
parente3938e43b8a1f02f74368ecb75c38530285feac0 (diff)
Replace Eclipselink with Hibernate
Issue-ID: POLICY-4533 Change-Id: I77a6c44c96013963e141265758629cae83e49876 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-pdp/src/test')
-rw-r--r--models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java34
-rw-r--r--models-pdp/src/test/resources/META-INF/persistence.xml28
2 files changed, 23 insertions, 39 deletions
diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java
index 2f12acbf5..80c906e5f 100644
--- a/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java
+++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2021 Nordix Foundation.
+ * Copyright (C) 2019-2021,2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -32,7 +32,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
-import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -81,7 +80,6 @@ public class PdpProviderTest {
private StandardCoder standardCoder;
private PdpPolicyStatusBuilder statusBuilder;
-
/**
* Set up the DAO towards the database.
*
@@ -95,15 +93,15 @@ public class PdpProviderTest {
daoParameters.setPersistenceUnit("ToscaConceptTest");
Properties jdbcProperties = new Properties();
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "policy");
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "P01icY");
+ jdbcProperties.setProperty("javax.persistence.jdbc.user", "policy");
+ jdbcProperties.setProperty("javax.persistence.jdbc.password", "P01icY");
if (System.getProperty("USE-MARIADB") != null) {
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.mariadb.jdbc.Driver");
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:mariadb://localhost:3306/policy");
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.mariadb.jdbc.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:mariadb://localhost:3306/policy");
} else {
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:PdpProviderTest");
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:PdpProviderTest");
}
daoParameters.setJdbcProperties(jdbcProperties);
@@ -128,7 +126,7 @@ public class PdpProviderTest {
ToscaConceptIdentifier policyType = new ToscaConceptIdentifier("MyPolicyType", "1.2.4");
statusBuilder = PdpPolicyStatus.builder().deploy(true).pdpType("MyPdpType").policy(MY_POLICY)
- .policyType(policyType).state(State.SUCCESS);
+ .policyType(policyType).state(State.SUCCESS);
}
@After
@@ -234,7 +232,7 @@ public class PdpProviderTest {
assertThatThrownBy(() -> {
new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups());
}).hasMessageContaining("PDP group").hasMessageContaining("pdpGroupState")
- .hasMessageContaining(Validated.IS_NULL);
+ .hasMessageContaining(Validated.IS_NULL);
}
@Test
@@ -300,7 +298,7 @@ public class PdpProviderTest {
assertThatThrownBy(() -> {
new PdpProvider().updatePdpGroups(pfDao, pdpGroups0.getGroups());
}).hasMessageContaining("PDP group").hasMessageContaining("pdpGroupState")
- .hasMessageContaining(Validated.IS_NULL);
+ .hasMessageContaining(Validated.IS_NULL);
}
@Test
@@ -407,7 +405,7 @@ public class PdpProviderTest {
assertThatThrownBy(() -> {
new PdpProvider().updatePdpSubGroup(pfDao, PDP_GROUP0, existingSubGroup);
}).hasMessageContaining("PDP sub group").hasMessageContaining("desiredInstanceCount")
- .hasMessageContaining("below the minimum value");
+ .hasMessageContaining("below the minimum value");
existingSubGroup.setDesiredInstanceCount(10);
}
@@ -498,9 +496,9 @@ public class PdpProviderTest {
List<PdpGroup> afterUpdatePdpGroups = new PdpProvider().getPdpGroups(pfDao, PDP_GROUP0);
assertEquals(PdpState.TEST,
- afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getPdpInstances().get(0).getPdpState());
+ afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getPdpInstances().get(0).getPdpState());
assertEquals(PdpHealthStatus.TEST_IN_PROGRESS,
- afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getPdpInstances().get(0).getHealthy());
+ afterUpdatePdpGroups.get(0).getPdpSubgroups().get(0).getPdpInstances().get(0).getHealthy());
existingPdp.setMessage("");
assertThatThrownBy(() -> {
@@ -693,12 +691,12 @@ public class PdpProviderTest {
}).hasMessageContaining("policy").hasMessageContaining("null");
assertThat(new PdpProvider().getAllPolicyStatus(pfDao, new ToscaConceptIdentifierOptVersion("somePdp", null)))
- .isEmpty();
+ .isEmpty();
PdpProvider provider = loadDeployments();
assertThat(provider.getAllPolicyStatus(pfDao, new ToscaConceptIdentifierOptVersion(MY_POLICY))).hasSize(2);
assertThat(provider.getAllPolicyStatus(pfDao, new ToscaConceptIdentifierOptVersion(MY_POLICY.getName(), null)))
- .hasSize(3);
+ .hasSize(3);
}
@Test
@@ -722,7 +720,7 @@ public class PdpProviderTest {
PdpProvider prov = new PdpProvider();
assertThatThrownBy(() -> prov.cudPolicyStatus(null, List.of(), List.of(), List.of()))
- .hasMessageMatching(DAO_IS_NULL);
+ .hasMessageMatching(DAO_IS_NULL);
// null collections should be OK
assertThatCode(() -> prov.cudPolicyStatus(pfDao, null, null, null)).doesNotThrowAnyException();
diff --git a/models-pdp/src/test/resources/META-INF/persistence.xml b/models-pdp/src/test/resources/META-INF/persistence.xml
index 7d4e5896b..e683bca9e 100644
--- a/models-pdp/src/test/resources/META-INF/persistence.xml
+++ b/models-pdp/src/test/resources/META-INF/persistence.xml
@@ -1,29 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
============LICENSE_START=======================================================
- Copyright (C) 2019, 2021 Nordix Foundation.
+ Copyright (C) 2019,2021,2023 Nordix Foundation.
Modifications Copyright (C) 2021 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.
See the License for the specific language governing permissions and
limitations under the License.
-
+
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="ToscaConceptTest" transaction-type="RESOURCE_LOCAL">
- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-
<class>org.onap.policy.models.dao.converters.CDataConditioner</class>
<class>org.onap.policy.models.dao.converters.Uuid2String</class>
<class>org.onap.policy.models.base.PfConceptKey</class>
@@ -38,21 +36,9 @@
<class>org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty</class>
<properties>
- <property name="eclipselink.target-database" value="MySQL" />
- <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
- <property name="eclipselink.ddl-generation.output-mode" value="database" />
- <property name="eclipselink.logging.level" value="INFO" />
-
- <!--property name="eclipselink.logging.level" value="ALL" />
- <property name="eclipselink.logging.level.jpa" value="ALL" />
- <property name="eclipselink.logging.level.ddl" value="ALL" />
- <property name="eclipselink.logging.level.connection" value="ALL" />
- <property name="eclipselink.logging.level.sql" value="ALL" />
- <property name="eclipselink.logging.level.transaction" value="ALL" />
- <property name="eclipselink.logging.level.sequencing" value="ALL" />
- <property name="eclipselink.logging.level.server" value="ALL" />
- <property name="eclipselink.logging.level.query" value="ALL" />
- <property name="eclipselink.logging.level.properties" value="ALL" /-->
+ <property name="javax.persistence.schema-generation.database.action" value="drop-and-create" />
+ <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
+ <property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>