aboutsummaryrefslogtreecommitdiffstats
path: root/model/basic-model
diff options
context:
space:
mode:
Diffstat (limited to 'model/basic-model')
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java14
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDao.java206
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDaoFactory.java70
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/DaoParameters.java123
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/CDataConditioner.java83
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/Uuid2String.java73
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/package-info.java28
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java497
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/package-info.java27
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/package-info.java29
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java27
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java7
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/DaoMiscTest.java77
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java262
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java84
-rw-r--r--model/basic-model/src/test/resources/META-INF/persistence.xml43
16 files changed, 44 insertions, 1606 deletions
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
index 7e92faddf..2e788a3d5 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfo.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,7 +26,6 @@ import java.util.List;
import java.util.Random;
import java.util.UUID;
import javax.persistence.Column;
-import javax.persistence.Convert;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
@@ -35,11 +34,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.apex.model.basicmodel.dao.converters.CDataConditioner;
-import org.onap.policy.apex.model.basicmodel.dao.converters.Uuid2String;
import org.onap.policy.common.utils.validation.Assertions;
/**
@@ -74,14 +70,10 @@ public class AxKeyInfo extends AxConcept {
private AxArtifactKey key;
@Column(name = "uuid")
- @Convert(converter = Uuid2String.class)
- @XmlJavaTypeAdapter(value = Uuid2String.class)
@XmlElement(name = "UUID", required = true)
private UUID uuid;
@Column(name = "description", length = MAX_DESCRIPTION_LENGTH_8192)
- @Convert(converter = CDataConditioner.class)
- @XmlJavaTypeAdapter(value = CDataConditioner.class)
@XmlElement(required = true)
private String description;
@@ -299,9 +291,7 @@ public class AxKeyInfo extends AxConcept {
if (!uuid.equals(other.uuid)) {
return false;
}
- final String thisdesc = CDataConditioner.clean(description);
- final String otherdesc = CDataConditioner.clean(other.description);
- return thisdesc.equals(otherdesc);
+ return description.equals(description);
}
/**
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDao.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDao.java
deleted file mode 100644
index b84646038..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDao.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.dao;
-
-import java.util.Collection;
-import java.util.List;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
-
-/**
- * The Interface ApexDao describes the DAO interface for reading and writing Apex {@link AxConcept} concepts to and from
- * databases using JDBC.
- *
- * @author Sergey Sachkov
- * @author liam.fallon@ericsson.com
- */
-public interface ApexDao {
-
- /**
- * Initialize the Apex DAO with the given parameters.
- *
- * @param daoParameters parameters to use to access the database
- * @throws ApexException on initialization errors
- */
- void init(DaoParameters daoParameters) throws ApexException;
-
- /**
- * Close the Apex DAO.
- */
- void close();
-
- /**
- * Creates an Apex concept on the database.
- *
- * @param <T> the type of the object to create, a subclass of {@link AxConcept}
- * @param obj the object to create
- */
- <T extends AxConcept> void create(T obj);
-
- /**
- * Delete an Apex concept on the database.
- *
- * @param <T> the type of the object to delete, a subclass of {@link AxConcept}
- * @param obj the object to delete
- */
- <T extends AxConcept> void delete(T obj);
-
- /**
- * Delete an Apex concept on the database.
- *
- * @param <T> the type of the object to delete, a subclass of {@link AxConcept}
- * @param someClass the class of the object to delete, a subclass of {@link AxConcept}
- * @param key the key of the object to delete
- */
- <T extends AxConcept> void delete(Class<T> someClass, AxArtifactKey key);
-
- /**
- * Delete an Apex concept on the database.
- *
- * @param <T> the type of the object to delete, a subclass of {@link AxConcept}
- * @param someClass the class of the object to delete, a subclass of {@link AxConcept}
- * @param key the key of the object to delete
- */
- <T extends AxConcept> void delete(Class<T> someClass, AxReferenceKey key);
-
- /**
- * Create a collection of objects in the database.
- *
- * @param <T> the type of the object to create, a subclass of {@link AxConcept}
- * @param objs the objects to create
- */
- <T extends AxConcept> void createCollection(Collection<T> objs);
-
- /**
- * Delete a collection of objects in the database.
- *
- * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
- * @param objs the objects to delete
- */
- <T extends AxConcept> void deleteCollection(Collection<T> objs);
-
- /**
- * Delete a collection of objects in the database referred to by artifact key.
- *
- * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
- * @param someClass the class of the objects to delete, a subclass of {@link AxConcept}
- * @param keys the keys of the objects to delete
- * @return the number of objects deleted
- */
- <T extends AxConcept> int deleteByArtifactKey(Class<T> someClass, Collection<AxArtifactKey> keys);
-
- /**
- * Delete a collection of objects in the database referred to by reference key.
- *
- * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
- * @param someClass the class of the objects to delete, a subclass of {@link AxConcept}
- * @param keys the keys of the objects to delete
- * @return the number of objects deleted
- */
- <T extends AxConcept> int deleteByReferenceKey(Class<T> someClass, Collection<AxReferenceKey> keys);
-
- /**
- * Delete all objects of a given class in the database.
- *
- * @param <T> the type of the objects to delete, a subclass of {@link AxConcept}
- * @param someClass the class of the objects to delete, a subclass of {@link AxConcept}
- */
- <T extends AxConcept> void deleteAll(Class<T> someClass);
-
- /**
- * Get an object from the database, referred to by artifact key.
- *
- * @param <T> the type of the object to get, a subclass of {@link AxConcept}
- * @param someClass the class of the object to get, a subclass of {@link AxConcept}
- * @param key the key of the object to get
- * @return the object that was retrieved from the database
- */
- <T extends AxConcept> T get(Class<T> someClass, AxArtifactKey key);
-
- /**
- * Get an object from the database, referred to by reference key.
- *
- * @param <T> the type of the object to get, a subclass of {@link AxConcept}
- * @param someClass the class of the object to get, a subclass of {@link AxConcept}
- * @param key the key of the object to get
- * @return the object that was retrieved from the database or null if the object was not retrieved
- */
- <T extends AxConcept> T get(Class<T> someClass, AxReferenceKey key);
-
- /**
- * Get all the objects in the database of a given type.
- *
- * @param <T> the type of the objects to get, a subclass of {@link AxConcept}
- * @param someClass the class of the objects to get, a subclass of {@link AxConcept}
- * @return the objects or null if no objects were retrieved
- */
- <T extends AxConcept> List<T> getAll(Class<T> someClass);
-
- /**
- * Get all the objects in the database of the given type with the given parent artifact key.
- *
- * @param <T> the type of the objects to get, a subclass of {@link AxConcept}
- * @param someClass the class of the objects to get, a subclass of {@link AxConcept}
- * @param parentKey the parent key of the concepts to get
- * @return the all
- */
- <T extends AxConcept> List<T> getAll(Class<T> someClass, AxArtifactKey parentKey);
-
- /**
- * Get a concept from the database with the given artifact key.
- *
- * @param <T> the type of the object to get, a subclass of {@link AxConcept}
- * @param someClass the class of the object to get, a subclass of {@link AxConcept}
- * @param artifactId the artifact key of the concept to get
- * @return the concept that matches the key or null if the concept is not retrieved
- */
- <T extends AxConcept> T getArtifact(Class<T> someClass, AxArtifactKey artifactId);
-
- /**
- * Get a concept from the database with the given reference key.
- *
- * @param <T> the type of the object to get, a subclass of {@link AxConcept}
- * @param someClass the class of the object to get, a subclass of {@link AxConcept}
- * @param artifactId the artifact key of the concept to get
- * @return the concept that matches the key or null if the concept is not retrieved
- */
- <T extends AxConcept> T getArtifact(Class<T> someClass, AxReferenceKey artifactId);
-
- /**
- * Get the number of instances of a concept that exist in the database.
- *
- * @param <T> the type of the object to get, a subclass of {@link AxConcept}
- * @param someClass the class of the object to get, a subclass of {@link AxConcept}
- * @return the number of instances of the concept in the database
- */
- <T extends AxConcept> long size(Class<T> someClass);
-
- /**
- * Update a concept in the database.
- *
- * @param <T> the type of the object to get, a subclass of {@link AxConcept}
- * @param obj the object to update
- * @return the updated object
- */
- <T extends AxConcept> T update(T obj);
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDaoFactory.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDaoFactory.java
deleted file mode 100644
index fad3b08b9..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/ApexDaoFactory.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 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.apex.model.basicmodel.dao;
-
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.common.utils.validation.Assertions;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * This factory class returns an Apex DAO for the configured persistence mechanism. The factory uses the plugin class
- * specified in {@link DaoParameters} to instantiate a DAO instance.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ApexDaoFactory {
- // Get a reference to the logger
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexDaoFactory.class);
-
- /**
- * Return an Apex DAO for the required APEX DAO plugin class.
- *
- * @param daoParameters parameters to use to read the database configuration information
- * @return the Apex DAO
- * @throws ApexException on invalid JPA plugins
- */
- public ApexDao createApexDao(final DaoParameters daoParameters) throws ApexException {
- Assertions.argumentOfClassNotNull(daoParameters, ApexException.class,
- "Parameter \"daoParameters\" may not be null");
-
- // Get the class for the DAO using reflection
- Object apexDaoObject = null;
- try {
- apexDaoObject = Class.forName(daoParameters.getPluginClass()).getDeclaredConstructor().newInstance();
- } catch (final Exception e) {
- LOGGER.error("Apex DAO class not found for DAO plugin \"" + daoParameters.getPluginClass() + "\"", e);
- throw new ApexException(
- "Apex DAO class not found for DAO plugin \"" + daoParameters.getPluginClass() + "\"", e);
- }
-
- // Check the class is an Apex DAO
- if (!(apexDaoObject instanceof ApexDao)) {
- LOGGER.error("Specified Apex DAO plugin class \"" + daoParameters.getPluginClass()
- + "\" does not implement the ApexDao interface");
- throw new ApexException("Specified Apex DAO plugin class \"" + daoParameters.getPluginClass()
- + "\" does not implement the ApexDao interface");
- }
-
- return (ApexDao) apexDaoObject;
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/DaoParameters.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/DaoParameters.java
deleted file mode 100644
index c575bd7c0..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/DaoParameters.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.dao;
-
-import java.util.Properties;
-
-/**
- * This class is a POJO that holds properties for Apex DAOs.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class DaoParameters {
- /** The default Apex DAO plugin class. */
- public static final String DEFAULT_PLUGIN_CLASS = "org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao";
-
- private String pluginClass = DEFAULT_PLUGIN_CLASS;
- private String persistenceUnit;
-
- private Properties jdbcProperties = new Properties();
-
- /**
- * Gets the DAO plugin class, this is the DAO class to use and it must implement the {@link ApexDao} interface.
- *
- * @return the DAO plugin class
- */
- public String getPluginClass() {
- return pluginClass;
- }
-
- /**
- * Sets the DAO plugin class, a class that implements the {@link ApexDao} interface.
- *
- * @param daoPluginClass the DAO plugin class
- */
- public void setPluginClass(final String daoPluginClass) {
- pluginClass = daoPluginClass;
- }
-
- /**
- * Gets the persistence unit for the DAO. The persistence unit defines the JDBC properties the DAO will use. The
- * persistence unit must defined in the {@code META-INF/persistence.xml} resource file
- *
- * @return the persistence unit to use for JDBC access
- */
- public String getPersistenceUnit() {
- return persistenceUnit;
- }
-
- /**
- * Sets the persistence unit for the DAO. The persistence unit defines the JDBC properties the DAO will use. The
- * persistence unit must defined in the {@code META-INF/persistence.xml} resource file
- *
- * @param daoPersistenceUnit the persistence unit to use for JDBC access
- */
- public void setPersistenceUnit(final String daoPersistenceUnit) {
- persistenceUnit = daoPersistenceUnit;
- }
-
- /**
- * Gets the JDBC properties.
- *
- * @return the JDBC properties
- */
- public Properties getJdbcProperties() {
- return jdbcProperties;
- }
-
- /**
- * Sets the JDBC properties.
- *
- * @param jdbcProperties the JDBC properties
- */
- public void setJdbcProperties(final Properties jdbcProperties) {
- this.jdbcProperties = jdbcProperties;
- }
-
- /**
- * Gets a single JDBC property.
- *
- * @param key the key of the property
- * @return the JDBC property
- */
- public String getJdbcProperty(final String key) {
- return jdbcProperties.getProperty(key);
- }
-
- /**
- * Sets a single JDBC property.
- *
- * @param key the key of the property
- * @param value the value of the JDBC property
- */
- public void setJdbcProperty(final String key, final String value) {
- jdbcProperties.setProperty(key, value);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- return "DAOParameters [pluginClass=" + pluginClass + ", persistenceUnit=" + persistenceUnit
- + ", jdbcProperties=" + jdbcProperties + "]";
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/CDataConditioner.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/CDataConditioner.java
deleted file mode 100644
index 460714683..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/CDataConditioner.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.dao.converters;
-
-import javax.persistence.AttributeConverter;
-import javax.persistence.Converter;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-
-/**
- * The Class CDATAConditioner converts a CDATA String to and from database format by removing spaces at the ends of
- * lines and platform-specific new line endings.
- *
- * @author John Keeney (John.Keeney@ericsson.com)
- */
-@Converter
-public class CDataConditioner extends XmlAdapter<String, String> implements AttributeConverter<String, String> {
-
- private static final String NL = "\n";
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String convertToDatabaseColumn(final String raw) {
- return clean(raw);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String convertToEntityAttribute(final String db) {
- return clean(db);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String unmarshal(final String value) throws Exception {
- return this.convertToEntityAttribute(value);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String marshal(final String value) throws Exception {
- return this.convertToDatabaseColumn(value);
- }
-
- /**
- * Clean.
- *
- * @param in the in
- * @return the string
- */
- public static final String clean(final String in) {
- if (in == null) {
- return null;
- } else {
- return in.replaceAll("\\s+$", "").replaceAll("\\r?\\n", NL);
- }
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/Uuid2String.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/Uuid2String.java
deleted file mode 100644
index f5fffdb00..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/Uuid2String.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.dao.converters;
-
-import java.util.UUID;
-import javax.persistence.AttributeConverter;
-import javax.persistence.Converter;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-
-/**
- * The Class UUIDConverter converts a UUID to and from database format.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-@Converter
-public class Uuid2String extends XmlAdapter<String, UUID> implements AttributeConverter<UUID, String> {
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String convertToDatabaseColumn(final UUID uuid) {
- String returnString;
- if (uuid == null) {
- returnString = "";
- } else {
- returnString = uuid.toString();
- }
- return returnString;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public UUID convertToEntityAttribute(final String uuidString) {
- return UUID.fromString(uuidString);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public UUID unmarshal(final String value) throws Exception {
- return this.convertToEntityAttribute(value);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String marshal(final UUID value) throws Exception {
- return this.convertToDatabaseColumn(value);
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/package-info.java
deleted file mode 100644
index f1e9a3ba7..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/converters/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-/**
- * Contains converters used by APEX EclipseLink marshaling and unmarshaling of
- * {@link org.onap.policy.apex.model.basicmodel.concepts.AxConcept} instances to and from files and databases.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-
-package org.onap.policy.apex.model.basicmodel.dao.converters;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java
deleted file mode 100644
index 738d15ed3..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/DefaultApexDao.java
+++ /dev/null
@@ -1,497 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 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=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.dao.impl;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.policy.apex.model.basicmodel.dao.ApexDao;
-import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class DefaultApexDao is an JPA implementation of the {@link ApexDao} class for Apex concepts ({@link AxConcept}).
- * It uses the default JPA implementation in the javax {@link Persistence} class.
- *
- *
- * @author Sergey Sachkov (sergey.sachkov@ericsson.com)
- */
-public class DefaultApexDao implements ApexDao {
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(DefaultApexDao.class);
-
- private static final String COL_LOCALNAME = "local_name";
- private static final String COL_PARENT_VERSION = "parent_version";
- private static final String COL_PARENT_NAME = "parent_name";
- private static final String COL_VERSION = "key_version";
- private static final String COL_NAME = "key_name";
-
- private static final String SELECT_C_FROM = "SELECT c FROM ";
- private static final String AND_C_KEY_LOCAL_NAME = " AND c.key.localName=:" + COL_LOCALNAME;
- private static final String AND_C_KEY_PARENT_KEY_VERSION = " AND c.key.parentKeyVersion=:" + COL_PARENT_VERSION;
- private static final String C_WHERE_C_KEY_PARENT_KEY_NAME = " c WHERE c.key.parentKeyName=:" + COL_PARENT_NAME;
- private static final String AND_C_KEY_VERSION = " AND c.key.version=:" + COL_VERSION;
- private static final String C_WHERE_C_KEY_NAME = " c WHERE c.key.name=:" + COL_NAME;
- private static final String DELETE_FROM = "DELETE FROM ";
-
- // Entity manager for JPA
- private EntityManagerFactory emf = null;
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void init(final DaoParameters daoParameters) throws ApexException {
- if (daoParameters == null || daoParameters.getPersistenceUnit() == null) {
- LOGGER.error("Apex persistence unit parameter not set");
- throw new ApexException("Apex persistence unit parameter not set");
- }
-
- LOGGER.debug("Creating Apex persistence unit \"" + daoParameters.getPersistenceUnit() + "\" . . .");
- try {
- emf = Persistence.createEntityManagerFactory(daoParameters.getPersistenceUnit(),
- daoParameters.getJdbcProperties());
- } catch (final Exception e) {
- LOGGER.warn("Creation of Apex persistence unit \"" + daoParameters.getPersistenceUnit() + "\" failed", e);
- throw new ApexException(
- "Creation of Apex persistence unit \"" + daoParameters.getPersistenceUnit() + "\" failed", e);
- }
- LOGGER.debug("Created Apex persistence unit \"" + daoParameters.getPersistenceUnit() + "\"");
- }
-
- /**
- * Gets the entity manager for this DAO.
- *
- * @return the entity manager
- */
- protected final synchronized EntityManager getEntityManager() {
- if (emf == null) {
- LOGGER.warn("Apex DAO has not been initialized");
- throw new ApexRuntimeException("Apex DAO has not been initialized");
- }
-
- return emf.createEntityManager();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public final void close() {
- if (emf != null) {
- emf.close();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> void create(final T obj) {
- if (obj == null) {
- return;
- }
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- mg.merge(obj);
- mg.getTransaction().commit();
- } finally {
- mg.close();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> void delete(final T obj) {
- if (obj == null) {
- return;
- }
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- mg.remove(mg.contains(obj) ? obj : mg.merge(obj));
- mg.getTransaction().commit();
- } finally {
- mg.close();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> void delete(final Class<T> someClass, final AxArtifactKey key) {
- if (key == null) {
- return;
- }
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- mg.createQuery(DELETE_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_NAME + AND_C_KEY_VERSION, someClass)
- .setParameter(COL_NAME, key.getName())
- .setParameter(COL_VERSION, key.getVersion())
- .executeUpdate();
- mg.getTransaction().commit();
- } finally {
- mg.close();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> void delete(final Class<T> someClass, final AxReferenceKey key) {
- if (key == null) {
- return;
- }
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- mg.createQuery(DELETE_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME
- + AND_C_KEY_PARENT_KEY_VERSION
- + AND_C_KEY_LOCAL_NAME, someClass)
- .setParameter(COL_PARENT_NAME, key.getParentKeyName())
- .setParameter(COL_PARENT_VERSION, key.getParentKeyVersion())
- .setParameter(COL_LOCALNAME, key.getLocalName())
- .executeUpdate();
- mg.getTransaction().commit();
- } finally {
- mg.close();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> void createCollection(final Collection<T> objs) {
- if (objs == null || objs.isEmpty()) {
- return;
- }
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- for (final T t : objs) {
- mg.merge(t);
- }
- mg.getTransaction().commit();
- } finally {
- mg.close();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> void deleteCollection(final Collection<T> objs) {
- if (objs == null || objs.isEmpty()) {
- return;
- }
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- for (final T t : objs) {
- mg.remove(mg.contains(t) ? t : mg.merge(t));
- }
- mg.getTransaction().commit();
- } finally {
- mg.close();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> int deleteByArtifactKey(final Class<T> someClass,
- final Collection<AxArtifactKey> keys) {
- if (keys == null || keys.isEmpty()) {
- return 0;
- }
- int deletedCount = 0;
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- for (final AxArtifactKey key : keys) {
- deletedCount += mg.createQuery(DELETE_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_NAME
- + AND_C_KEY_VERSION, someClass)
- .setParameter(COL_NAME, key.getName())
- .setParameter(COL_VERSION, key.getVersion())
- .executeUpdate();
- }
- mg.getTransaction().commit();
- } finally {
- mg.close();
- }
- return deletedCount;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> int deleteByReferenceKey(final Class<T> someClass,
- final Collection<AxReferenceKey> keys) {
- if (keys == null || keys.isEmpty()) {
- return 0;
- }
- int deletedCount = 0;
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- for (final AxReferenceKey key : keys) {
- deletedCount +=
- mg.createQuery(
- DELETE_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME
- + AND_C_KEY_PARENT_KEY_VERSION + AND_C_KEY_LOCAL_NAME, someClass)
- .setParameter(COL_PARENT_NAME, key.getParentKeyName())
- .setParameter(COL_PARENT_VERSION, key.getParentKeyVersion())
- .setParameter(COL_LOCALNAME, key.getLocalName())
- .executeUpdate();
- }
- mg.getTransaction().commit();
- } finally {
- mg.close();
- }
- return deletedCount;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> void deleteAll(final Class<T> someClass) {
- final EntityManager mg = getEntityManager();
- try {
- mg.getTransaction().begin();
- mg.createQuery(DELETE_FROM + someClass.getSimpleName() + " c ", someClass).executeUpdate();
- mg.getTransaction().commit();
- } finally {
- mg.close();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> T get(final Class<T> someClass, final AxArtifactKey key) {
- if (someClass == null) {
- return null;
- }
- final EntityManager mg = getEntityManager();
- try {
- final T t = mg.find(someClass, key);
- if (t != null) {
- // This clone is created to force the JPA DAO to recurse down through the object
- try {
- final T clonedT = someClass.getDeclaredConstructor().newInstance();
- t.copyTo(clonedT);
- return clonedT;
- } catch (final Exception e) {
- LOGGER.warn("Could not clone object of class \"" + someClass.getName() + "\"", e);
- return null;
- }
- } else {
- return null;
- }
- } finally {
- mg.close();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> T get(final Class<T> someClass, final AxReferenceKey key) {
- if (someClass == null) {
- return null;
- }
- final EntityManager mg = getEntityManager();
- try {
- final T t = mg.find(someClass, key);
- if (t != null) {
- try {
- final T clonedT = someClass.getDeclaredConstructor().newInstance();
- t.copyTo(clonedT);
- return clonedT;
- } catch (final Exception e) {
- LOGGER.warn("Could not clone object of class \"" + someClass.getName() + "\"", e);
- return null;
- }
- } else {
- return null;
- }
- } finally {
- mg.close();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> List<T> getAll(final Class<T> someClass) {
- if (someClass == null) {
- return Collections.emptyList();
- }
- final EntityManager mg = getEntityManager();
- try {
- return mg.createQuery(SELECT_C_FROM + someClass.getSimpleName() + " c", someClass).getResultList();
- } finally {
- mg.close();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> List<T> getAll(final Class<T> someClass, final AxArtifactKey parentKey) {
- if (someClass == null) {
- return Collections.emptyList();
- }
- final EntityManager mg = getEntityManager();
- try {
- return mg
- .createQuery(
- SELECT_C_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME
- + AND_C_KEY_PARENT_KEY_VERSION, someClass)
- .setParameter(COL_PARENT_NAME, parentKey.getName())
- .setParameter(COL_PARENT_VERSION, parentKey.getVersion())
- .getResultList();
- } finally {
- mg.close();
- }
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> T getArtifact(final Class<T> someClass, final AxArtifactKey key) {
- if (someClass == null || key == null) {
- return null;
- }
- final EntityManager mg = getEntityManager();
- List<T> ret;
- try {
- ret = mg.createQuery(SELECT_C_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_NAME
- + AND_C_KEY_VERSION, someClass)
- .setParameter(COL_NAME, key.getName())
- .setParameter(COL_VERSION, key.getVersion())
- .getResultList();
- } finally {
- mg.close();
- }
- if (ret == null || ret.isEmpty()) {
- return null;
- }
- if (ret.size() > 1) {
- throw new IllegalArgumentException("More than one result was returned for search for " + someClass
- + " with key " + key.getId() + ": " + ret);
- }
- return ret.get(0);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> T getArtifact(final Class<T> someClass, final AxReferenceKey key) {
- if (someClass == null || key == null) {
- return null;
- }
- final EntityManager mg = getEntityManager();
- List<T> ret;
- try {
- ret = mg.createQuery(SELECT_C_FROM + someClass.getSimpleName() + C_WHERE_C_KEY_PARENT_KEY_NAME
- + AND_C_KEY_PARENT_KEY_VERSION + AND_C_KEY_LOCAL_NAME, someClass)
- .setParameter(COL_PARENT_NAME, key.getParentKeyName())
- .setParameter(COL_PARENT_VERSION, key.getParentKeyVersion())
- .setParameter(COL_LOCALNAME, key.getLocalName())
- .getResultList();
- } finally {
- mg.close();
- }
- if (ret == null || ret.isEmpty()) {
- return null;
- }
- if (ret.size() > 1) {
- throw new IllegalArgumentException("More than one result was returned for search for " + someClass
- + " with key " + key.getId() + ": " + ret);
- }
- return ret.get(0);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> T update(final T obj) {
- final EntityManager mg = getEntityManager();
- T ret;
- try {
- mg.getTransaction().begin();
- ret = mg.merge(obj);
- mg.flush();
- mg.getTransaction().commit();
- } finally {
- mg.close();
- }
- return ret;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public <T extends AxConcept> long size(final Class<T> someClass) {
- if (someClass == null) {
- return 0;
- }
- final EntityManager mg = getEntityManager();
- long size = 0;
- try {
- size = mg.createQuery("SELECT COUNT(c) FROM " + someClass.getSimpleName() + " c", Long.class)
- .getSingleResult();
- } finally {
- mg.close();
- }
- return size;
- }
-}
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/package-info.java
deleted file mode 100644
index 5d585c247..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/impl/package-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-/**
- * Contains a default DAO implementation for APEX {@link org.onap.policy.apex.model.basicmodel.concepts.AxConcept}
- * classes that uses javax persistence.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-package org.onap.policy.apex.model.basicmodel.dao.impl;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/package-info.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/package-info.java
deleted file mode 100644
index 505e4023a..000000000
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/dao/package-info.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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=========================================================
- */
-
-/**
- * Defines and implements the Data Access Object (DAO) that allows Apex
- * {@link org.onap.policy.apex.model.basicmodel.concepts.AxConcept} concepts to be read from and written to databases
- * over JDBC.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-
-package org.onap.policy.apex.model.basicmodel.dao;
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
index 36ce4e438..5dbf69492 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,8 +27,6 @@ import java.io.File;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.basicmodel.dao.ApexDaoFactory;
-import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelFileWriter;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelWriter;
@@ -174,29 +172,6 @@ public class TestApexModel<M extends AxModel> {
}
/**
- * Test write and read of an Apex model to database using JPA.
- *
- * @param daoParameters the DAO parameters to use for JPA/JDBC
- * @throws ApexException thrown on errors writing or reading the model to database
- */
- public final void testApexModelWriteReadJpa(final DaoParameters daoParameters) throws ApexException {
- LOGGER.debug("running testApexModelWriteReadJPA . . .");
-
- final var model = modelCreator.getModel();
-
- final var apexDao = new ApexDaoFactory().createApexDao(daoParameters);
- apexDao.init(daoParameters);
-
- apexDao.create(model);
- final var dbJpaModel = apexDao.get(rootModelClass, model.getKey());
- apexDao.close();
-
- checkModelEquality(model, dbJpaModel, "test model does not equal model written and read using generic JPA");
-
- LOGGER.debug("ran testApexModelWriteReadJPA");
- }
-
- /**
* Test that an Apex model is valid.
*
* @return the result of the validation
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java
index d066d674c..0c7edee28 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,10 +65,11 @@ public class AxKeyInfoTest {
assertEquals(testKeyInfo, testKeyInfo); // NOSONAR
assertEquals(testKeyInfo, clonedReferenceKey);
assertNotNull(testKeyInfo);
- assertNotEquals(testKeyInfo, (Object) new AxArtifactKey());
+ Object differentKeyType = new AxArtifactKey();
+ assertNotEquals(testKeyInfo, differentKeyType);
assertNotEquals(testKeyInfo, new AxKeyInfo(new AxArtifactKey()));
assertNotEquals(testKeyInfo, new AxKeyInfo(key, UUID.randomUUID(), "Some Description"));
- assertNotEquals(testKeyInfo, new AxKeyInfo(key, uuid, "Some Description"));
+ assertEquals(testKeyInfo, new AxKeyInfo(key, uuid, "Some Other Description"));
assertEquals(testKeyInfo, new AxKeyInfo(key, uuid, "Key Description"));
assertEquals(0, testKeyInfo.compareTo(testKeyInfo));
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/DaoMiscTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/DaoMiscTest.java
deleted file mode 100644
index 6f9bef83d..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/DaoMiscTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 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.apex.model.basicmodel.dao;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import java.util.Properties;
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.dao.converters.CDataConditioner;
-import org.onap.policy.apex.model.basicmodel.dao.converters.Uuid2String;
-
-public class DaoMiscTest {
-
- @Test
- public void testUuid2StringMopUp() {
- final Uuid2String uuid2String = new Uuid2String();
- assertEquals("", uuid2String.convertToDatabaseColumn(null));
- }
-
- @Test
- public void testCDataConditionerMopUp() {
- assertNull(CDataConditioner.clean(null));
- }
-
- @Test
- public void testDaoFactory() {
- final DaoParameters daoParameters = new DaoParameters();
-
- daoParameters.setPluginClass("somewhere.over.the.rainbow");
- assertThatThrownBy(() -> new ApexDaoFactory().createApexDao(daoParameters))
- .hasMessage("Apex DAO class not found for DAO plugin \"somewhere.over.the.rainbow\"");
- daoParameters.setPluginClass("java.lang.String");
- assertThatThrownBy(() -> new ApexDaoFactory().createApexDao(daoParameters))
- .hasMessage("Specified Apex DAO plugin class \"java.lang.String\" "
- + "does not implement the ApexDao interface");
- }
-
- @Test
- public void testDaoParameters() {
- final DaoParameters pars = new DaoParameters();
- pars.setJdbcProperties(new Properties());
- assertEquals(0, pars.getJdbcProperties().size());
-
- pars.setJdbcProperty("name", "Dorothy");
- assertEquals("Dorothy", pars.getJdbcProperty("name"));
-
- pars.setPersistenceUnit("Kansas");
- assertEquals("Kansas", pars.getPersistenceUnit());
-
- pars.setPluginClass("somewhere.over.the.rainbow");
- assertEquals("somewhere.over.the.rainbow", pars.getPluginClass());
-
- assertEquals("DAOParameters [pluginClass=somewhere.over.the.rainbow, "
- + "persistenceUnit=Kansas, jdbcProperties={name=Dorothy}]", pars.toString());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
deleted file mode 100644
index e584085c3..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 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.apex.model.basicmodel.dao;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-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.List;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.UUID;
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.policy.apex.model.basicmodel.concepts.DummyEntity;
-
-/**
- * JUnit test class.
- */
-public class EntityTest {
- private ApexDao apexDao;
-
- @Test
- public void testEntityTestSanity() throws ApexException {
- final DaoParameters daoParameters = new DaoParameters();
-
- apexDao = new ApexDaoFactory().createApexDao(daoParameters);
-
- assertThatThrownBy(() -> apexDao.init(null))
- .hasMessage("Apex persistence unit parameter not set");
- assertThatThrownBy(() -> apexDao.init(daoParameters))
- .hasMessage("Apex persistence unit parameter not set");
- daoParameters.setPluginClass("somewhere.over.the.rainbow");
- daoParameters.setPersistenceUnit("Dorothy");
- assertThatThrownBy(() -> apexDao.init(daoParameters))
- .hasMessage("Creation of Apex persistence unit \"Dorothy\" failed");
- assertThatThrownBy(() -> apexDao.create(new AxArtifactKey()))
- .hasMessage("Apex DAO has not been initialized");
- apexDao.close();
- }
-
- @Test
- public void testEntityTestAllOpsJpa() throws ApexException {
- final DaoParameters daoParameters = new DaoParameters();
- daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
- daoParameters.setPersistenceUnit("DaoTest");
-
- apexDao = new ApexDaoFactory().createApexDao(daoParameters);
- apexDao.init(daoParameters);
-
- testAllOps();
- apexDao.close();
- }
-
- @Test
- public void testEntityTestBadVals() throws ApexException {
- final DaoParameters daoParameters = new DaoParameters();
- assertNotNull(daoParameters);
- daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
- assertEquals("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao", daoParameters.getPluginClass());
- daoParameters.setPersistenceUnit("DaoTest");
- assertEquals("DaoTest", daoParameters.getPersistenceUnit());
-
- apexDao = new ApexDaoFactory().createApexDao(daoParameters);
- apexDao.init(daoParameters);
-
- final AxArtifactKey nullKey = null;
- final AxReferenceKey nullRefKey = null;
- final List<AxArtifactKey> nullKeyList = null;
- final List<AxArtifactKey> emptyKeyList = new ArrayList<>();
- final List<AxReferenceKey> nullRKeyList = null;
- final List<AxReferenceKey> emptyRKeyList = new ArrayList<>();
-
- apexDao.create(nullKey);
- apexDao.createCollection(nullKeyList);
- apexDao.createCollection(emptyKeyList);
-
- apexDao.delete(nullKey);
- apexDao.deleteCollection(nullKeyList);
- apexDao.deleteCollection(emptyKeyList);
- apexDao.delete(AxArtifactKey.class, nullKey);
- apexDao.delete(AxReferenceKey.class, nullRefKey);
- apexDao.deleteByArtifactKey(AxArtifactKey.class, nullKeyList);
- apexDao.deleteByArtifactKey(AxArtifactKey.class, emptyKeyList);
- apexDao.deleteByReferenceKey(AxReferenceKey.class, nullRKeyList);
- apexDao.deleteByReferenceKey(AxReferenceKey.class, emptyRKeyList);
-
- apexDao.get(null, nullKey);
- apexDao.get(null, nullRefKey);
- apexDao.getAll(null);
- apexDao.getAll(null, nullKey);
- apexDao.getArtifact(null, nullKey);
- apexDao.getArtifact(AxArtifactKey.class, nullKey);
- apexDao.getArtifact(null, nullRefKey);
- apexDao.getArtifact(AxReferenceKey.class, nullRefKey);
- apexDao.size(null);
-
- apexDao.close();
- }
-
- private void testAllOps() {
- final AxArtifactKey aKey0 = new AxArtifactKey("A-KEY0", "0.0.1");
- final AxArtifactKey aKey1 = new AxArtifactKey("A-KEY1", "0.0.1");
- final AxArtifactKey aKey2 = new AxArtifactKey("A-KEY2", "0.0.1");
- final AxKeyInfo keyInfo0 = new AxKeyInfo(aKey0, UUID.fromString("00000000-0000-0000-0000-000000000000"),
- "key description 0");
- final AxKeyInfo keyInfo1 = new AxKeyInfo(aKey1, UUID.fromString("00000000-0000-0000-0000-000000000001"),
- "key description 1");
- final AxKeyInfo keyInfo2 = new AxKeyInfo(aKey2, UUID.fromString("00000000-0000-0000-0000-000000000002"),
- "key description 2");
-
- apexDao.create(keyInfo0);
-
- final AxKeyInfo keyInfoBack0 = apexDao.get(AxKeyInfo.class, aKey0);
- assertEquals(keyInfo0, keyInfoBack0);
-
- final AxKeyInfo keyInfoBackNull = apexDao.get(AxKeyInfo.class, AxArtifactKey.getNullKey());
- assertNull(keyInfoBackNull);
-
- final AxKeyInfo keyInfoBack1 = apexDao.getArtifact(AxKeyInfo.class, aKey0);
- assertEquals(keyInfoBack0, keyInfoBack1);
-
- final AxKeyInfo keyInfoBack2 = apexDao.getArtifact(AxKeyInfo.class, new AxArtifactKey("A-KEY3", "0.0.1"));
- assertNull(keyInfoBack2);
-
- final Set<AxKeyInfo> keyInfoSetIn = new TreeSet<AxKeyInfo>();
- keyInfoSetIn.add(keyInfo1);
- keyInfoSetIn.add(keyInfo2);
-
- apexDao.createCollection(keyInfoSetIn);
-
- Set<AxKeyInfo> keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
-
- keyInfoSetIn.add(keyInfo0);
- assertEquals(keyInfoSetIn, keyInfoSetOut);
-
- apexDao.delete(keyInfo1);
- keyInfoSetIn.remove(keyInfo1);
- keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
- assertEquals(keyInfoSetIn, keyInfoSetOut);
-
- apexDao.deleteCollection(keyInfoSetIn);
- keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
- assertEquals(0, keyInfoSetOut.size());
-
- keyInfoSetIn.add(keyInfo0);
- keyInfoSetIn.add(keyInfo1);
- keyInfoSetIn.add(keyInfo0);
- apexDao.createCollection(keyInfoSetIn);
- keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
- assertEquals(keyInfoSetIn, keyInfoSetOut);
-
- apexDao.delete(AxKeyInfo.class, aKey0);
- keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
- assertEquals(2, keyInfoSetOut.size());
- assertEquals(2, apexDao.size(AxKeyInfo.class));
-
- final Set<AxArtifactKey> keySetIn = new TreeSet<AxArtifactKey>();
- keySetIn.add(aKey1);
- keySetIn.add(aKey2);
-
- final int deletedCount = apexDao.deleteByArtifactKey(AxKeyInfo.class, keySetIn);
- assertEquals(2, deletedCount);
-
- keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
- assertEquals(0, keyInfoSetOut.size());
-
- keyInfoSetIn.add(keyInfo0);
- keyInfoSetIn.add(keyInfo1);
- keyInfoSetIn.add(keyInfo0);
- apexDao.createCollection(keyInfoSetIn);
- keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
- assertEquals(keyInfoSetIn, keyInfoSetOut);
-
- apexDao.deleteAll(AxKeyInfo.class);
- assertEquals(0, apexDao.size(AxKeyInfo.class));
-
- final AxArtifactKey owner0Key = new AxArtifactKey("Owner0", "0.0.1");
- final AxArtifactKey owner1Key = new AxArtifactKey("Owner1", "0.0.1");
- final AxArtifactKey owner2Key = new AxArtifactKey("Owner2", "0.0.1");
- final AxArtifactKey owner3Key = new AxArtifactKey("Owner3", "0.0.1");
- final AxArtifactKey owner4Key = new AxArtifactKey("Owner4", "0.0.1");
- final AxArtifactKey owner5Key = new AxArtifactKey("Owner5", "0.0.1");
-
- apexDao.create(new DummyEntity(new AxReferenceKey(owner0Key, "Entity0"), 100.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner0Key, "Entity1"), 101.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner0Key, "Entity2"), 102.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner0Key, "Entity3"), 103.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner0Key, "Entity4"), 104.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner1Key, "Entity5"), 105.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner1Key, "Entity6"), 106.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner1Key, "Entity7"), 107.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner2Key, "Entity8"), 108.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner2Key, "Entity9"), 109.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner3Key, "EntityA"), 110.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner4Key, "EntityB"), 111.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner5Key, "EntityC"), 112.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner5Key, "EntityD"), 113.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner5Key, "EntityE"), 114.0));
- apexDao.create(new DummyEntity(new AxReferenceKey(owner5Key, "EntityF"), 115.0));
-
- TreeSet<DummyEntity> testEntitySetOut = new TreeSet<DummyEntity>(apexDao.getAll(DummyEntity.class));
- assertEquals(16, testEntitySetOut.size());
-
- testEntitySetOut = new TreeSet<DummyEntity>(apexDao.getAll(DummyEntity.class, owner0Key));
- assertEquals(5, testEntitySetOut.size());
-
- testEntitySetOut = new TreeSet<DummyEntity>(apexDao.getAll(DummyEntity.class, owner1Key));
- assertEquals(3, testEntitySetOut.size());
-
- testEntitySetOut = new TreeSet<DummyEntity>(apexDao.getAll(DummyEntity.class, owner2Key));
- assertEquals(2, testEntitySetOut.size());
-
- testEntitySetOut = new TreeSet<DummyEntity>(apexDao.getAll(DummyEntity.class, owner3Key));
- assertEquals(1, testEntitySetOut.size());
-
- testEntitySetOut = new TreeSet<DummyEntity>(apexDao.getAll(DummyEntity.class, owner4Key));
- assertEquals(1, testEntitySetOut.size());
-
- testEntitySetOut = new TreeSet<DummyEntity>(apexDao.getAll(DummyEntity.class, owner5Key));
- assertEquals(4, testEntitySetOut.size());
-
- assertNotNull(apexDao.get(DummyEntity.class, new AxReferenceKey(owner0Key, "Entity0")));
- assertNotNull(apexDao.getArtifact(DummyEntity.class, new AxReferenceKey(owner0Key, "Entity0")));
- assertNull(apexDao.get(DummyEntity.class, new AxReferenceKey(owner0Key, "Entity1000")));
- assertNull(apexDao.getArtifact(DummyEntity.class, new AxReferenceKey(owner0Key, "Entity1000")));
- apexDao.delete(DummyEntity.class, new AxReferenceKey(owner0Key, "Entity0"));
-
- final Set<AxReferenceKey> rKeySetIn = new TreeSet<AxReferenceKey>();
- rKeySetIn.add(new AxReferenceKey(owner4Key, "EntityB"));
- rKeySetIn.add(new AxReferenceKey(owner5Key, "EntityD"));
-
- final int deletedRCount = apexDao.deleteByReferenceKey(DummyEntity.class, rKeySetIn);
- assertEquals(2, deletedRCount);
-
- apexDao.update(new DummyEntity(new AxReferenceKey(owner5Key, "EntityF"), 120.0));
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
index 1c21b6c33..bb9776fc7 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2022 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,10 +28,45 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
public class SupportApexBasicModelTest {
+ // As there are no real concepts in a basic model, this is as near to a valid model as we can get
+ private static final String VALID_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
+ + "AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
+ + ".AxModel:WARNING:key not found for key information entry\n"
+ + "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
+ + ".AxModel:WARNING:key not found for key information entry\n" + "********************************";
+
+ private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
+ + "AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
+ + ".AxModel:WARNING:key not found for key information entry\n"
+ + "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
+ + ".AxModel:WARNING:key not found for key information entry\n"
+ + "AxArtifactKey:(name=Unref0,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
+ + ".AxModel:WARNING:key not found for key information entry\n"
+ + "AxArtifactKey:(name=Unref1,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
+ + ".AxModel:WARNING:key not found for key information entry\n" + "********************************";
+
+ private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
+ + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
+ + "AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
+ + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
+ + "AxKeyInfo:OBSERVATION:description is blank\n"
+ + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
+ + "AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
+ + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
+ + "AxKeyInformation:INVALID:duplicate UUID found on keyInfoMap entry AxArtifactKey:"
+ + "(name=KeyInfoMapKey,version=0.0.1):00000000-0000-0000-0000-000000000000\n"
+ + "********************************";
+
+ private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
+ + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
+ + "AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
+ + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
+ + "AxModel:INVALID:key information not found for key "
+ + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)\n" + "********************************";
+
TestApexModel<AxModel> testApexModel;
/**
@@ -83,49 +118,4 @@ public class SupportApexBasicModelTest {
public void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
-
- @Test
- public void testModelWriteReadJpa() throws Exception {
- final DaoParameters daoParameters = new DaoParameters();
- daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
- daoParameters.setPersistenceUnit("DaoTest");
-
- testApexModel.testApexModelWriteReadJpa(daoParameters);
- }
-
- // As there are no real concepts in a basic model, this is as near to a valid model as we can get
- private static final String VALID_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
- + "AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
- + ".AxModel:WARNING:key not found for key information entry\n"
- + "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
- + ".AxModel:WARNING:key not found for key information entry\n" + "********************************";
-
- private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
- + "AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
- + ".AxModel:WARNING:key not found for key information entry\n"
- + "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
- + ".AxModel:WARNING:key not found for key information entry\n"
- + "AxArtifactKey:(name=Unref0,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
- + ".AxModel:WARNING:key not found for key information entry\n"
- + "AxArtifactKey:(name=Unref1,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
- + ".AxModel:WARNING:key not found for key information entry\n" + "********************************";
-
- private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
- + "AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
- + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
- + "AxKeyInfo:OBSERVATION:description is blank\n"
- + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
- + "AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
- + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
- + "AxKeyInformation:INVALID:duplicate UUID found on keyInfoMap entry AxArtifactKey:"
- + "(name=KeyInfoMapKey,version=0.0.1):00000000-0000-0000-0000-000000000000\n"
- + "********************************";
-
- private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
- + "AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
- + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
- + "AxModel:INVALID:key information not found for key "
- + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)\n" + "********************************";
}
diff --git a/model/basic-model/src/test/resources/META-INF/persistence.xml b/model/basic-model/src/test/resources/META-INF/persistence.xml
deleted file mode 100644
index 01a8989bb..000000000
--- a/model/basic-model/src/test/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- Copyright (C) 2016-2018 Ericsson. 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="DaoTest" transaction-type="RESOURCE_LOCAL">
- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
-
- <class>org.onap.policy.apex.model.basicmodel.dao.converters.CDataConditioner</class>
- <class>org.onap.policy.apex.model.basicmodel.dao.converters.Uuid2String</class>
- <class>org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey</class>
- <class>org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey</class>
- <class>org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo</class>
- <class>org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation</class>
- <class>org.onap.policy.apex.model.basicmodel.concepts.AxModel</class>
- <class>org.onap.policy.apex.model.basicmodel.concepts.DummyEntity</class>
-
- <properties>
- <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
- <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
- <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" />
- </properties>
- </persistence-unit>
-</persistence>