aboutsummaryrefslogtreecommitdiffstats
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
parente3938e43b8a1f02f74368ecb75c38530285feac0 (diff)
Replace Eclipselink with Hibernate
Issue-ID: POLICY-4533 Change-Id: I77a6c44c96013963e141265758629cae83e49876 Signed-off-by: liamfallon <liam.fallon@est.tech>
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java40
-rw-r--r--models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java19
-rw-r--r--models-dao/src/test/resources/META-INF/persistence.xml22
-rw-r--r--models-interactions/model-impl/aai/pom.xml4
-rw-r--r--models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java104
-rw-r--r--models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/XmlElementFieldNamingStrategy.java38
-rw-r--r--models-interactions/model-impl/guard/src/main/java/org/onap/policy/guard/OperationsHistory.java12
-rw-r--r--models-pap/src/main/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAudit.java4
-rw-r--r--models-pap/src/test/resources/META-INF/persistence.xml22
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java20
-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
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/ModelsProvider.java18
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java14
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java4
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java6
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java38
-rw-r--r--models-provider/src/test/resources/META-INF/persistence.xml22
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java9
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java9
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java15
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java9
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java43
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java16
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithTypeAndStringProperties.java9
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java51
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java17
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java17
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java17
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java233
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java29
-rw-r--r--models-tosca/src/test/resources/META-INF/persistence.xml22
-rw-r--r--pom.xml11
33 files changed, 492 insertions, 464 deletions
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
index 22c5c5397..13a4eea5a 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.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.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
@@ -113,16 +113,16 @@ public class DefaultPfDao implements PfDao {
if (daoParameters == null || daoParameters.getPersistenceUnit() == null) {
LOGGER.error("Policy Framework persistence unit parameter not set");
throw new PfModelException(Response.Status.INTERNAL_SERVER_ERROR,
- "Policy Framework persistence unit parameter not set");
+ "Policy Framework persistence unit parameter not set");
}
LOGGER.debug("Creating Policy Framework persistence unit \"{}\" . . .", daoParameters.getPersistenceUnit());
try {
emf = Persistence.createEntityManagerFactory(daoParameters.getPersistenceUnit(),
- daoParameters.getJdbcProperties());
+ daoParameters.getJdbcProperties());
} catch (final Exception ex) {
String errorMessage = "Creation of Policy Framework persistence unit \""
- + daoParameters.getPersistenceUnit() + "\" failed";
+ + daoParameters.getPersistenceUnit() + "\" failed";
LOGGER.warn(errorMessage);
throw new PfModelException(Response.Status.INTERNAL_SERVER_ERROR, errorMessage, ex);
}
@@ -138,7 +138,7 @@ public class DefaultPfDao implements PfDao {
if (emf == null) {
LOGGER.warn("Policy Framework DAO has not been initialized");
throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
- "Policy Framework DAO has not been initialized");
+ "Policy Framework DAO has not been initialized");
}
return emf.createEntityManager();
@@ -190,7 +190,7 @@ public class DefaultPfDao implements PfDao {
try {
// @formatter:off
mg.getTransaction().begin();
- mg.createQuery(setQueryTable(DELETE_BY_CONCEPT_KEY, someClass), someClass)
+ mg.createQuery(setQueryTable(DELETE_BY_CONCEPT_KEY, someClass))
.setParameter(NAME, key.getName())
.setParameter(VERSION, key.getVersion())
.executeUpdate();
@@ -210,7 +210,7 @@ public class DefaultPfDao implements PfDao {
try {
// @formatter:off
mg.getTransaction().begin();
- mg.createQuery(setQueryTable(DELETE_BY_REFERENCE_KEY, someClass), someClass)
+ mg.createQuery(setQueryTable(DELETE_BY_REFERENCE_KEY, someClass))
.setParameter(PARENT_NAME, key.getParentKeyName())
.setParameter(PARENT_VERSION, key.getParentKeyVersion())
.setParameter(LOCAL_NAME, key.getLocalName())
@@ -231,7 +231,7 @@ public class DefaultPfDao implements PfDao {
try {
// @formatter:off
mg.getTransaction().begin();
- mg.createQuery(setQueryTable(DELETE_BY_TIMESTAMP_KEY, someClass), someClass)
+ mg.createQuery(setQueryTable(DELETE_BY_TIMESTAMP_KEY, someClass))
.setParameter(NAME, key.getName())
.setParameter(VERSION, key.getVersion())
.setParameter(TIMESTAMP, key.getTimeStamp())
@@ -288,7 +288,7 @@ public class DefaultPfDao implements PfDao {
// @formatter:off
mg.getTransaction().begin();
for (final PfConceptKey key : keys) {
- deletedCount += mg.createQuery(setQueryTable(DELETE_BY_CONCEPT_KEY, someClass), someClass)
+ deletedCount += mg.createQuery(setQueryTable(DELETE_BY_CONCEPT_KEY, someClass))
.setParameter(NAME, key.getName())
.setParameter(VERSION, key.getVersion())
.executeUpdate();
@@ -303,7 +303,7 @@ public class DefaultPfDao implements PfDao {
@Override
public <T extends PfConcept> int deleteByReferenceKey(final Class<T> someClass,
- final Collection<PfReferenceKey> keys) {
+ final Collection<PfReferenceKey> keys) {
if (keys == null || keys.isEmpty()) {
return 0;
}
@@ -313,7 +313,7 @@ public class DefaultPfDao implements PfDao {
// @formatter:off
mg.getTransaction().begin();
for (final PfReferenceKey key : keys) {
- deletedCount += mg.createQuery(setQueryTable(DELETE_BY_REFERENCE_KEY, someClass), someClass)
+ deletedCount += mg.createQuery(setQueryTable(DELETE_BY_REFERENCE_KEY, someClass))
.setParameter(PARENT_NAME, key.getParentKeyName())
.setParameter(PARENT_VERSION, key.getParentKeyVersion())
.setParameter(LOCAL_NAME, key.getLocalName())
@@ -332,7 +332,7 @@ public class DefaultPfDao implements PfDao {
final var mg = getEntityManager();
try {
mg.getTransaction().begin();
- mg.createQuery(setQueryTable(DELETE_FROM_TABLE, someClass), someClass).executeUpdate();
+ mg.createQuery(setQueryTable(DELETE_FROM_TABLE, someClass)).executeUpdate();
mg.getTransaction().commit();
} finally {
mg.close();
@@ -341,7 +341,7 @@ public class DefaultPfDao implements PfDao {
@Override
public <T extends PfConcept> List<T> getFiltered(final Class<T> someClass, final String name,
- final String version) {
+ final String version) {
if (name == null) {
return getAll(someClass);
}
@@ -362,8 +362,8 @@ public class DefaultPfDao implements PfDao {
try {
PfFilter filter = new PfFilterFactory().createFilter(someClass);
var filterQueryString = SELECT_FROM_TABLE
- + filter.genWhereClause(filterParams)
- + filter.genOrderClause(filterParams);
+ + filter.genWhereClause(filterParams)
+ + filter.genOrderClause(filterParams);
TypedQuery<T> query = mg.createQuery(setQueryTable(filterQueryString, someClass), someClass);
filter.setParams(query, filterParams);
@@ -457,7 +457,7 @@ public class DefaultPfDao implements PfDao {
}
return mg.createQuery(query, someClass).setMaxResults(numRecords)
- .getResultList();
+ .getResultList();
} finally {
mg.close();
}
@@ -567,8 +567,8 @@ public class DefaultPfDao implements PfDao {
* The invoking code only passes well-known classes into this method, thus
* disabling the sonar about SQL injection.
*/
- size = mg.createQuery("SELECT COUNT(c) FROM " + someClass.getSimpleName() + " c", Long.class) // NOSONAR
- .getSingleResult();
+ size = mg.createQuery("SELECT COUNT(c) FROM " + someClass.getSimpleName() + " c", Long.class) // NOSONAR
+ .getSingleResult();
} finally {
mg.close();
}
@@ -595,13 +595,13 @@ public class DefaultPfDao implements PfDao {
* @return the single unique result
*/
private <T extends PfConcept> T getSingleResult(final Class<T> someClass, final String searchFilter,
- List<T> resultList) {
+ List<T> resultList) {
if (resultList == null || resultList.isEmpty()) {
return null;
}
if (resultList.size() > 1) {
throw new IllegalArgumentException("More than one result was returned query on " + someClass
- + " with filter " + searchFilter + ": " + resultList);
+ + " with filter " + searchFilter + ": " + resultList);
}
return resultList.get(0);
}
diff --git a/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java b/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java
index 65d22863f..e5f40ebf4 100644
--- a/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java
+++ b/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.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.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
@@ -38,7 +38,6 @@ import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
-import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Test;
import org.onap.policy.models.base.PfConceptKey;
@@ -85,10 +84,10 @@ public class EntityTest {
Properties jdbcProperties = new Properties();
// @formatter:off
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:EntityTest");
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, "sa");
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, "");
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:EntityTest");
+ jdbcProperties.setProperty("javax.persistence.jdbc.user", "sa");
+ jdbcProperties.setProperty("javax.persistence.jdbc.password", "");
// @formatter:on
daoParameters.setJdbcProperties(jdbcProperties);
@@ -145,6 +144,14 @@ public class EntityTest {
daoParameters.setPluginClass(DefaultPfDao.class.getName());
daoParameters.setPersistenceUnit("DaoTest");
+ Properties jdbcProperties = new Properties();
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:EntityTest");
+ jdbcProperties.setProperty("javax.persistence.jdbc.user", "sa");
+ jdbcProperties.setProperty("javax.persistence.jdbc.password", "");
+
+ daoParameters.setJdbcProperties(jdbcProperties);
+
pfDao = new PfDaoFactory().createPfDao(daoParameters);
pfDao.init(daoParameters);
diff --git a/models-dao/src/test/resources/META-INF/persistence.xml b/models-dao/src/test/resources/META-INF/persistence.xml
index d324ae0a6..5148f059a 100644
--- a/models-dao/src/test/resources/META-INF/persistence.xml
+++ b/models-dao/src/test/resources/META-INF/persistence.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
============LICENSE_START=======================================================
- Copyright (C) 2019-2021 Nordix Foundation.
+ Copyright (C) 2019-2021,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.
@@ -21,8 +21,6 @@
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="DaoTest" 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>
@@ -33,21 +31,9 @@
<class>org.onap.policy.models.dao.DummyReferenceTimestampEntity</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>
diff --git a/models-interactions/model-impl/aai/pom.xml b/models-interactions/model-impl/aai/pom.xml
index de82e9bf2..5f401295f 100644
--- a/models-interactions/model-impl/aai/pom.xml
+++ b/models-interactions/model-impl/aai/pom.xml
@@ -44,10 +44,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java
index d638c9d3d..7a6eb6859 100644
--- a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java
+++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiCqResponse.java
@@ -3,6 +3,7 @@
*
* ================================================================================
* Copyright (C) 2019-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.
@@ -20,19 +21,13 @@
package org.onap.policy.aai;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
-import java.io.StringReader;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.transform.stream.StreamSource;
-import org.eclipse.persistence.jaxb.JAXBContextFactory;
-import org.eclipse.persistence.jaxb.JAXBContextProperties;
import org.json.JSONArray;
import org.json.JSONObject;
import org.onap.aai.domain.yang.CloudRegion;
@@ -44,8 +39,6 @@ import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.Vserver;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class AaiCqResponse implements Serializable {
private static final long serialVersionUID = 1L;
@@ -53,46 +46,21 @@ public class AaiCqResponse implements Serializable {
public static final String OPERATION = "CustomQuery";
private static final String GENERIC_VNF = "generic-vnf";
private static final String VF_MODULE = "vf-module";
- private static final Logger LOGGER = LoggerFactory.getLogger(AaiCqResponse.class);
- private static JAXBContext jaxbContext;
-
- // JABX initial stuff
- static {
- Map<String, Object> properties = new HashMap<>();
- properties.put(JAXBContextProperties.MEDIA_TYPE, "application/json");
- properties.put(JAXBContextProperties.JSON_INCLUDE_ROOT, false);
- // Define JAXB context
- try {
- // @formatter:off
- jaxbContext = JAXBContextFactory.createContext(new Class[] {
- Vserver.class,
- GenericVnf.class,
- VfModule.class,
- CloudRegion.class,
- ServiceInstance.class,
- Tenant.class,
- ModelVer.class
- }, properties);
- // @formatter:on
-
- // verify that we can create an unmarshaller
- jaxbContext.createUnmarshaller();
-
- } catch (JAXBException e) {
- LOGGER.error("Could not initialize JAXBContext", e);
- LOGGER.info("Problem initiatlizing JAXBContext", e);
- }
- }
@SerializedName("results")
private List<Serializable> inventoryResponseItems = new LinkedList<>();
+ private final Gson gson;
+
/**
* Constructor creates a custom query response from a valid json string.
*
* @param jsonString A&AI Custom Query response JSON string
*/
public AaiCqResponse(String jsonString) {
+ gson = new GsonBuilder()
+ .setFieldNamingStrategy(new XmlElementFieldNamingStrategy())
+ .create();
// Read JSON String and add all AaiObjects
var responseObj = new JSONObject(jsonString);
@@ -118,11 +86,10 @@ public class AaiCqResponse implements Serializable {
// Create the StreamSource by creating StringReader using the
// JSON input
- var json = new StreamSource(
- new StringReader(resultObject.getJSONObject("vserver").toString()));
+ var json = resultObject.getJSONObject("vserver").toString();
// Getting the vserver pojo again from the json
- var vserver = this.getAaiObject(json, Vserver.class);
+ var vserver = gson.fromJson(json, Vserver.class);
this.inventoryResponseItems.add(vserver);
}
}
@@ -131,12 +98,10 @@ public class AaiCqResponse implements Serializable {
if (resultObject.has(GENERIC_VNF)) {
// Create the StreamSource by creating StringReader using the
// JSON input
- var json = new StreamSource(
- new StringReader(resultObject.getJSONObject(GENERIC_VNF).toString()));
+ var json = resultObject.getJSONObject(GENERIC_VNF).toString();
// Getting the generic vnf pojo again from the json
- var genericVnf = this.getAaiObject(json, GenericVnf.class);
-
+ var genericVnf = gson.fromJson(json, GenericVnf.class);
this.inventoryResponseItems.add(genericVnf);
}
}
@@ -146,12 +111,10 @@ public class AaiCqResponse implements Serializable {
// Create the StreamSource by creating StringReader using the
// JSON input
- var json = new StreamSource(
- new StringReader(resultObject.getJSONObject("service-instance").toString()));
+ var json = resultObject.getJSONObject("service-instance").toString();
// Getting the employee pojo again from the json
- var serviceInstance = this.getAaiObject(json, ServiceInstance.class);
-
+ var serviceInstance = gson.fromJson(json, ServiceInstance.class);
this.inventoryResponseItems.add(serviceInstance);
}
}
@@ -160,12 +123,10 @@ public class AaiCqResponse implements Serializable {
if (resultObject.has(VF_MODULE)) {
// Create the StreamSource by creating StringReader using the
// JSON input
- var json = new StreamSource(
- new StringReader(resultObject.getJSONObject(VF_MODULE).toString()));
+ var json = resultObject.getJSONObject(VF_MODULE).toString();
// Getting the vf module pojo again from the json
- var vfModule = this.getAaiObject(json, VfModule.class);
-
+ var vfModule = gson.fromJson(json, VfModule.class);
this.inventoryResponseItems.add(vfModule);
}
}
@@ -174,12 +135,10 @@ public class AaiCqResponse implements Serializable {
if (resultObject.has("cloud-region")) {
// Create the StreamSource by creating StringReader using the
// JSON input
- var json = new StreamSource(
- new StringReader(resultObject.getJSONObject("cloud-region").toString()));
+ var json = resultObject.getJSONObject("cloud-region").toString();
// Getting the cloud region pojo again from the json
- var cloudRegion = this.getAaiObject(json, CloudRegion.class);
-
+ var cloudRegion = gson.fromJson(json, CloudRegion.class);
this.inventoryResponseItems.add(cloudRegion);
}
}
@@ -188,12 +147,10 @@ public class AaiCqResponse implements Serializable {
if (resultObject.has("tenant")) {
// Create the StreamSource by creating StringReader using the
// JSON input
- var json = new StreamSource(
- new StringReader(resultObject.getJSONObject("tenant").toString()));
+ var json = resultObject.getJSONObject("tenant").toString();
// Getting the tenant pojo again from the json
- var tenant = this.getAaiObject(json, Tenant.class);
-
+ var tenant = gson.fromJson(json, Tenant.class);
this.inventoryResponseItems.add(tenant);
}
}
@@ -202,25 +159,14 @@ public class AaiCqResponse implements Serializable {
if (resultObject.has("model-ver")) {
// Create the StreamSource by creating StringReader using the
// JSON input
- var json = new StreamSource(
- new StringReader(resultObject.getJSONObject("model-ver").toString()));
+ var json = resultObject.getJSONObject("model-ver").toString();
// Getting the ModelVer pojo again from the json
- var modelVer = this.getAaiObject(json, ModelVer.class);
-
+ var modelVer = gson.fromJson(json, ModelVer.class);
this.inventoryResponseItems.add(modelVer);
}
}
- private <T> T getAaiObject(StreamSource json, final Class<T> classOfResponse) {
- try {
- return jaxbContext.createUnmarshaller().unmarshal(json, classOfResponse).getValue();
- } catch (JAXBException e) {
- LOGGER.error("JAXBCOntext error", e);
- return null;
- }
- }
-
public List<Serializable> getInventoryResponseItems() {
return inventoryResponseItems;
}
@@ -374,7 +320,7 @@ public class AaiCqResponse implements Serializable {
// Iterate through all the vfModules of that generic Vnf
for (VfModule vfMod : genVnf.getVfModules().getVfModule()) {
if (vfMod.getModelInvariantId() != null
- && vfMod.getModelInvariantId().equals(vfModuleModelInvariantId)) {
+ && vfMod.getModelInvariantId().equals(vfModuleModelInvariantId)) {
return genVnf;
}
}
@@ -608,12 +554,12 @@ public class AaiCqResponse implements Serializable {
var count = 0;
for (VfModule vfModule : vfModuleList) {
if (vfModule.getModelCustomizationId() == null || vfModule.getModelInvariantId() == null
- || vfModule.getModelVersionId() == null) {
+ || vfModule.getModelVersionId() == null) {
continue;
}
if (vfModule.getModelCustomizationId().equals(custId) && vfModule.getModelInvariantId().equals(invId)
- && vfModule.getModelVersionId().equals(verId)) {
+ && vfModule.getModelVersionId().equals(verId)) {
count = count + 1;
}
}
diff --git a/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/XmlElementFieldNamingStrategy.java b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/XmlElementFieldNamingStrategy.java
new file mode 100644
index 000000000..fa1236283
--- /dev/null
+++ b/models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/XmlElementFieldNamingStrategy.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * 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.
+ * 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=========================================================
+ */
+
+package org.onap.policy.aai;
+
+import com.google.gson.FieldNamingStrategy;
+import java.lang.reflect.Field;
+import javax.xml.bind.annotation.XmlElement;
+
+public class XmlElementFieldNamingStrategy implements FieldNamingStrategy {
+ @Override
+ public String translateName(Field field) {
+ XmlElement annotatedFieldName = field.getAnnotation(XmlElement.class);
+
+ if (annotatedFieldName != null) {
+ return annotatedFieldName.name();
+ } else {
+ return field.getName();
+ }
+ }
+} \ No newline at end of file
diff --git a/models-interactions/model-impl/guard/src/main/java/org/onap/policy/guard/OperationsHistory.java b/models-interactions/model-impl/guard/src/main/java/org/onap/policy/guard/OperationsHistory.java
index 2ec1f342e..aee57f142 100644
--- a/models-interactions/model-impl/guard/src/main/java/org/onap/policy/guard/OperationsHistory.java
+++ b/models-interactions/model-impl/guard/src/main/java/org/onap/policy/guard/OperationsHistory.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021,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.
@@ -28,9 +28,11 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
+import javax.persistence.TableGenerator;
import lombok.Data;
@Entity
@@ -44,7 +46,13 @@ public class OperationsHistory implements Serializable {
private static final long serialVersionUID = -551420180714993577L;
@Id
- @GeneratedValue
+ @GeneratedValue(strategy = GenerationType.TABLE, generator = "opHistoryIdGen")
+ @TableGenerator(
+ name = "opHistoryIdGen",
+ table = "ophistory_id_sequence",
+ pkColumnName = "SEQ_NAME",
+ valueColumnName = "SEQ_COUNT",
+ pkColumnValue = "SEQ_GEN")
@Column(name = "id")
private Long id;
diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAudit.java b/models-pap/src/main/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAudit.java
index e2f8972de..4b7fde43b 100644
--- a/models-pap/src/main/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAudit.java
+++ b/models-pap/src/main/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAudit.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021,2023 Nordix Foundation.
* Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -77,7 +77,7 @@ public class JpaPolicyAudit extends PfConcept implements PfAuthorative<PolicyAud
@GeneratedValue(strategy = GenerationType.TABLE, generator = "auditIdGen")
@TableGenerator(
name = "auditIdGen",
- table = "sequence",
+ table = "audit_sequence",
pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT",
pkColumnValue = "SEQ_GEN")
diff --git a/models-pap/src/test/resources/META-INF/persistence.xml b/models-pap/src/test/resources/META-INF/persistence.xml
index fcab08f3e..a009e6340 100644
--- a/models-pap/src/test/resources/META-INF/persistence.xml
+++ b/models-pap/src/test/resources/META-INF/persistence.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
============LICENSE_START=======================================================
- Copyright (C) 2021 Nordix Foundation.
+ Copyright (C) 2021,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.
@@ -21,26 +21,12 @@
<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.pap.persistence.concepts.JpaPolicyAudit</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>
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java
index 7eb4e7c39..57a8ec97e 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpStatistics.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Model
* ================================================================================
- * Copyright (C) 2019-2021 Nordix Foundation.
+ * Copyright (C) 2019-2021,2023 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
@@ -35,6 +35,7 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
+import javax.persistence.Index;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
@@ -46,7 +47,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.apache.commons.lang3.builder.CompareToBuilder;
-import org.eclipse.persistence.annotations.Index;
import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.parameters.annotations.Pattern;
@@ -64,10 +64,16 @@ import org.onap.policy.models.pdp.concepts.PdpStatistics;
*
*/
@Entity
-@Table(name = "PdpStatistics")
-@Index(name = "IDXTSIDX1", columnNames = {
- "timeStamp", "name", "version"
-})
+@Table(
+ name = "PdpStatistics",
+ indexes = {
+ @Index(
+ name = "IDXTSIDX1",
+ columnList = "timeStamp,name,version",
+ unique = true
+ )
+ }
+)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Data
@AllArgsConstructor
@@ -80,7 +86,7 @@ public class JpaPdpStatistics extends PfConcept implements PfAuthorative<PdpStat
@GeneratedValue(strategy = GenerationType.TABLE, generator = "statisticsIdGen")
@TableGenerator(
name = "statisticsIdGen",
- table = "sequence",
+ table = "statistics_sequence",
pkColumnName = "SEQ_NAME",
valueColumnName = "SEQ_COUNT",
pkColumnValue = "SEQ_GEN")
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>
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/ModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/ModelsProvider.java
index 36c762e01..d90847f56 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/ModelsProvider.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/ModelsProvider.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021,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.
@@ -24,7 +24,6 @@ import java.util.Properties;
import javax.ws.rs.core.Response;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.dao.DaoParameters;
import org.onap.policy.models.dao.PfDao;
@@ -48,13 +47,14 @@ public final class ModelsProvider {
// @formatter:off
var jdbcProperties = new Properties();
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, parameters.getDatabaseDriver());
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, parameters.getDatabaseUrl());
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_USER, parameters.getDatabaseUser());
- jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_PASSWORD, parameters.getDatabasePassword());
- jdbcProperties.setProperty(PersistenceUnitProperties.TARGET_DATABASE,
- (parameters.getDatabaseType() == null ? "MySQL" : parameters.getDatabaseType()));
- // @formatter:on
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", parameters.getDatabaseDriver());
+ jdbcProperties.setProperty("javax.persistence.jdbc.url", parameters.getDatabaseUrl());
+ jdbcProperties.setProperty("javax.persistence.jdbc.user", parameters.getDatabaseUser());
+ jdbcProperties.setProperty("javax.persistence.jdbc.password", parameters.getDatabasePassword());
+ jdbcProperties.setProperty("hibernate.dialect",
+ (parameters.getDatabaseType() == null
+ ? "org.hibernate.dialect.MariaDBDialect"
+ : parameters.getDatabaseType())); // @formatter:on
daoParameters.setJdbcProperties(jdbcProperties);
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
index ff3dae81a..6cf56cb96 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2022 Nordix Foundation.
+ * Copyright (C) 2019-2023 Nordix Foundation.
* Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020, 2022 Bell Canada. All rights reserved.
* ================================================================================
@@ -90,6 +90,7 @@ public class DatabasePolicyModelsProviderTest {
parameters.setDatabaseUser("policy");
parameters.setDatabasePassword("P01icY");
parameters.setPersistenceUnit("ToscaConceptTest");
+ parameters.setDatabaseType("org.hibernate.dialect.H2Dialect");
}
/**
@@ -110,20 +111,23 @@ public class DatabasePolicyModelsProviderTest {
databaseProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+ final String savedDatabaseUrl = parameters.getDatabaseUrl();
parameters.setDatabaseUrl("jdbc://www.acmecorp.nonexist");
databaseProvider.close();
- databaseProvider.init();
+ assertThatThrownBy(() -> {
+ databaseProvider.init();
+ }).hasMessageContaining("could not create Data Access Object (DAO)");
databaseProvider.close();
- parameters.setDatabaseUrl("jdbc:h2:mem:DatabasePolicyModelsProviderTest");
+ parameters.setDatabaseUrl(savedDatabaseUrl);
+ final String savedPersistenceUnit = parameters.getPersistenceUnit();
parameters.setPersistenceUnit("WileECoyote");
assertThatThrownBy(databaseProvider::init).hasMessageContaining("could not create Data Access Object (DAO)");
-
- parameters.setPersistenceUnit("ToscaConceptTest");
+ parameters.setPersistenceUnit(savedPersistenceUnit);
databaseProvider.init();
databaseProvider.close();
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java
index c39eeb392..1f9931678 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyToscaPersistenceTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2021 Nordix Foundation.
+ * Copyright (C) 2019-2021,2023 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -81,9 +81,11 @@ public class PolicyToscaPersistenceTest {
if (System.getProperty("USE-MARIADB") != null) {
parameters.setDatabaseDriver("org.mariadb.jdbc.Driver");
parameters.setDatabaseUrl("jdbc:mariadb://localhost:3306/policy");
+ parameters.setDatabaseType("org.hibernate.dialect.MariaDBDialect");
} else {
parameters.setDatabaseDriver("org.h2.Driver");
parameters.setDatabaseUrl("jdbc:h2:mem:PolicyToscaPersistenceTest");
+ parameters.setDatabaseType("org.hibernate.dialect.H2Dialect");
}
parameters.setDatabaseUser("policy");
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
index 786563a78..978a30346 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyTypePersistenceTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2021 Nordix Foundation.
+ * Copyright (C) 2019-2021,2023 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -66,9 +66,11 @@ public class PolicyTypePersistenceTest {
if (System.getProperty("USE-MARIADB") != null) {
parameters.setDatabaseDriver("org.mariadb.jdbc.Driver");
parameters.setDatabaseUrl("jdbc:mariadb://localhost:3306/policy");
+ parameters.setDatabaseType("org.hibernate.dialect.MariaDBDialect");
} else {
parameters.setDatabaseDriver("org.h2.Driver");
- parameters.setDatabaseUrl("jdbc:h2:mem:PolicyTypePersistenceTest");
+ parameters.setDatabaseUrl("jdbc:h2:mem:PolicyToscaPersistenceTest");
+ parameters.setDatabaseType("org.hibernate.dialect.H2Dialect");
}
parameters.setDatabaseUser("policy");
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
index c55325e57..2d2723f0f 100644
--- a/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2021 Nordix Foundation.
+ * Copyright (C) 2020-2021,2023 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -55,6 +55,7 @@ public class HierarchyFetchTest {
parameters.setDatabaseUser("policy");
parameters.setDatabasePassword("P01icY");
parameters.setPersistenceUnit("ToscaConceptTest");
+ parameters.setDatabaseType("org.hibernate.dialect.H2Dialect");
}
/**
@@ -95,29 +96,28 @@ public class HierarchyFetchTest {
assertEquals(1, fetchedServiceTemplate.getPolicyTypes().size());
ToscaPolicyType fetchedPolicyType = fetchedServiceTemplate.getPolicyTypes().values().iterator().next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0",
- "3.0.0", fetchedServiceTemplate, 3);
-
+ "3.0.0", fetchedServiceTemplate, 3);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0", "1.0.0");
assertOldDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(1, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyType = fetchedServiceTemplate.getPolicyTypes().values().iterator().next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0",
- "1.0.0", fetchedServiceTemplate, 1);
+ "1.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0", "1.1.0");
assertOldDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(1, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyType = fetchedServiceTemplate.getPolicyTypes().values().iterator().next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0",
- "2.0.0", fetchedServiceTemplate, 1);
+ "2.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0", "1.2.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
assertEquals(1, fetchedServiceTemplate.getPolicyTypes().size());
fetchedPolicyType = fetchedServiceTemplate.getPolicyTypes().values().iterator().next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0",
- "3.0.0", fetchedServiceTemplate, 1);
+ "3.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1", null);
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -128,7 +128,7 @@ public class HierarchyFetchTest {
checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1",
- "3.0.0", fetchedServiceTemplate, 3);
+ "3.0.0", fetchedServiceTemplate, 3);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1", "1.0.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -138,7 +138,7 @@ public class HierarchyFetchTest {
checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1",
- "1.0.0", fetchedServiceTemplate, 1);
+ "1.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1", "1.1.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -148,7 +148,7 @@ public class HierarchyFetchTest {
checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1",
- "2.0.0", fetchedServiceTemplate, 1);
+ "2.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1", "1.2.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -158,7 +158,7 @@ public class HierarchyFetchTest {
checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1",
- "3.0.0", fetchedServiceTemplate, 1);
+ "3.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2", null);
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -170,7 +170,7 @@ public class HierarchyFetchTest {
checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2",
- "3.0.0", fetchedServiceTemplate, 3);
+ "3.0.0", fetchedServiceTemplate, 3);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2", "1.0.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -182,7 +182,7 @@ public class HierarchyFetchTest {
checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2",
- "1.0.0", fetchedServiceTemplate, 1);
+ "1.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2", "1.1.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -194,7 +194,7 @@ public class HierarchyFetchTest {
checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2",
- "2.0.0", fetchedServiceTemplate, 1);
+ "2.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2", "1.2.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -206,7 +206,7 @@ public class HierarchyFetchTest {
checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2",
- "3.0.0", fetchedServiceTemplate, 1);
+ "3.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2.3", null);
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -220,7 +220,7 @@ public class HierarchyFetchTest {
checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2.3",
- "3.0.0", fetchedServiceTemplate, 3);
+ "3.0.0", fetchedServiceTemplate, 3);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2.3", "1.0.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -234,7 +234,7 @@ public class HierarchyFetchTest {
checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2.3",
- "1.0.0", fetchedServiceTemplate, 1);
+ "1.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2.3", "1.1.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -248,7 +248,7 @@ public class HierarchyFetchTest {
checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2.3",
- "2.0.0", fetchedServiceTemplate, 1);
+ "2.0.0", fetchedServiceTemplate, 1);
fetchedServiceTemplate = databaseProvider.getPolicies("onap.policies.PolicyLevel0.1.2.3", "1.2.0");
assertLatestDataTypesAreReturned(fetchedServiceTemplate);
@@ -262,7 +262,7 @@ public class HierarchyFetchTest {
checkNameVersion(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2", "3.0.0");
fetchedPolicyType = fetchedPolicyTypeIterator.next();
checkEqualsPolicyType(fetchedPolicyType, "onap.policies.PolicyTypeLevel0.1.2.3",
- "3.0.0", fetchedServiceTemplate, 1);
+ "3.0.0", fetchedServiceTemplate, 1);
databaseProvider.close();
}
@@ -273,7 +273,7 @@ public class HierarchyFetchTest {
}
private void checkEqualsPolicyType(ToscaPolicyType fetchedPolicyType, String name, String ver,
- ToscaServiceTemplate fetchedServiceTemplate, int policies) {
+ ToscaServiceTemplate fetchedServiceTemplate, int policies) {
checkNameVersion(fetchedPolicyType, name, ver);
assertEquals(policies, countReturnedPolicies(fetchedServiceTemplate));
}
diff --git a/models-provider/src/test/resources/META-INF/persistence.xml b/models-provider/src/test/resources/META-INF/persistence.xml
index 3b4d95656..8247f0850 100644
--- a/models-provider/src/test/resources/META-INF/persistence.xml
+++ b/models-provider/src/test/resources/META-INF/persistence.xml
@@ -1,7 +1,7 @@
<?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");
@@ -22,8 +22,6 @@
<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.base.PfConceptKey</class>
<class>org.onap.policy.models.dao.converters.CDataConditioner</class>
<class>org.onap.policy.models.dao.converters.Uuid2String</class>
@@ -58,21 +56,9 @@
<class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</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.enable_lazy_load_no_trans" value="true" />
+ <property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
</persistence>
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java
index 14c8ca4a3..b9acde26c 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020,2022 Nordix Foundation.
+ * Copyright (C) 2019-2020,2022-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");
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId;
@@ -67,8 +68,10 @@ public class JpaToscaEntityType<T extends ToscaEntity> extends PfConcept impleme
// @formatter:off
@Column
- @AttributeOverride(name = "name", column = @Column(name = "derived_from_name"))
- @AttributeOverride(name = "version", column = @Column(name = "derived_from_version"))
+ @AttributeOverrides({
+ @AttributeOverride(name = "name", column = @Column(name = "derived_from_name")),
+ @AttributeOverride(name = "version", column = @Column(name = "derived_from_version"))
+ })
@VerifyKey
private PfConceptKey derivedFrom;
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java
index 09c406ea6..5f72e2ba8 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2020,2023 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
@@ -29,6 +29,7 @@ import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import lombok.Data;
@@ -57,8 +58,10 @@ public class JpaToscaModel extends PfModel {
private static final long serialVersionUID = 8800599637708309945L;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumn(name = "serviceTemplatesName", referencedColumnName = "name")
- @JoinColumn(name = "serviceTemplatesVersion", referencedColumnName = "version")
+ @JoinColumns({
+ @JoinColumn(name = "serviceTemplatesName", referencedColumnName = "name"),
+ @JoinColumn(name = "serviceTemplatesVersion", referencedColumnName = "version")
+ })
@Valid
private JpaToscaServiceTemplates serviceTemplates;
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java
index bd1dfd4d5..0a5f0c688 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2021 Nordix Foundation.
+ * Copyright (C) 2020-2021,2023 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,6 +31,7 @@ import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.ws.rs.core.Response;
@@ -63,14 +64,18 @@ public class JpaToscaNodeTemplate extends JpaToscaWithTypeAndStringProperties<To
// formatter:off
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumn(name = "requirementsName", referencedColumnName = "name")
- @JoinColumn(name = "requirementsVersion", referencedColumnName = "version")
+ @JoinColumns({
+ @JoinColumn(name = "requirementsName", referencedColumnName = "name"),
+ @JoinColumn(name = "requirementsVersion", referencedColumnName = "version")
+ })
@Valid
private JpaToscaRequirements requirements;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumn(name = "capabilitiesName", referencedColumnName = "name")
- @JoinColumn(name = "capabilitiesVersion", referencedColumnName = "version")
+ @JoinColumns({
+ @JoinColumn(name = "capabilitiesName", referencedColumnName = "name"),
+ @JoinColumn(name = "capabilitiesVersion", referencedColumnName = "version")
+ })
@Valid
private JpaToscaCapabilityAssignments capabilities;
// @formatter:on
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java
index 512abb75b..f295accab 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020,2023 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,6 +28,7 @@ import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import lombok.Data;
@@ -58,8 +59,10 @@ public class JpaToscaNodeType extends JpaToscaWithToscaProperties<ToscaNodeType>
// formatter:off
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumn(name = "requirementsName", referencedColumnName = "name")
- @JoinColumn(name = "requirementsVersion", referencedColumnName = "version")
+ @JoinColumns({
+ @JoinColumn(name = "requirementsName", referencedColumnName = "name"),
+ @JoinColumn(name = "requirementsVersion", referencedColumnName = "version")
+ })
// @formatter:on
@Valid
private JpaToscaRequirements requirements;
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java
index 769b623c7..109f1f0a8 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.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");
@@ -34,6 +34,7 @@ import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import lombok.Data;
@@ -78,45 +79,57 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp
private String toscaDefinitionsVersion;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumn(name = "dataTypesName", referencedColumnName = "name")
- @JoinColumn(name = "dataTypesVersion", referencedColumnName = "version")
+ @JoinColumns({
+ @JoinColumn(name = "dataTypesName", referencedColumnName = "name"),
+ @JoinColumn(name = "dataTypesVersion", referencedColumnName = "version")
+ })
@SerializedName("data_types")
@Valid
private JpaToscaDataTypes dataTypes;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumn(name = "capabilityTypesName", referencedColumnName = "name")
- @JoinColumn(name = "capabilityTypesVersion", referencedColumnName = "version")
+ @JoinColumns({
+ @JoinColumn(name = "capabilityTypesName", referencedColumnName = "name"),
+ @JoinColumn(name = "capabilityTypesVersion", referencedColumnName = "version")
+ })
@SerializedName("capability_types")
@Valid
private JpaToscaCapabilityTypes capabilityTypes;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumn(name = "relationshipTypesName", referencedColumnName = "name")
- @JoinColumn(name = "relationshipTypesVersion", referencedColumnName = "version")
+ @JoinColumns({
+ @JoinColumn(name = "relationshipTypesName", referencedColumnName = "name"),
+ @JoinColumn(name = "relationshipTypesVersion", referencedColumnName = "version")
+ })
@SerializedName("relationship_types")
@Valid
private JpaToscaRelationshipTypes relationshipTypes;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumn(name = "nodeTypesName", referencedColumnName = "name")
- @JoinColumn(name = "nodeTypesVersion", referencedColumnName = "version")
+ @JoinColumns({
+ @JoinColumn(name = "nodeTypesName", referencedColumnName = "name"),
+ @JoinColumn(name = "nodeTypesVersion", referencedColumnName = "version")
+ })
@SerializedName("node_types")
@Valid
private JpaToscaNodeTypes nodeTypes;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumn(name = "policyTypesName", referencedColumnName = "name")
- @JoinColumn(name = "policyTypesVersion", referencedColumnName = "version")
+ @JoinColumns({
+ @JoinColumn(name = "policyTypesName", referencedColumnName = "name"),
+ @JoinColumn(name = "policyTypesVersion", referencedColumnName = "version")
+ })
@SerializedName("policy_types")
@Valid
private JpaToscaPolicyTypes policyTypes;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumn(name = "topologyTemplateParentKeyName", referencedColumnName = "parentKeyName")
- @JoinColumn(name = "topologyTemplateParentKeyVersion", referencedColumnName = "parentKeyVersion")
- @JoinColumn(name = "topologyTemplateParentLocalName", referencedColumnName = "parentLocalName")
- @JoinColumn(name = "topologyTemplateLocalName", referencedColumnName = "localName")
+ @JoinColumns({
+ @JoinColumn(name = "topologyTemplateParentKeyName", referencedColumnName = "parentKeyName"),
+ @JoinColumn(name = "topologyTemplateParentKeyVersion", referencedColumnName = "parentKeyVersion"),
+ @JoinColumn(name = "topologyTemplateParentLocalName", referencedColumnName = "parentLocalName"),
+ @JoinColumn(name = "topologyTemplateLocalName", referencedColumnName = "localName")
+ })
@SerializedName("topology_template")
@Valid
private JpaToscaTopologyTemplate topologyTemplate;
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java
index af6f512dd..629e14a84 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2020,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");
@@ -35,6 +35,7 @@ import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@@ -86,15 +87,20 @@ public class JpaToscaTopologyTemplate extends PfConcept implements PfAuthorative
private Map<@NotNull String, @NotNull @Valid JpaToscaParameter> inputs;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumn(name = "nodeTemplatesName", referencedColumnName = "name")
- @JoinColumn(name = "nodeTemplatessVersion", referencedColumnName = "version")
+ @JoinColumns({
+ @JoinColumn(name = "nodeTemplatesName", referencedColumnName = "name"),
+ @JoinColumn(name = "nodeTemplatessVersion", referencedColumnName = "version")
+ })
@SerializedName("data_types")
@Valid
private JpaToscaNodeTemplates nodeTemplates;
@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
- @JoinColumn(name = "policyName", referencedColumnName = "name")
- @JoinColumn(name = "policyVersion", referencedColumnName = "version")
+ @JoinColumns({
+ @JoinColumn(name = "policyName", referencedColumnName = "name"),
+ @JoinColumn(name = "policyVersion", referencedColumnName = "version")
+
+ })
// @formatter:on
@Valid
private JpaToscaPolicies policies;
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithTypeAndStringProperties.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithTypeAndStringProperties.java
index 55acc0653..cb0ff4e5d 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithTypeAndStringProperties.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithTypeAndStringProperties.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021,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.
@@ -25,6 +25,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Lob;
@@ -56,8 +57,10 @@ public abstract class JpaToscaWithTypeAndStringProperties<T extends ToscaWithTyp
private static final long serialVersionUID = 2785481541573683089L;
@Column
- @AttributeOverride(name = "name", column = @Column(name = "type_name"))
- @AttributeOverride(name = "version", column = @Column(name = "type_version"))
+ @AttributeOverrides ({
+ @AttributeOverride(name = "name", column = @Column(name = "type_name")),
+ @AttributeOverride(name = "version", column = @Column(name = "type_version"))
+ })
@VerifyKey
@NotNull
private PfConceptKey type;
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java
index 63ac44ae2..51976d1e9 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderGenericTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2021 Nordix Foundation.
+ * Copyright (C) 2020-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");
@@ -30,7 +30,6 @@ import com.google.gson.GsonBuilder;
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang3.ObjectUtils;
-import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -86,18 +85,16 @@ public class AuthorativeToscaProviderGenericTest {
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:AuthorativeToscaProviderGenericTest");
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url",
+ "jdbc:h2:mem:AuthorativeToscaProviderGenericTest");
}
-
daoParameters.setJdbcProperties(jdbcProperties);
pfDao = new PfDaoFactory().createPfDao(daoParameters);
@@ -127,7 +124,7 @@ public class AuthorativeToscaProviderGenericTest {
assertNotNull(toscaServiceTemplate);
ToscaServiceTemplate createdServiceTemplate =
- new AuthorativeToscaProvider().createServiceTemplate(pfDao, toscaServiceTemplate);
+ new AuthorativeToscaProvider().createServiceTemplate(pfDao, toscaServiceTemplate);
PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION1);
@@ -137,14 +134,14 @@ public class AuthorativeToscaProviderGenericTest {
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
List<ToscaServiceTemplate> gotServiceTemplateList =
- new AuthorativeToscaProvider().getServiceTemplateList(pfDao, null, null);
+ new AuthorativeToscaProvider().getServiceTemplateList(pfDao, null, null);
ToscaPolicyType gotPolicyType = gotServiceTemplateList.get(0).getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
List<ToscaPolicyType> gotPolicyTypeList =
- new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_001);
+ new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_001);
assertEquals(2, gotPolicyTypeList.size());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
@@ -161,48 +158,48 @@ public class AuthorativeToscaProviderGenericTest {
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
assertThatThrownBy(() -> new AuthorativeToscaProvider().getPolicyTypeList(new DefaultPfDao(), POLICY_NO_VERSION,
- VERSION_001)).hasMessageContaining("Policy Framework DAO has not been initialized");
+ VERSION_001)).hasMessageContaining("Policy Framework DAO has not been initialized");
assertTrue(new AuthorativeToscaProvider().getPolicyTypeList(pfDao, "i.dont.Exist", VERSION_001).isEmpty());
ToscaServiceTemplate deletedServiceTemplate =
- new AuthorativeToscaProvider().deleteServiceTemplate(pfDao, "Dummy", "0.0.1");
+ new AuthorativeToscaProvider().deleteServiceTemplate(pfDao, "Dummy", "0.0.1");
assertEquals(2, deletedServiceTemplate.getPolicyTypes().size());
}
@Test
public void testNullParameters() throws Exception {
assertThatThrownBy(() -> new AuthorativeToscaProvider().getServiceTemplateList(null, null, null))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().createServiceTemplate(null, null))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().createServiceTemplate(pfDao, null))
- .hasMessageMatching("^serviceTemplate is marked .*on.*ull but is null$");
+ .hasMessageMatching("^serviceTemplate is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().createServiceTemplate(null, new ToscaServiceTemplate()))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(null, null, null))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(null, null, "0.0.1"))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(null, "Dummy", null))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(null, "Dummy", "0.0.1"))
- .hasMessageMatching("^dao is marked .*on.*ull but is null$");
+ .hasMessageMatching("^dao is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(pfDao, null, null))
- .hasMessageMatching("^name is marked .*on.*ull but is null$");
+ .hasMessageMatching("^name is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(pfDao, null, "0.0.1"))
- .hasMessageMatching("^name is marked .*on.*ull but is null$");
+ .hasMessageMatching("^name is marked .*on.*ull but is null$");
assertThatThrownBy(() -> new AuthorativeToscaProvider().deleteServiceTemplate(pfDao, "Dummy", null))
- .hasMessageMatching("^version is marked .*on.*ull but is null$");
+ .hasMessageMatching("^version is marked .*on.*ull but is null$");
}
}
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java
index cc034d8fb..64c164796 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderNodeTemplateTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022-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.
@@ -29,7 +29,6 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -96,18 +95,16 @@ public class AuthorativeToscaProviderNodeTemplateTest {
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,
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url",
"jdbc:h2:mem:AuthorativeToscaProviderNodeTemplatesTest");
}
-
daoParameters.setJdbcProperties(jdbcProperties);
pfDao = new PfDaoFactory().createPfDao(daoParameters);
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java
index 250b3e2ee..954f21eec 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.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");
@@ -30,7 +30,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -78,18 +77,16 @@ public class AuthorativeToscaProviderPolicyTest {
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,
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url",
"jdbc:h2:mem:AuthorativeToscaProviderPolicyTest");
}
-
daoParameters.setJdbcProperties(jdbcProperties);
pfDao = new PfDaoFactory().createPfDao(daoParameters);
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
index fff1aca50..3511bc8fa 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.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");
@@ -31,7 +31,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang3.ObjectUtils;
-import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -89,18 +88,16 @@ public class AuthorativeToscaProviderPolicyTypeTest {
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,
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url",
"jdbc:h2:mem:AuthorativeToscaProviderPolicyTypeTest");
}
-
daoParameters.setJdbcProperties(jdbcProperties);
pfDao = new PfDaoFactory().createPfDao(daoParameters);
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
index 55cd11e40..2382c5a03 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.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");
@@ -26,9 +26,10 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Properties;
-import org.eclipse.persistence.config.PersistenceUnitProperties;
+import java.util.TreeMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -46,6 +47,7 @@ import org.onap.policy.models.dao.impl.DefaultPfDao;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.authorative.provider.AuthorativeToscaProvider;
+import org.onap.policy.models.tosca.simple.concepts.JpaToscaConstraint;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies;
@@ -55,6 +57,7 @@ import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate;
+import org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger;
import org.yaml.snakeyaml.Yaml;
/**
@@ -84,15 +87,15 @@ public class SimpleToscaProviderTest {
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:SimpleToscaProviderTest");
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url", "jdbc:h2:mem:SimpleToscaProviderTest");
}
daoParameters.setJdbcProperties(jdbcProperties);
@@ -116,16 +119,19 @@ public class SimpleToscaProviderTest {
@Test
public void testCreateUpdateGetDeleteDataType() throws PfModelException {
- JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
-
PfConceptKey dataType0Key = new PfConceptKey("DataType0", "0.0.1");
JpaToscaDataType dataType0 = new JpaToscaDataType();
dataType0.setKey(dataType0Key);
+ dataType0.setConstraints(new ArrayList<JpaToscaConstraint>());
+ dataType0.setMetadata(new TreeMap<String, String>());
+ dataType0.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
+
+ JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
serviceTemplate.setDataTypes(new JpaToscaDataTypes());
serviceTemplate.getDataTypes().getConceptMap().put(dataType0Key, dataType0);
JpaToscaServiceTemplate createdServiceTemplate =
- new SimpleToscaProvider().createDataTypes(pfDao, serviceTemplate);
+ new SimpleToscaProvider().createDataTypes(pfDao, serviceTemplate);
assertEquals(1, createdServiceTemplate.getDataTypes().getConceptMap().size());
assertEquals(dataType0, createdServiceTemplate.getDataTypes().get(dataType0Key));
@@ -134,19 +140,19 @@ public class SimpleToscaProviderTest {
dataType0.setDescription("Updated Description");
JpaToscaServiceTemplate updatedServiceTemplate =
- new SimpleToscaProvider().updateDataTypes(pfDao, serviceTemplate);
+ new SimpleToscaProvider().updateDataTypes(pfDao, serviceTemplate);
assertEquals(dataType0, updatedServiceTemplate.getDataTypes().get(dataType0Key));
assertEquals("Updated Description", updatedServiceTemplate.getDataTypes().get(dataType0Key).getDescription());
JpaToscaServiceTemplate gotServiceTemplate =
- new SimpleToscaProvider().getDataTypes(pfDao, dataType0Key.getName(), dataType0Key.getVersion());
+ new SimpleToscaProvider().getDataTypes(pfDao, dataType0Key.getName(), dataType0Key.getVersion());
assertEquals(dataType0, gotServiceTemplate.getDataTypes().get(dataType0Key));
assertEquals("Updated Description", gotServiceTemplate.getDataTypes().get(dataType0Key).getDescription());
assertThatThrownBy(() -> new SimpleToscaProvider().deleteDataType(pfDao, new PfConceptKey("IDontExist:0.0.1")))
- .hasMessage("data type IDontExist:0.0.1 not found");
+ .hasMessage("data type IDontExist:0.0.1 not found");
JpaToscaServiceTemplate deletedServiceTemplate = new SimpleToscaProvider().deleteDataType(pfDao, dataType0Key);
@@ -167,7 +173,7 @@ public class SimpleToscaProviderTest {
assertEquals("Updated Description", deletedServiceTemplate.getDataTypes().get(dataType0Key).getDescription());
assertThatThrownBy(() -> new SimpleToscaProvider().deleteDataType(pfDao, dataType0Key))
- .hasMessage("no data types found");
+ .hasMessage("no data types found");
// Create the data type again
new SimpleToscaProvider().createDataTypes(pfDao, serviceTemplate);
@@ -181,9 +187,12 @@ public class SimpleToscaProviderTest {
new SimpleToscaProvider().createPolicyTypes(pfDao, updatedServiceTemplate);
assertThatThrownBy(() -> new SimpleToscaProvider().deleteDataType(pfDao, dataType0Key))
- .hasMessage("data type DataType0:0.0.1 is in use, it is referenced in policy type pt0:0.0.2");
+ .hasMessage("data type DataType0:0.0.1 is in use, it is referenced in policy type pt0:0.0.2");
JpaToscaDataType dataType0v2 = new JpaToscaDataType(new PfConceptKey("DataType0:0.0.2"));
+ dataType0v2.setConstraints(new ArrayList<JpaToscaConstraint>());
+ dataType0v2.setMetadata(new TreeMap<String, String>());
+ dataType0v2.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
updatedServiceTemplate.getDataTypes().getConceptMap().put(dataType0v2.getKey(), dataType0v2);
new SimpleToscaProvider().createDataTypes(pfDao, updatedServiceTemplate);
@@ -193,7 +202,7 @@ public class SimpleToscaProviderTest {
assertNull(deletedServiceTemplate.getDataTypes().get(dataType0v2.getKey()).getDescription());
assertThatThrownBy(() -> new SimpleToscaProvider().deleteDataType(pfDao, dataType0Key))
- .hasMessage("data type DataType0:0.0.1 is in use, it is referenced in policy type pt0:0.0.2");
+ .hasMessage("data type DataType0:0.0.1 is in use, it is referenced in policy type pt0:0.0.2");
JpaToscaDataType dataType1 = new JpaToscaDataType(new PfConceptKey("DataType1:0.0.3"));
JpaToscaProperty prop1 = new JpaToscaProperty(new PfReferenceKey(dataType1.getKey(), "prop1"));
@@ -204,7 +213,7 @@ public class SimpleToscaProviderTest {
new SimpleToscaProvider().createDataTypes(pfDao, updatedServiceTemplate);
assertThatThrownBy(() -> new SimpleToscaProvider().deleteDataType(pfDao, dataType0v2.getKey()))
- .hasMessage("data type DataType0:0.0.2 is in use, it is referenced in data type DataType1:0.0.3");
+ .hasMessage("data type DataType0:0.0.2 is in use, it is referenced in data type DataType1:0.0.3");
}
@Test
@@ -220,11 +229,15 @@ public class SimpleToscaProviderTest {
PfConceptKey policyType0Key = new PfConceptKey("PolicyType0", "0.0.1");
JpaToscaPolicyType policyType0 = new JpaToscaPolicyType();
policyType0.setKey(policyType0Key);
+ policyType0.setMetadata(new TreeMap<String, String>());
+ policyType0.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
+ policyType0.setTargets(new ArrayList<PfConceptKey>());
+ policyType0.setTriggers(new ArrayList<JpaToscaTrigger>());
serviceTemplate.setPolicyTypes(new JpaToscaPolicyTypes());
serviceTemplate.getPolicyTypes().getConceptMap().put(policyType0Key, policyType0);
JpaToscaServiceTemplate createdServiceTemplate =
- new SimpleToscaProvider().createPolicyTypes(pfDao, serviceTemplate);
+ new SimpleToscaProvider().createPolicyTypes(pfDao, serviceTemplate);
assertEquals(1, createdServiceTemplate.getPolicyTypes().getConceptMap().size());
assertEquals(policyType0, createdServiceTemplate.getPolicyTypes().get(policyType0Key));
@@ -233,14 +246,14 @@ public class SimpleToscaProviderTest {
policyType0.setDescription("Updated Description");
JpaToscaServiceTemplate updatedServiceTemplate =
- new SimpleToscaProvider().updatePolicyTypes(pfDao, serviceTemplate);
+ new SimpleToscaProvider().updatePolicyTypes(pfDao, serviceTemplate);
assertEquals(policyType0, updatedServiceTemplate.getPolicyTypes().get(policyType0Key));
assertEquals("Updated Description",
- updatedServiceTemplate.getPolicyTypes().get(policyType0Key).getDescription());
+ updatedServiceTemplate.getPolicyTypes().get(policyType0Key).getDescription());
JpaToscaServiceTemplate gotServiceTemplate =
- new SimpleToscaProvider().getPolicyTypes(pfDao, policyType0Key.getName(), policyType0Key.getVersion());
+ new SimpleToscaProvider().getPolicyTypes(pfDao, policyType0Key.getName(), policyType0Key.getVersion());
assertEquals(policyType0, gotServiceTemplate.getPolicyTypes().get(policyType0Key));
assertEquals("Updated Description", gotServiceTemplate.getPolicyTypes().get(policyType0Key).getDescription());
@@ -255,7 +268,7 @@ public class SimpleToscaProviderTest {
new SimpleToscaProvider().createPolicyTypes(pfDao, serviceTemplate);
assertThatThrownBy(() -> new SimpleToscaProvider().deletePolicyType(pfDao, policyType0Key))
- .hasMessage("policy type PolicyType0:0.0.1 is in use, it is referenced in policy type pt1:0.0.2");
+ .hasMessage("policy type PolicyType0:0.0.1 is in use, it is referenced in policy type pt1:0.0.2");
serviceTemplate.setTopologyTemplate(new JpaToscaTopologyTemplate());
serviceTemplate.getTopologyTemplate().setPolicies(new JpaToscaPolicies());
@@ -270,10 +283,10 @@ public class SimpleToscaProviderTest {
new SimpleToscaProvider().createPolicies(pfDao, serviceTemplate);
assertThatThrownBy(() -> new SimpleToscaProvider().deletePolicyType(pfDao, policyType0Key))
- .hasMessage("policy type PolicyType0:0.0.1 is in use, it is referenced in policy type pt1:0.0.2");
+ .hasMessage("policy type PolicyType0:0.0.1 is in use, it is referenced in policy type pt1:0.0.2");
assertThatThrownBy(() -> new SimpleToscaProvider().deletePolicyType(pfDao, pt1.getKey()))
- .hasMessage("policy type pt1:0.0.2 is in use, it is referenced in policy p1:0.0.1");
+ .hasMessage("policy type pt1:0.0.2 is in use, it is referenced in policy p1:0.0.1");
new SimpleToscaProvider().deletePolicy(pfDao, p1.getKey());
@@ -282,32 +295,36 @@ public class SimpleToscaProviderTest {
new SimpleToscaProvider().deletePolicy(pfDao, p0.getKey());
JpaToscaServiceTemplate deletedServiceTemplate =
- new SimpleToscaProvider().deletePolicyType(pfDao, policyType0Key);
+ new SimpleToscaProvider().deletePolicyType(pfDao, policyType0Key);
assertEquals(policyType0, deletedServiceTemplate.getPolicyTypes().get(policyType0Key));
assertEquals("Updated Description",
- deletedServiceTemplate.getPolicyTypes().get(policyType0Key).getDescription());
+ deletedServiceTemplate.getPolicyTypes().get(policyType0Key).getDescription());
assertThatThrownBy(() -> new SimpleToscaProvider().deletePolicyType(pfDao, policyType0Key))
- .hasMessage("no policy types found");
+ .hasMessage("no policy types found");
JpaToscaServiceTemplate newServiceTemplate =
- new SimpleToscaProvider().createPolicyTypes(pfDao, serviceTemplate);
+ new SimpleToscaProvider().createPolicyTypes(pfDao, serviceTemplate);
assertEquals(serviceTemplate, newServiceTemplate);
}
@Test
public void testCreateUpdateGetDeletePolicyTypeWithDataType() throws PfModelException {
- JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
-
PfConceptKey policyType0Key = new PfConceptKey("PolicyType0", "0.0.1");
JpaToscaPolicyType policyType0 = new JpaToscaPolicyType();
policyType0.setKey(policyType0Key);
+ policyType0.setMetadata(new TreeMap<String, String>());
+ policyType0.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
+ policyType0.setTargets(new ArrayList<PfConceptKey>());
+ policyType0.setTriggers(new ArrayList<JpaToscaTrigger>());
+
+ JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
serviceTemplate.setPolicyTypes(new JpaToscaPolicyTypes());
serviceTemplate.getPolicyTypes().getConceptMap().put(policyType0Key, policyType0);
JpaToscaServiceTemplate createdServiceTemplate =
- new SimpleToscaProvider().createPolicyTypes(pfDao, serviceTemplate);
+ new SimpleToscaProvider().createPolicyTypes(pfDao, serviceTemplate);
assertEquals(policyType0, createdServiceTemplate.getPolicyTypes().get(policyType0Key));
assertEquals(null, createdServiceTemplate.getPolicyTypes().get(policyType0Key).getDescription());
@@ -315,33 +332,33 @@ public class SimpleToscaProviderTest {
policyType0.setDescription("Updated Description");
JpaToscaServiceTemplate updatedServiceTemplate =
- new SimpleToscaProvider().updatePolicyTypes(pfDao, serviceTemplate);
+ new SimpleToscaProvider().updatePolicyTypes(pfDao, serviceTemplate);
assertEquals(policyType0, updatedServiceTemplate.getPolicyTypes().get(policyType0Key));
assertEquals("Updated Description",
- updatedServiceTemplate.getPolicyTypes().get(policyType0Key).getDescription());
+ updatedServiceTemplate.getPolicyTypes().get(policyType0Key).getDescription());
JpaToscaServiceTemplate gotServiceTemplate =
- new SimpleToscaProvider().getPolicyTypes(pfDao, policyType0Key.getName(), policyType0Key.getVersion());
+ new SimpleToscaProvider().getPolicyTypes(pfDao, policyType0Key.getName(), policyType0Key.getVersion());
assertEquals(policyType0, gotServiceTemplate.getPolicyTypes().get(policyType0Key));
assertEquals("Updated Description", gotServiceTemplate.getPolicyTypes().get(policyType0Key).getDescription());
JpaToscaServiceTemplate deletedServiceTemplate =
- new SimpleToscaProvider().deletePolicyType(pfDao, policyType0Key);
+ new SimpleToscaProvider().deletePolicyType(pfDao, policyType0Key);
assertEquals(policyType0, deletedServiceTemplate.getPolicyTypes().get(policyType0Key));
assertEquals("Updated Description",
- deletedServiceTemplate.getPolicyTypes().get(policyType0Key).getDescription());
+ deletedServiceTemplate.getPolicyTypes().get(policyType0Key).getDescription());
assertThatThrownBy(() -> new SimpleToscaProvider().deletePolicyType(pfDao, policyType0Key))
- .hasMessage("no policy types found");
+ .hasMessage("no policy types found");
}
@Test
public void testPoliciesGet() throws Exception {
ToscaServiceTemplate toscaServiceTemplate =
- standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class);
+ standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class);
createPolicyTypes();
@@ -350,18 +367,18 @@ public class SimpleToscaProviderTest {
assertNotNull(originalServiceTemplate);
JpaToscaServiceTemplate createdServiceTemplate =
- new SimpleToscaProvider().createPolicies(pfDao, originalServiceTemplate);
+ new SimpleToscaProvider().createPolicies(pfDao, originalServiceTemplate);
assertEquals(originalServiceTemplate.getTopologyTemplate().getPolicies(),
- createdServiceTemplate.getTopologyTemplate().getPolicies());
+ createdServiceTemplate.getTopologyTemplate().getPolicies());
PfConceptKey policyKey = new PfConceptKey("onap.restart.tca:1.0.0");
JpaToscaServiceTemplate gotServiceTemplate =
- new SimpleToscaProvider().getPolicies(pfDao, policyKey.getName(), policyKey.getVersion());
+ new SimpleToscaProvider().getPolicies(pfDao, policyKey.getName(), policyKey.getVersion());
assertEquals(0, originalServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey)
- .compareTo(gotServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey)));
+ .compareTo(gotServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey)));
JpaToscaServiceTemplate deletedServiceTemplate = new SimpleToscaProvider().deletePolicy(pfDao, policyKey);
assertEquals(1, deletedServiceTemplate.getTopologyTemplate().getPolicies().getConceptMap().size());
@@ -370,7 +387,7 @@ public class SimpleToscaProviderTest {
@Test
public void testPolicyCreate() throws Exception {
ToscaServiceTemplate toscaServiceTemplate =
- standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class);
+ standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class);
createPolicyTypes();
@@ -379,21 +396,21 @@ public class SimpleToscaProviderTest {
assertNotNull(originalServiceTemplate);
JpaToscaServiceTemplate createdServiceTemplate =
- new SimpleToscaProvider().createPolicies(pfDao, originalServiceTemplate);
+ new SimpleToscaProvider().createPolicies(pfDao, originalServiceTemplate);
assertEquals(originalServiceTemplate.getTopologyTemplate().getPolicies(),
- createdServiceTemplate.getTopologyTemplate().getPolicies());
+ createdServiceTemplate.getTopologyTemplate().getPolicies());
}
@Test
public void testPolicyCreateTypeAndVersion() throws Exception {
ToscaServiceTemplate toscaServiceTemplate =
- standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class);
+ standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class);
createPolicyTypes();
ToscaPolicy toscaPolicy =
- toscaServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().values().iterator().next();
+ toscaServiceTemplate.getToscaTopologyTemplate().getPoliciesAsMap().values().iterator().next();
JpaToscaServiceTemplate originalServiceTemplate = new JpaToscaServiceTemplate();
@@ -410,7 +427,7 @@ public class SimpleToscaProviderTest {
assertThatThrownBy(() -> {
originalServiceTemplate.fromAuthorative(toscaServiceTemplate);
}).hasMessage("Version not specified, the version of this TOSCA entity must be "
- + "specified in the type_version field");
+ + "specified in the type_version field");
toscaPolicy.setTypeVersion("hello");
assertThatThrownBy(() -> {
@@ -423,7 +440,7 @@ public class SimpleToscaProviderTest {
assertThatThrownBy(() -> {
new SimpleToscaProvider().createPolicies(pfDao, originalServiceTemplate);
}).hasMessageContaining("policy type").hasMessageContaining("IDontExist:99.100.101")
- .hasMessageContaining(Validated.NOT_FOUND);
+ .hasMessageContaining(Validated.NOT_FOUND);
toscaPolicy.setType("IDontExist");
originalServiceTemplate.fromAuthorative(toscaServiceTemplate);
@@ -439,15 +456,15 @@ public class SimpleToscaProviderTest {
originalServiceTemplate.fromAuthorative(toscaServiceTemplate);
JpaToscaServiceTemplate createdServiceTemplate =
- new SimpleToscaProvider().createPolicies(pfDao, originalServiceTemplate);
+ new SimpleToscaProvider().createPolicies(pfDao, originalServiceTemplate);
assertEquals(originalServiceTemplate.getTopologyTemplate().getPolicies(),
- createdServiceTemplate.getTopologyTemplate().getPolicies());
+ createdServiceTemplate.getTopologyTemplate().getPolicies());
}
@Test
public void testPolicyUpdate() throws Exception {
ToscaServiceTemplate toscaServiceTemplate =
- standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class);
+ standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class);
createPolicyTypes();
@@ -456,7 +473,7 @@ public class SimpleToscaProviderTest {
assertNotNull(originalServiceTemplate);
JpaToscaServiceTemplate updatedServiceTemplate =
- new SimpleToscaProvider().updatePolicies(pfDao, originalServiceTemplate);
+ new SimpleToscaProvider().updatePolicies(pfDao, originalServiceTemplate);
assertEquals(originalServiceTemplate, updatedServiceTemplate);
}
@@ -464,7 +481,7 @@ public class SimpleToscaProviderTest {
@Test
public void testPoliciesDelete() throws Exception {
ToscaServiceTemplate toscaServiceTemplate =
- standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class);
+ standardCoder.decode(ResourceUtils.getResourceAsString(VCPE_INPUT_JSON), ToscaServiceTemplate.class);
createPolicyTypes();
@@ -473,26 +490,26 @@ public class SimpleToscaProviderTest {
assertNotNull(originalServiceTemplate);
JpaToscaServiceTemplate createdServiceTemplate =
- new SimpleToscaProvider().createPolicies(pfDao, originalServiceTemplate);
+ new SimpleToscaProvider().createPolicies(pfDao, originalServiceTemplate);
assertEquals(originalServiceTemplate.getTopologyTemplate(), createdServiceTemplate.getTopologyTemplate());
PfConceptKey policyKey = new PfConceptKey("onap.restart.tca:1.0.0");
assertThatThrownBy(() -> new SimpleToscaProvider().deletePolicy(pfDao, new PfConceptKey("IDontExist:0.0.1")))
- .hasMessage("policy IDontExist:0.0.1 not found");
+ .hasMessage("policy IDontExist:0.0.1 not found");
JpaToscaServiceTemplate deletedServiceTemplate = new SimpleToscaProvider().deletePolicy(pfDao, policyKey);
assertEquals(0, originalServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey)
- .compareTo(deletedServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey)));
+ .compareTo(deletedServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey)));
assertThatThrownBy(() -> {
new SimpleToscaProvider().getPolicies(pfDao, policyKey.getName(), policyKey.getVersion());
}).hasMessage("policies for onap.restart.tca:1.0.0 do not exist");
assertThatThrownBy(() -> new SimpleToscaProvider().deletePolicy(pfDao, policyKey))
- .hasMessage("no policies found");
+ .hasMessage("no policies found");
new SimpleToscaProvider().createPolicies(pfDao, originalServiceTemplate);
}
@@ -502,21 +519,21 @@ public class SimpleToscaProviderTest {
JpaToscaServiceTemplate testServiceTemplate = new JpaToscaServiceTemplate();
assertThatThrownBy(() -> new SimpleToscaProvider().createPolicies(pfDao, testServiceTemplate))
- .hasMessage("topology template not specified on service template");
+ .hasMessage("topology template not specified on service template");
testServiceTemplate.setTopologyTemplate(new JpaToscaTopologyTemplate());
assertThatThrownBy(() -> new SimpleToscaProvider().createPolicies(pfDao, testServiceTemplate))
- .hasMessage("no policies specified on topology template of service template");
+ .hasMessage("no policies specified on topology template of service template");
testServiceTemplate.getTopologyTemplate().setPolicies(new JpaToscaPolicies());
assertThatThrownBy(() -> new SimpleToscaProvider().createPolicies(pfDao, testServiceTemplate))
- .hasMessage("list of policies specified on topology template of service template is empty");
+ .hasMessage("list of policies specified on topology template of service template is empty");
}
@Test
public void testGetServiceTemplate() throws PfModelException {
assertThatThrownBy(() -> new SimpleToscaProvider().getServiceTemplate(pfDao))
- .hasMessage("service template not found in database");
+ .hasMessage("service template not found in database");
}
@Test
@@ -527,8 +544,8 @@ public class SimpleToscaProviderTest {
serviceTemplateFragment.getPolicyTypes().getConceptMap().put(badPt.getKey(), badPt);
assertThatThrownBy(() -> new SimpleToscaProvider().appendToServiceTemplate(pfDao, serviceTemplateFragment))
- .hasMessageContaining("key on concept entry").hasMessageContaining("NULL:0.0.0")
- .hasMessageContaining(Validated.IS_A_NULL_KEY);
+ .hasMessageContaining("key on concept entry").hasMessageContaining("NULL:0.0.0")
+ .hasMessageContaining(Validated.IS_A_NULL_KEY);
}
@Test
@@ -539,8 +556,8 @@ public class SimpleToscaProviderTest {
JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
serviceTemplate.setPolicyTypes(new JpaToscaPolicyTypes());
- JpaToscaPolicyType p0 = new JpaToscaPolicyType(new PfConceptKey("p0:0.0.1"));
- serviceTemplate.getPolicyTypes().getConceptMap().put(p0.getKey(), p0);
+ JpaToscaPolicyType pt0 = new JpaToscaPolicyType(new PfConceptKey("p0:0.0.1"));
+ serviceTemplate.getPolicyTypes().getConceptMap().put(pt0.getKey(), pt0);
new SimpleToscaProvider().createPolicyTypes(pfDao, serviceTemplate);
@@ -550,8 +567,11 @@ public class SimpleToscaProviderTest {
serviceTemplate.setDataTypes(new JpaToscaDataTypes());
- JpaToscaDataType p01 = new JpaToscaDataType(new PfConceptKey("dt0:0.0.1"));
- serviceTemplate.getDataTypes().getConceptMap().put(p01.getKey(), p01);
+ JpaToscaDataType dt01 = new JpaToscaDataType(new PfConceptKey("dt0:0.0.1"));
+ dt01.setConstraints(new ArrayList<JpaToscaConstraint>());
+ dt01.setMetadata(new TreeMap<String, String>());
+ dt01.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
+ serviceTemplate.getDataTypes().getConceptMap().put(dt01.getKey(), dt01);
new SimpleToscaProvider().createDataTypes(pfDao, serviceTemplate);
@@ -559,32 +579,36 @@ public class SimpleToscaProviderTest {
new SimpleToscaProvider().getDataTypes(pfDao, "hello", "0.0.1");
}).hasMessageMatching("data types for hello:0.0.1 do not exist");
- JpaToscaServiceTemplate gotSt = new SimpleToscaProvider().getDataTypes(pfDao, p01.getName(), p01.getVersion());
+ JpaToscaServiceTemplate gotSt =
+ new SimpleToscaProvider().getDataTypes(pfDao, dt01.getName(), dt01.getVersion());
- assertEquals(p01, gotSt.getDataTypes().get(p01.getKey()));
- assertEquals(p01, gotSt.getDataTypes().get(p01.getName()));
- assertEquals(p01, gotSt.getDataTypes().get(p01.getName(), null));
- assertEquals(p01, gotSt.getDataTypes().get(p01.getName(), p01.getVersion()));
+ assertEquals(dt01, gotSt.getDataTypes().get(dt01.getKey()));
+ assertEquals(dt01, gotSt.getDataTypes().get(dt01.getName()));
+ assertEquals(dt01, gotSt.getDataTypes().get(dt01.getName(), null));
+ assertEquals(dt01, gotSt.getDataTypes().get(dt01.getName(), dt01.getVersion()));
assertEquals(1, gotSt.getDataTypes().getAll(null).size());
assertEquals(1, gotSt.getDataTypes().getAll(null, null).size());
- assertEquals(1, gotSt.getDataTypes().getAll(p01.getName(), null).size());
- assertEquals(1, gotSt.getDataTypes().getAll(p01.getName(), p01.getVersion()).size());
+ assertEquals(1, gotSt.getDataTypes().getAll(dt01.getName(), null).size());
+ assertEquals(1, gotSt.getDataTypes().getAll(dt01.getName(), dt01.getVersion()).size());
- JpaToscaDataType p02 = new JpaToscaDataType(new PfConceptKey("dt0:0.0.2"));
- serviceTemplate.getDataTypes().getConceptMap().put(p02.getKey(), p02);
+ JpaToscaDataType dt02 = new JpaToscaDataType(new PfConceptKey("dt0:0.0.2"));
+ dt02.setConstraints(new ArrayList<JpaToscaConstraint>());
+ dt02.setMetadata(new TreeMap<String, String>());
+ dt02.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
+ serviceTemplate.getDataTypes().getConceptMap().put(dt02.getKey(), dt02);
new SimpleToscaProvider().createDataTypes(pfDao, serviceTemplate);
- gotSt = new SimpleToscaProvider().getDataTypes(pfDao, p01.getName(), null);
+ gotSt = new SimpleToscaProvider().getDataTypes(pfDao, dt01.getName(), null);
- assertEquals(p01, gotSt.getDataTypes().get(p01.getKey()));
- assertEquals(p02, gotSt.getDataTypes().get(p01.getName()));
- assertEquals(p02, gotSt.getDataTypes().get(p01.getName(), null));
- assertEquals(p01, gotSt.getDataTypes().get(p01.getName(), p01.getVersion()));
- assertEquals(p02, gotSt.getDataTypes().get(p01.getName(), p02.getVersion()));
+ assertEquals(dt01, gotSt.getDataTypes().get(dt01.getKey()));
+ assertEquals(dt02, gotSt.getDataTypes().get(dt01.getName()));
+ assertEquals(dt02, gotSt.getDataTypes().get(dt01.getName(), null));
+ assertEquals(dt01, gotSt.getDataTypes().get(dt01.getName(), dt01.getVersion()));
+ assertEquals(dt02, gotSt.getDataTypes().get(dt01.getName(), dt02.getVersion()));
assertEquals(2, gotSt.getDataTypes().getAll(null).size());
assertEquals(2, gotSt.getDataTypes().getAll(null, null).size());
- assertEquals(2, gotSt.getDataTypes().getAll(p01.getName(), null).size());
- assertEquals(1, gotSt.getDataTypes().getAll(p01.getName(), p02.getVersion()).size());
+ assertEquals(2, gotSt.getDataTypes().getAll(dt01.getName(), null).size());
+ assertEquals(1, gotSt.getDataTypes().getAll(dt01.getName(), dt02.getVersion()).size());
}
@Test
@@ -607,6 +631,10 @@ public class SimpleToscaProviderTest {
serviceTemplate.setPolicyTypes(new JpaToscaPolicyTypes());
JpaToscaPolicyType pt01 = new JpaToscaPolicyType(new PfConceptKey("p0:0.0.1"));
+ pt01.setMetadata(new TreeMap<String, String>());
+ pt01.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
+ pt01.setTargets(new ArrayList<PfConceptKey>());
+ pt01.setTriggers(new ArrayList<JpaToscaTrigger>());
serviceTemplate.getPolicyTypes().getConceptMap().put(pt01.getKey(), pt01);
new SimpleToscaProvider().createPolicyTypes(pfDao, serviceTemplate);
@@ -616,7 +644,7 @@ public class SimpleToscaProviderTest {
}).hasMessageMatching("policy types for hello:0.0.1 do not exist");
JpaToscaServiceTemplate gotSt =
- new SimpleToscaProvider().getPolicyTypes(pfDao, pt01.getName(), pt01.getVersion());
+ new SimpleToscaProvider().getPolicyTypes(pfDao, pt01.getName(), pt01.getVersion());
assertEquals(pt01, gotSt.getPolicyTypes().get(pt01.getKey()));
assertEquals(pt01, gotSt.getPolicyTypes().get(pt01.getName()));
@@ -628,6 +656,10 @@ public class SimpleToscaProviderTest {
assertEquals(1, gotSt.getPolicyTypes().getAll(pt01.getName(), pt01.getVersion()).size());
JpaToscaPolicyType pt02 = new JpaToscaPolicyType(new PfConceptKey("p0:0.0.2"));
+ pt02.setMetadata(new TreeMap<String, String>());
+ pt02.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
+ pt02.setTargets(new ArrayList<PfConceptKey>());
+ pt02.setTriggers(new ArrayList<JpaToscaTrigger>());
serviceTemplate.getPolicyTypes().getConceptMap().put(pt02.getKey(), pt02);
new SimpleToscaProvider().createPolicyTypes(pfDao, serviceTemplate);
@@ -653,6 +685,9 @@ public class SimpleToscaProviderTest {
JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
serviceTemplate.setDataTypes(new JpaToscaDataTypes());
JpaToscaDataType dt0 = new JpaToscaDataType(new PfConceptKey("dt0:0.0.1"));
+ dt0.setConstraints(new ArrayList<JpaToscaConstraint>());
+ dt0.setMetadata(new TreeMap<String, String>());
+ dt0.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
serviceTemplate.getDataTypes().getConceptMap().put(dt0.getKey(), dt0);
new SimpleToscaProvider().createDataTypes(pfDao, serviceTemplate);
@@ -664,6 +699,10 @@ public class SimpleToscaProviderTest {
serviceTemplate.setPolicyTypes(new JpaToscaPolicyTypes());
JpaToscaPolicyType pt01 = new JpaToscaPolicyType(new PfConceptKey("pt0:0.0.1"));
+ pt01.setMetadata(new TreeMap<String, String>());
+ pt01.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
+ pt01.setTargets(new ArrayList<PfConceptKey>());
+ pt01.setTriggers(new ArrayList<JpaToscaTrigger>());
serviceTemplate.getPolicyTypes().getConceptMap().put(pt01.getKey(), pt01);
serviceTemplate.setTopologyTemplate(new JpaToscaTopologyTemplate());
@@ -671,6 +710,9 @@ public class SimpleToscaProviderTest {
JpaToscaPolicy p01 = new JpaToscaPolicy(new PfConceptKey("p0:0.0.1"));
p01.setType(pt01.getKey());
+ p01.setMetadata(new TreeMap<String, String>());
+ p01.setProperties(new LinkedHashMap<String, String>());
+ p01.setTargets(new ArrayList<PfConceptKey>());
serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(p01.getKey(), p01);
new SimpleToscaProvider().createPolicies(pfDao, serviceTemplate);
@@ -692,6 +734,10 @@ public class SimpleToscaProviderTest {
JpaToscaPolicy p02 = new JpaToscaPolicy(new PfConceptKey("p0:0.0.2"));
p02.setType(pt01.getKey());
+ p02.setType(pt01.getKey());
+ p02.setMetadata(new TreeMap<String, String>());
+ p02.setProperties(new LinkedHashMap<String, String>());
+ p02.setTargets(new ArrayList<PfConceptKey>());
serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(p02.getKey(), p02);
new SimpleToscaProvider().createPolicies(pfDao, serviceTemplate);
@@ -860,16 +906,19 @@ public class SimpleToscaProviderTest {
new SimpleToscaProvider().deleteServiceTemplate(pfDao);
}).hasMessage("service template not found in database");
- JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
-
PfConceptKey dataType0Key = new PfConceptKey("DataType0", "0.0.1");
JpaToscaDataType dataType0 = new JpaToscaDataType();
dataType0.setKey(dataType0Key);
+ dataType0.setConstraints(new ArrayList<JpaToscaConstraint>());
+ dataType0.setMetadata(new TreeMap<String, String>());
+ dataType0.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
+
+ JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
serviceTemplate.setDataTypes(new JpaToscaDataTypes());
serviceTemplate.getDataTypes().getConceptMap().put(dataType0Key, dataType0);
JpaToscaServiceTemplate createdServiceTemplate =
- new SimpleToscaProvider().createDataTypes(pfDao, serviceTemplate);
+ new SimpleToscaProvider().createDataTypes(pfDao, serviceTemplate);
assertEquals(1, createdServiceTemplate.getDataTypes().getConceptMap().size());
assertEquals(dataType0, createdServiceTemplate.getDataTypes().get(dataType0Key));
@@ -889,11 +938,11 @@ public class SimpleToscaProviderTest {
private void createPolicyTypes() throws CoderException, PfModelException {
Object yamlObject =
- new Yaml().load(ResourceUtils.getResourceAsString("policytypes/onap.policies.monitoring.tcagen2.yaml"));
+ new Yaml().load(ResourceUtils.getResourceAsString("policytypes/onap.policies.monitoring.tcagen2.yaml"));
String yamlAsJsonString = new StandardCoder().encode(yamlObject);
ToscaServiceTemplate toscaServiceTemplatePolicyType =
- standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
+ standardCoder.decode(yamlAsJsonString, ToscaServiceTemplate.class);
assertNotNull(toscaServiceTemplatePolicyType);
new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplatePolicyType);
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java
index 016ed532c..f00fa0fc5 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProviderTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2021 Nordix Foundation.
+ * Copyright (C) 2020-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");
@@ -25,8 +25,10 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.Properties;
-import org.eclipse.persistence.config.PersistenceUnitProperties;
+import java.util.TreeMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -36,11 +38,14 @@ import org.onap.policy.models.dao.DaoParameters;
import org.onap.policy.models.dao.PfDao;
import org.onap.policy.models.dao.PfDaoFactory;
import org.onap.policy.models.dao.impl.DefaultPfDao;
+import org.onap.policy.models.tosca.simple.concepts.JpaToscaConstraint;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaDataType;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaDataTypes;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyType;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes;
+import org.onap.policy.models.tosca.simple.concepts.JpaToscaProperty;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
+import org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger;
/**
* Test the {@link SimpleToscaProvider} class.
@@ -66,15 +71,15 @@ public class SimpleToscaServiceTemplateProviderTest {
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,
+ jdbcProperties.setProperty("javax.persistence.jdbc.driver", "org.h2.Driver");
+ jdbcProperties.setProperty("javax.persistence.jdbc.url",
"jdbc:h2:mem:SimpleToscaServiceTemplateProviderTest");
}
@@ -92,6 +97,7 @@ public class SimpleToscaServiceTemplateProviderTest {
@Test
public void testCreateUpdateGetDeleteDataType() throws PfModelException {
JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
+ serviceTemplate.setMetadata(new TreeMap<String, String>());
JpaToscaServiceTemplate dbServiceTemplate =
new SimpleToscaServiceTemplateProvider().write(pfDao, serviceTemplate);
@@ -106,6 +112,9 @@ public class SimpleToscaServiceTemplateProviderTest {
PfConceptKey dataType0Key = new PfConceptKey("DataType0", "0.0.1");
JpaToscaDataType dataType0 = new JpaToscaDataType();
dataType0.setKey(dataType0Key);
+ dataType0.setConstraints(new ArrayList<JpaToscaConstraint>());
+ dataType0.setMetadata(new TreeMap<String, String>());
+ dataType0.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
serviceTemplate.setDataTypes(new JpaToscaDataTypes());
serviceTemplate.getDataTypes().getConceptMap().put(dataType0Key, dataType0);
@@ -135,6 +144,10 @@ public class SimpleToscaServiceTemplateProviderTest {
JpaToscaPolicyType policyType0 = new JpaToscaPolicyType();
policyType0.setKey(policyType0Key);
+ policyType0.setMetadata(new TreeMap<String, String>());
+ policyType0.setProperties(new LinkedHashMap<String, JpaToscaProperty>());
+ policyType0.setTargets(new ArrayList<PfConceptKey>());
+ policyType0.setTriggers(new ArrayList<JpaToscaTrigger>());
serviceTemplate.setPolicyTypes(new JpaToscaPolicyTypes());
serviceTemplate.getPolicyTypes().getConceptMap().put(policyType0Key, policyType0);
diff --git a/models-tosca/src/test/resources/META-INF/persistence.xml b/models-tosca/src/test/resources/META-INF/persistence.xml
index 5c65fc59b..922fef286 100644
--- a/models-tosca/src/test/resources/META-INF/persistence.xml
+++ b/models-tosca/src/test/resources/META-INF/persistence.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
============LICENSE_START=======================================================
- Copyright (C) 2019-2021 Nordix Foundation.
+ Copyright (C) 2019-2021,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.
@@ -21,8 +21,6 @@
<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.base.PfConceptKey</class>
<class>org.onap.policy.models.dao.converters.CDataConditioner</class>
<class>org.onap.policy.models.dao.converters.Uuid2String</class>
@@ -51,21 +49,9 @@
<class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTrigger</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>
diff --git a/pom.xml b/pom.xml
index 26df0fdf2..2b42f5d6c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
- Copyright (C) 2019-2020, 2022 Nordix Foundation.
+ Copyright (C) 2019-2020,2022-2023 Nordix Foundation.
Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2020 Bell Canada.
================================================================================
@@ -119,8 +119,13 @@
</dependency>
<dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>eclipselink</artifactId>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.1-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>