aboutsummaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to '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
-rw-r--r--model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java17
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java90
-rw-r--r--model/context-model/src/test/resources/META-INF/persistence.xml48
-rw-r--r--model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java40
-rw-r--r--model/engine-model/src/test/resources/META-INF/persistence.xml69
-rw-r--r--model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java116
-rw-r--r--model/event-model/src/test/resources/META-INF/persistence.xml54
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModel.java27
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java22
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java115
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java36
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java13
-rw-r--r--model/model-api/src/test/resources/META-INF/persistence.xml67
-rw-r--r--model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java10
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java116
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java56
-rw-r--r--model/policy-model/src/test/resources/META-INF/persistence.xml67
-rw-r--r--model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt3
-rw-r--r--model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt2
-rw-r--r--model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt7
-rw-r--r--model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt16
37 files changed, 255 insertions, 2386 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>
diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
index 37f44ba49..def22f434 100644
--- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java
+++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.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");
@@ -24,7 +24,6 @@ package org.onap.policy.apex.model.contextmodel.concepts;
import java.util.List;
import javax.persistence.Column;
-import javax.persistence.Convert;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
@@ -33,7 +32,6 @@ 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 lombok.AccessLevel;
import lombok.Getter;
import lombok.ToString;
@@ -43,7 +41,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.apex.model.basicmodel.dao.converters.CDataConditioner;
import org.onap.policy.common.utils.validation.Assertions;
/**
@@ -99,8 +96,6 @@ public class AxContextSchema extends AxConcept {
private String schemaFlavour;
@Column(name = "schemaDefinition", length = MAX_SCHEMA_SIZE)
- @Convert(converter = CDataConditioner.class)
- @XmlJavaTypeAdapter(value = CDataConditioner.class)
@XmlElement(name = "schemaDefinition", required = true)
@Getter(AccessLevel.NONE)
private String schemaDefinition;
@@ -270,7 +265,7 @@ public class AxContextSchema extends AxConcept {
result = prime * result + key.hashCode();
result = prime * result + schemaFlavour.hashCode();
- final String thisSchema = CDataConditioner.clean(schemaDefinition).replace("\n", "");
+ final String thisSchema = schemaDefinition.replace("\n", "");
result = prime * result + thisSchema.hashCode();
return result;
}
@@ -299,9 +294,7 @@ public class AxContextSchema extends AxConcept {
if (!schemaFlavour.equals(other.schemaFlavour)) {
return false;
}
- final String thisSchema = CDataConditioner.clean(schemaDefinition).replace("\n", "");
- final String otherSchema = CDataConditioner.clean(other.schemaDefinition).replace("\n", "");
- return thisSchema.equals(otherSchema);
+ return schemaDefinition.equals(other.schemaDefinition);
}
/**
@@ -326,8 +319,6 @@ public class AxContextSchema extends AxConcept {
if (!schemaFlavour.equals(other.schemaFlavour)) {
return schemaFlavour.compareTo(other.schemaFlavour);
}
- final String thisSchema = CDataConditioner.clean(schemaDefinition).replace("\n", "");
- final String otherSchema = CDataConditioner.clean(other.schemaDefinition).replace("\n", "");
- return thisSchema.compareTo(otherSchema);
+ return schemaDefinition.compareTo(other.schemaDefinition);
}
}
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
index 89a108ad8..a18065ed9 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 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.
@@ -26,7 +26,6 @@ import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
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;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
@@ -37,6 +36,45 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
*
*/
public class ApexContextModelTest {
+
+ private static final String VALID_MODEL_STRING = "***validation of model successful***";
+
+ private static final String OBSERVATION_MODEL_STRING = "\n"
+ + "***observations noted during validation of model***\n"
+ + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
+ + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:OBSERVATION:description is blank\n"
+ + "********************************";
+
+ private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
+ + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
+ + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:"
+ + "UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
+ + "********************************";
+
+ private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
+ + "AxArtifactKey:(name=StringType,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema:INVALID:"
+ + "no schemaDefinition specified, schemaDefinition may not be blank\n"
+ + "AxArtifactKey:(name=contextAlbum0,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:"
+ + "scope is not defined\n" + "********************************";
+
+ private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
+ + "AxArtifactKey:(name=ContextModel,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:INVALID:"
+ + "key information not found for key AxArtifactKey:(name=contextAlbum1,version=0.0.2)\n"
+ + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:WARNING:"
+ + "key not found for key information entry\n" + "AxArtifactKey:(name=ContextSchemas,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas:INVALID:"
+ + "key on schemas entry AxArtifactKey:(name=MapType,version=0.0.1) "
+ + "does not equal entry key AxArtifactKey:(name=MapType,version=0.0.2)\n"
+ + "AxArtifactKey:(name=contextAlbums,version=0.0.1):"
+ + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:INVALID:"
+ + "key on context album entry key AxArtifactKey:(name=contextAlbum1,version=0.0.1) "
+ + "does not equal context album value key AxArtifactKey:(name=contextAlbum1,version=0.0.2)\n"
+ + "********************************";
+
TestApexModel<AxContextModel> testApexModel;
/**
@@ -88,52 +126,4 @@ public class ApexContextModelTest {
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);
- }
-
- private static final String VALID_MODEL_STRING = "***validation of model successful***";
-
- private static final String OBSERVATION_MODEL_STRING = "\n"
- + "***observations noted during validation of model***\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
- + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:OBSERVATION:description is blank\n"
- + "********************************";
-
- private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
- + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:"
- + "UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
- + "********************************";
-
- private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=StringType,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema:INVALID:"
- + "no schemaDefinition specified, schemaDefinition may not be blank\n"
- + "AxArtifactKey:(name=contextAlbum0,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:"
- + "scope is not defined\n" + "********************************";
-
- private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=ContextModel,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=contextAlbum1,version=0.0.2)\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:WARNING:"
- + "key not found for key information entry\n" + "AxArtifactKey:(name=ContextSchemas,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas:INVALID:"
- + "key on schemas entry AxArtifactKey:(name=MapType,version=0.0.1) "
- + "does not equal entry key AxArtifactKey:(name=MapType,version=0.0.2)\n"
- + "AxArtifactKey:(name=contextAlbums,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:INVALID:"
- + "key on context album entry key AxArtifactKey:(name=contextAlbum1,version=0.0.1) "
- + "does not equal context album value key AxArtifactKey:(name=contextAlbum1,version=0.0.2)\n"
- + "********************************";
-
}
diff --git a/model/context-model/src/test/resources/META-INF/persistence.xml b/model/context-model/src/test/resources/META-INF/persistence.xml
deleted file mode 100644
index b4ba68a38..000000000
--- a/model/context-model/src/test/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,48 +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.AxConcept</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.TestEntity</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextModel</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>
diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
index 063424b3d..8baa59b2f 100644
--- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
+++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 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.
@@ -26,11 +26,24 @@ import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
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;
import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
public class ApexEngineModelTest {
+ private static final String VALID_MODEL_STRING = "***validation of model successful***";
+
+ private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
+ + "AxArtifactKey:(name=AnEngine,version=0.0.1):"
+ + "org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel:INVALID:"
+ + "AxEngineModel - state is UNDEFINED\n" + "********************************";
+
+ private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
+ + "AxArtifactKey:(name=AnEngine,version=0.0.1):"
+ + "org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel:INVALID:"
+ + "AxEngineModel - timestamp is not set\n" + "AxArtifactKey:(name=AnEngine,version=0.0.1):"
+ + "org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel:INVALID:"
+ + "AxEngineModel - state is UNDEFINED\n" + "********************************";
+
TestApexModel<AxEngineModel> testApexModel;
/**
@@ -70,27 +83,4 @@ public class ApexEngineModelTest {
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);
- }
-
- private static final String VALID_MODEL_STRING = "***validation of model successful***";
-
- private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=AnEngine,version=0.0.1):"
- + "org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel:INVALID:"
- + "AxEngineModel - state is UNDEFINED\n" + "********************************";
-
- private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=AnEngine,version=0.0.1):"
- + "org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel:INVALID:"
- + "AxEngineModel - timestamp is not set\n" + "AxArtifactKey:(name=AnEngine,version=0.0.1):"
- + "org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel:INVALID:"
- + "AxEngineModel - state is UNDEFINED\n" + "********************************";
}
diff --git a/model/engine-model/src/test/resources/META-INF/persistence.xml b/model/engine-model/src/test/resources/META-INF/persistence.xml
deleted file mode 100644
index 42048d85d..000000000
--- a/model/engine-model/src/test/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,69 +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.AxConcept</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.TestEntity</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextModel</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxInputField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxOutputField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEvent</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEvents</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEventModel</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTask</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTasks</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxStateFinalizerLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxStateOutput</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxState</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicy</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicies</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</class>
- <class>org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel</class>
- <class>org.onap.policy.apex.model.enginemodel.concepts.AxEngineStats</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>
diff --git a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
index c31597413..5f770d1b3 100644
--- a/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
+++ b/model/event-model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 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.
@@ -26,72 +26,10 @@ import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
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;
import org.onap.policy.apex.model.eventmodel.concepts.AxEventModel;
public class ApexEventModelTest {
- TestApexModel<AxEventModel> testApexModel;
-
- /**
- * Set up the test.
- *
- * @throws Exception exceptions from the test
- */
- @Before
- public void setup() throws Exception {
- testApexModel = new TestApexModel<AxEventModel>(AxEventModel.class, new DummyTestApexEventModelCreator());
- }
-
- @Test
- public void testModelValid() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelValid();
- assertEquals(VALID_MODEL_STRING, result.toString());
- }
-
- @Test
- public void testApexModelVaidateObservation() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateObservation();
- assertEquals(OBSERVATION_MODEL_STRING, result.toString());
- }
-
- @Test
- public void testApexModelVaidateWarning() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
- assertEquals(WARNING_MODEL_STRING, result.toString());
- }
-
- @Test
- public void testModelVaidateInvalidModel() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
- assertEquals(INVALID_MODEL_STRING, result.toString());
- }
-
- @Test
- public void testModelVaidateMalstructured() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
- assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
- }
-
- @Test
- public void testModelWriteReadXml() throws Exception {
- testApexModel.testApexModelWriteReadXml();
- }
-
- @Test
- 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);
- }
-
private static final String VALID_MODEL_STRING = "***validation of model successful***";
private static final String OBSERVATION_MODEL_STRING = "\n"
@@ -291,4 +229,56 @@ public class ApexEventModelTest {
+ "AxArtifactKey:(name=event1,version=0.0.1):"
+ "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank\n"
+ "********************************";
+
+ TestApexModel<AxEventModel> testApexModel;
+
+ /**
+ * Set up the test.
+ *
+ * @throws Exception exceptions from the test
+ */
+ @Before
+ public void setup() throws Exception {
+ testApexModel = new TestApexModel<AxEventModel>(AxEventModel.class, new DummyTestApexEventModelCreator());
+ }
+
+ @Test
+ public void testModelValid() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValid();
+ assertEquals(VALID_MODEL_STRING, result.toString());
+ }
+
+ @Test
+ public void testApexModelVaidateObservation() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelVaidateObservation();
+ assertEquals(OBSERVATION_MODEL_STRING, result.toString());
+ }
+
+ @Test
+ public void testApexModelVaidateWarning() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
+ assertEquals(WARNING_MODEL_STRING, result.toString());
+ }
+
+ @Test
+ public void testModelVaidateInvalidModel() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
+ assertEquals(INVALID_MODEL_STRING, result.toString());
+ }
+
+ @Test
+ public void testModelVaidateMalstructured() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
+ assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
+ }
+
+ @Test
+ public void testModelWriteReadXml() throws Exception {
+ testApexModel.testApexModelWriteReadXml();
+ }
+
+ @Test
+ public void testModelWriteReadJson() throws Exception {
+ testApexModel.testApexModelWriteReadJson();
+ }
}
diff --git a/model/event-model/src/test/resources/META-INF/persistence.xml b/model/event-model/src/test/resources/META-INF/persistence.xml
deleted file mode 100644
index 0184cada6..000000000
--- a/model/event-model/src/test/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,54 +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.AxConcept</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.TestEntity</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextModel</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxInputField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxOutputField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEvent</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEvents</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEventModel</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>
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModel.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModel.java
index 6c37e453c..d721e33fd 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModel.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexModel.java
@@ -1,26 +1,26 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 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.
* 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.modelapi;
-import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
/**
@@ -62,25 +62,6 @@ public interface ApexModel extends ApexEditorApi {
ApexApiResult saveToFile(String fileName, boolean xmlFlag);
/**
- * Load an Apex model from a database.
- *
- * @param modelName the name of the model to load
- * @param modelVersion the version of the model to load, loads the policy model from the database with this name, if
- * more than one exist, an exception is thrown
- * @param daoParameters the parameters to use to access the database over JDBC
- * @return the result of the operation
- */
- ApexApiResult loadFromDatabase(String modelName, String modelVersion, DaoParameters daoParameters);
-
- /**
- * Save an Apex model to a database.
- *
- * @param daoParameters the parameters to use to access the database over JDBC
- * @return the result of the operation
- */
- ApexApiResult saveToDatabase(DaoParameters daoParameters);
-
- /**
* Read an APEX model from a location identified by a URL.
*
* @param urlString the url string
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
index cca9d3454..944d95f2b 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019,2022 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,7 +28,6 @@ import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
-import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
import org.onap.policy.apex.model.modelapi.ApexApiResult;
import org.onap.policy.apex.model.modelapi.ApexApiResult.Result;
import org.onap.policy.apex.model.modelapi.ApexModel;
@@ -792,23 +791,6 @@ public final class ApexModelImpl implements ApexModel {
* {@inheritDoc}.
*/
@Override
- public ApexApiResult loadFromDatabase(final String modelName, final String modelVersion,
- final DaoParameters daoParameters) {
- return modelHandlerFacade.loadFromDatabase(modelName, modelVersion, daoParameters);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public ApexApiResult saveToDatabase(final DaoParameters daoParameters) {
- return modelHandlerFacade.saveToDatabase(daoParameters);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public ApexApiResult readFromUrl(final String urlString) {
return modelHandlerFacade.readFromUrl(urlString);
}
@@ -894,4 +876,4 @@ public final class ApexModelImpl implements ApexModel {
return policyModel;
}
-} \ No newline at end of file
+}
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java
index b350af527..9d03ba1e0 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ModelHandlerFacade.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-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.
@@ -30,16 +30,11 @@ import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Properties;
import java.util.Set;
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.AxValidationResult;
-import org.onap.policy.apex.model.basicmodel.dao.ApexDao;
-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.ApexModelException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelFileWriter;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
@@ -66,7 +61,6 @@ import org.slf4j.ext.XLoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class ModelHandlerFacade {
- private static final String FOUND_IN_DATABASE = " found in database";
private static final String FILE_NAME_MAY_NOT_BE_NULL = "fileName may not be null";
private static final String MODEL = "model ";
private static final String ALREADY_LOADED = " already loaded";
@@ -161,113 +155,6 @@ public class ModelHandlerFacade {
}
/**
- * Load an Apex model from a database.
- *
- * @param modelName the name of the model to load
- * @param modelVersion the version of the model to load, loads the policy model from the database with this name, if
- * more than one exist, an exception is thrown
- * @param daoParameters the parameters to use to access the database over JDBC
- * @return the result of the operation
- */
- public ApexApiResult loadFromDatabase(final String modelName, final String modelVersion,
- final DaoParameters daoParameters) {
- Assertions.argumentNotNull(modelName, "modelName may not be null");
- Assertions.argumentNotNull(daoParameters, "DaoParameters may not be null");
-
- if (!apexModel.getPolicyModel().getKey().equals(AxArtifactKey.getNullKey())) {
- return new ApexApiResult(ApexApiResult.Result.CONCEPT_EXISTS,
- MODEL + apexModel.getPolicyModel().getKey().getId() + ALREADY_LOADED);
- }
-
- ApexDao apexDao = null;
- try {
- apexDao = new ApexDaoFactory().createApexDao(daoParameters);
- apexDao.init(daoParameters);
-
- // Single specific model requested
- if (modelVersion != null) {
- AxPolicyModel daoPolicyModel =
- apexDao.get(AxPolicyModel.class, new AxArtifactKey(modelName, modelVersion));
-
- if (daoPolicyModel != null) {
- apexModel.setPolicyModel(daoPolicyModel);
- return new ApexApiResult();
- } else {
- apexModel.setPolicyModel(new AxPolicyModel());
- return new ApexApiResult(ApexApiResult.Result.FAILED, "no policy model with name " + modelName
- + " and version " + modelVersion + FOUND_IN_DATABASE);
- }
- } else {
- // Fishing expedition
- return searchInDatabase(modelName, apexDao, apexModel);
- }
- } catch (ApexException | ApexRuntimeException e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- } finally {
- if (apexDao != null) {
- apexDao.close();
- }
- }
- }
-
- /**
- * Search for an Apex model in the database.
- *
- * @param modelName the name of the model to load
- * @param apexDao the DAO to use to find the model
- * @param apexModel the APEX model we are loading the found model into
- * @return the result of the operation
- */
- private ApexApiResult searchInDatabase(String modelName, ApexDao apexDao, ApexModel apexModel) {
- AxPolicyModel foundPolicyModel = null;
-
- List<AxPolicyModel> policyModelList = apexDao.getAll(AxPolicyModel.class);
- for (AxPolicyModel dbPolicyModel : policyModelList) {
- if (dbPolicyModel.getKey().getName().equals(modelName)) {
- if (foundPolicyModel == null) {
- foundPolicyModel = dbPolicyModel;
- } else {
- return new ApexApiResult(ApexApiResult.Result.FAILED,
- "more than one policy model with name " + modelName + FOUND_IN_DATABASE);
- }
- }
- }
-
- if (foundPolicyModel != null) {
- apexModel.setPolicyModel(foundPolicyModel);
- return new ApexApiResult();
- } else {
- apexModel.setPolicyModel(new AxPolicyModel());
- return new ApexApiResult(ApexApiResult.Result.FAILED,
- "no policy model with name " + modelName + FOUND_IN_DATABASE);
- }
- }
-
- /**
- * Save an Apex model to a database.
- *
- * @param daoParameters the parameters to use to access the database over JDBC
- * @return the result of the operation
- */
- public ApexApiResult saveToDatabase(final DaoParameters daoParameters) {
- ApexDao apexDao = null;
-
- try {
- apexDao = new ApexDaoFactory().createApexDao(daoParameters);
- apexDao.init(daoParameters);
-
- apexDao.create(apexModel.getPolicyModel());
- return new ApexApiResult();
- } catch (ApexException e) {
- return new ApexApiResult(ApexApiResult.Result.FAILED, e);
- } finally {
- if (apexDao != null) {
- apexDao.close();
- }
- }
- }
-
- /**
* Read an APEX model from a location identified by a URL.
*
* @param urlString the url string
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
index a4b42276a..132864bc9 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 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.
@@ -34,7 +34,6 @@ import java.util.UUID;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
import org.onap.policy.apex.model.modelapi.impl.ApexModelImpl;
import org.onap.policy.common.utils.resources.TextFileUtils;
@@ -109,39 +108,6 @@ public class ApexModelApiTest {
}
@Test
- public void testApexModelDatabase() throws IOException {
- final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
-
- ApexApiResult result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- final DaoParameters DaoParameters = new DaoParameters();
- DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
- DaoParameters.setPersistenceUnit("DAOTest");
-
- result = apexModel.saveToDatabase(DaoParameters);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.deleteModel();
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.loadFromDatabase("PolicyModel", "0.0.1", DaoParameters);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.deleteModel();
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.loadFromDatabase("PolicyModel", null, DaoParameters);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.deleteModel();
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.loadFromDatabase("VPNPolicyModel", "0.0.1", DaoParameters);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- }
-
- @Test
public void testApexModelUrl() throws IOException {
final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
index 4a1c3276c..e43e5896b 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 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.
@@ -29,7 +29,6 @@ import java.io.File;
import java.io.IOException;
import java.util.Properties;
import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
import org.onap.policy.apex.model.modelapi.impl.ModelHandlerFacade;
import org.onap.policy.common.utils.resources.TextFileUtils;
@@ -69,19 +68,9 @@ public class ModelHandlerFacadeTest {
result = mhf.loadFromString(modelString);
assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
- final DaoParameters DaoParameters = new DaoParameters();
- result = mhf.loadFromDatabase("SomeModel", null, DaoParameters);
- assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
-
result = apexModel.deleteModel();
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = mhf.loadFromDatabase("SomeModel", null, DaoParameters);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
-
- result = mhf.saveToDatabase(DaoParameters);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
-
result = mhf.readFromUrl("blah://somewhere/over/the/rainbow");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
diff --git a/model/model-api/src/test/resources/META-INF/persistence.xml b/model/model-api/src/test/resources/META-INF/persistence.xml
deleted file mode 100644
index 2603d5496..000000000
--- a/model/model-api/src/test/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,67 +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.AxConcept</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.TestEntity</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextModel</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxInputField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxOutputField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEvent</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEvents</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEventModel</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTask</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTasks</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxStateFinalizerLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxStateOutput</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxState</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicy</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicies</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</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="create-or-extend-tables" />
- <property name="eclipselink.ddl-generation.output-mode" value="database" />
- <property name="eclipselink.logging.level" value="INFO" />
- </properties>
- </persistence-unit>
-</persistence>
diff --git a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
index 442e54b1f..4cb55e1d7 100644
--- a/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
+++ b/model/policy-model/src/main/java/org/onap/policy/apex/model/policymodel/concepts/AxLogic.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-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.
@@ -23,7 +23,6 @@ package org.onap.policy.apex.model.policymodel.concepts;
import java.util.List;
import javax.persistence.Column;
-import javax.persistence.Convert;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
@@ -41,7 +40,6 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
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.xml.AxReferenceKeyAdapter;
import org.onap.policy.common.utils.validation.Assertions;
@@ -96,8 +94,6 @@ public class AxLogic extends AxConcept {
private String logicFlavour;
@Column(name = "logic", length = MAX_LOGIC_SIZE)
- @Convert(converter = CDataConditioner.class)
- @XmlJavaTypeAdapter(value = CDataConditioner.class)
@XmlElement(required = true)
private String logic;
@@ -361,9 +357,7 @@ public class AxLogic extends AxConcept {
if (!logicFlavour.equals(other.logicFlavour)) {
return false;
}
- final String thislogic = CDataConditioner.clean(logic).replace("\n", "");
- final String otherlogic = CDataConditioner.clean(other.logic).replace("\n", "");
- return thislogic.equals(otherlogic);
+ return logic.equals(other.logic);
}
/**
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
index 3e3051021..a2a997e8d 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020,2022 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,72 +27,10 @@ import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
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;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
public class ApexPolicyModelTest {
- TestApexModel<AxPolicyModel> testApexModel;
-
- /**
- * Set up the policy model tests.
- *
- * @throws Exception on setup errors
- */
- @Before
- public void setup() throws Exception {
- testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new SupportApexPolicyModelCreator());
- }
-
- @Test
- public void testModelValid() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelValid();
- assertEquals(VALID_MODEL_STRING, result.toString());
- }
-
- @Test
- public void testApexModelVaidateObservation() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateObservation();
- assertEquals(OBSERVATION_MODEL_STRING, result.toString());
- }
-
- @Test
- public void testApexModelVaidateWarning() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
- assertEquals(WARNING_MODEL_STRING, result.toString());
- }
-
- @Test
- public void testModelVaidateInvalidModel() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
- assertEquals(INVALID_MODEL_STRING, result.toString());
- }
-
- @Test
- public void testModelVaidateMalstructured() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
- assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
- }
-
- @Test
- public void testModelWriteReadXml() throws Exception {
- testApexModel.testApexModelWriteReadXml();
- }
-
- @Test
- 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);
- }
-
private static final String VALID_MODEL_STRING = "***validation of model successful***";
private static final String OBSERVATION_MODEL_STRING = "\n"
@@ -150,4 +88,56 @@ public class ApexPolicyModelTest {
+ "AxArtifactKey:(name=policyModel_Policies,version=0.0.1)"
+ ":org.onap.policy.apex.model.policymodel.concepts.AxPolicies:INVALID:policyMap may not be empty\n"
+ "********************************";
+
+ TestApexModel<AxPolicyModel> testApexModel;
+
+ /**
+ * Set up the policy model tests.
+ *
+ * @throws Exception on setup errors
+ */
+ @Before
+ public void setup() throws Exception {
+ testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new SupportApexPolicyModelCreator());
+ }
+
+ @Test
+ public void testModelValid() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValid();
+ assertEquals(VALID_MODEL_STRING, result.toString());
+ }
+
+ @Test
+ public void testApexModelVaidateObservation() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelVaidateObservation();
+ assertEquals(OBSERVATION_MODEL_STRING, result.toString());
+ }
+
+ @Test
+ public void testApexModelVaidateWarning() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
+ assertEquals(WARNING_MODEL_STRING, result.toString());
+ }
+
+ @Test
+ public void testModelVaidateInvalidModel() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
+ assertEquals(INVALID_MODEL_STRING, result.toString());
+ }
+
+ @Test
+ public void testModelVaidateMalstructured() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
+ assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
+ }
+
+ @Test
+ public void testModelWriteReadXml() throws Exception {
+ testApexModel.testApexModelWriteReadXml();
+ }
+
+ @Test
+ public void testModelWriteReadJson() throws Exception {
+ testApexModel.testApexModelWriteReadJson();
+ }
}
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
index 0a1e80a20..691880d6b 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 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.
@@ -43,66 +43,58 @@ public class PolicyModelComparerTest {
String resultString = policyModelComparer.asString(false, false);
String checkString = TextFileUtils
- .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt");
- assertEquals(resultString.trim().replaceAll("\\s+", ""),
- checkString.trim().replaceAll("\\s+", ""));
+ .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseValues.txt");
+ assertEquals(resultString.trim().replaceAll("\\s+", ""), checkString.trim().replaceAll("\\s+", ""));
resultString = policyModelComparer.asString(false, true);
checkString = TextFileUtils
- .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseKeys.txt");
- assertEquals(checkString.trim().replaceAll("\\s+", ""),
- resultString.trim().replaceAll("\\s+", ""));
+ .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseKeys.txt");
+ assertEquals(checkString.trim().replaceAll("\\s+", ""), resultString.trim().replaceAll("\\s+", ""));
resultString = policyModelComparer.asString(true, false);
- checkString = TextFileUtils
- .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt");
- assertEquals(checkString.trim().replaceAll("\\s+", ""),
- resultString.trim().replaceAll("\\s+", ""));
+ checkString =
+ TextFileUtils.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt");
+ assertEquals(checkString.trim().replaceAll("\\s+", ""), resultString.trim().replaceAll("\\s+", ""));
resultString = policyModelComparer.asString(true, true);
- checkString = TextFileUtils
- .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt");
- assertEquals(checkString.trim().replaceAll("\\s+", ""),
- resultString.trim().replaceAll("\\s+", ""));
+ checkString =
+ TextFileUtils.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt");
+ assertEquals(checkString.trim().replaceAll("\\s+", ""), resultString.trim().replaceAll("\\s+", ""));
final AxKeyInfo leftOnlyKeyInfo = new AxKeyInfo(new AxArtifactKey("LeftOnlyKeyInfo", "0.0.1"),
- UUID.fromString("ce9168c-e6df-414f-9646-6da464b6f000"), "Left only key info");
+ UUID.fromString("ce9168c-e6df-414f-9646-6da464b6f000"), "Left only key info");
final AxKeyInfo rightOnlyKeyInfo = new AxKeyInfo(new AxArtifactKey("RightOnlyKeyInfo", "0.0.1"),
- UUID.fromString("ce9168c-e6df-414f-9646-6da464b6f001"), "Right only key info");
+ UUID.fromString("ce9168c-e6df-414f-9646-6da464b6f001"), "Right only key info");
leftApexModel.getKeyInformation().getKeyInfoMap().put(leftOnlyKeyInfo.getKey(), leftOnlyKeyInfo);
rightApexModel.getKeyInformation().getKeyInfoMap().put(rightOnlyKeyInfo.getKey(), rightOnlyKeyInfo);
leftApexModel.getKeyInformation().getKeyInfoMap().get(new AxArtifactKey("inEvent", "0.0.1"))
- .setDescription("Left InEvent Description");
+ .setDescription("Left InEvent Description");
rightApexModel.getKeyInformation().getKeyInfoMap().get(new AxArtifactKey("inEvent", "0.0.1"))
- .setDescription("Right InEvent Description");
+ .setDescription("Right InEvent Description");
policyModelComparer = new PolicyModelComparer(leftApexModel, rightApexModel);
resultString = policyModelComparer.asString(false, false);
checkString = TextFileUtils
- .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt");
- assertEquals(resultString.trim().replaceAll("\\s+", ""),
- checkString.trim().replaceAll("\\s+", ""));
+ .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt");
+ assertEquals(resultString.trim().replaceAll("\\s+", ""), checkString.trim().replaceAll("\\s+", ""));
resultString = policyModelComparer.asString(false, true);
checkString = TextFileUtils
- .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt");
- assertEquals(checkString.trim().replaceAll("\\s+", ""),
- resultString.trim().replaceAll("\\s+", ""));
+ .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt");
+ assertEquals(checkString.trim().replaceAll("\\s+", ""), resultString.trim().replaceAll("\\s+", ""));
resultString = policyModelComparer.asString(true, false);
checkString = TextFileUtils
- .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt");
- assertEquals(checkString.trim().replaceAll("\\s+", ""),
- resultString.trim().replaceAll("\\s+", ""));
+ .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt");
+ assertEquals(checkString.trim().replaceAll("\\s+", ""), resultString.trim().replaceAll("\\s+", ""));
resultString = policyModelComparer.asString(true, true);
checkString = TextFileUtils
- .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt");
- assertEquals(checkString.trim().replaceAll("\\s+", ""),
- resultString.trim().replaceAll("\\s+", ""));
+ .getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt");
+ assertEquals(checkString.trim().replaceAll("\\s+", ""), resultString.trim().replaceAll("\\s+", ""));
assertNotNull(policyModelComparer.getContextAlbumComparisonResult());
assertNotNull(policyModelComparer.getContextAlbumKeyDifference());
@@ -121,6 +113,6 @@ public class PolicyModelComparerTest {
assertNotNull(new PolicyComparer().compare(leftApexModel.getPolicies(), rightApexModel.getPolicies()));
assertEquals("****** policy map differences ******\n*** context s",
- policyModelComparer.toString().substring(0, 50));
+ policyModelComparer.toString().substring(0, 50));
}
}
diff --git a/model/policy-model/src/test/resources/META-INF/persistence.xml b/model/policy-model/src/test/resources/META-INF/persistence.xml
deleted file mode 100644
index 0eee729a1..000000000
--- a/model/policy-model/src/test/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,67 +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.AxConcept</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.TestEntity</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums</class>
- <class>org.onap.policy.apex.model.contextmodel.concepts.AxContextModel</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxInputField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxOutputField</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEvent</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEvents</class>
- <class>org.onap.policy.apex.model.eventmodel.concepts.AxEventModel</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTask</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTasks</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxStateFinalizerLogic</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxStateOutput</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxStateTaskReference</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxState</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicy</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicies</class>
- <class>org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel</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>
diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt
index 57b790222..4d00394b7 100644
--- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt
+++ b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt
@@ -9,7 +9,4 @@
key=AxArtifactKey:(name=LeftOnlyKeyInfo,version=0.0.1)
*** list of keys on right only
key=AxArtifactKey:(name=RightOnlyKeyInfo,version=0.0.1)
-*** list of differing entries between left and right
-key=AxArtifactKey:(name=inEvent,version=0.0.1)
***********************************
-
diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt
index e3ba6dc7c..82fecd990 100644
--- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt
+++ b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt
@@ -9,6 +9,4 @@
key=AxArtifactKey:(name=LeftOnlyKeyInfo,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=LeftOnlyKeyInfo,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6f000,description=Left only key info)
*** list of keys on right only
key=AxArtifactKey:(name=RightOnlyKeyInfo,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=RightOnlyKeyInfo,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6f001,description=Right only key info)
-*** list of differing entries between left and right
-key=AxArtifactKey:(name=inEvent,version=0.0.1),values={AxKeyInfo:(artifactId=AxArtifactKey:(name=inEvent,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e011,description=Left InEvent Description)AxKeyInfo:(artifactId=AxArtifactKey:(name=inEvent,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e011,description=Right InEvent Description),}
***********************************
diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt
index 926a8d764..38623c32a 100644
--- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt
+++ b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt
@@ -47,8 +47,7 @@ left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtif
key=AxArtifactKey:(name=LeftOnlyKeyInfo,version=0.0.1)
*** list of keys on right only
key=AxArtifactKey:(name=RightOnlyKeyInfo,version=0.0.1)
-*** list of differing entries between left and right
-key=AxArtifactKey:(name=inEvent,version=0.0.1)
+*** all values in left and right are identical
*** list of identical entries in left and right
key=AxArtifactKey:(name=ContextSchemas,version=0.0.1)
key=AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)
@@ -61,11 +60,11 @@ key=AxArtifactKey:(name=contextAlbum1,version=0.0.1)
key=AxArtifactKey:(name=eventContextItem0,version=0.0.1)
key=AxArtifactKey:(name=eventContextItem1,version=0.0.1)
key=AxArtifactKey:(name=events,version=0.0.1)
+key=AxArtifactKey:(name=inEvent,version=0.0.1)
key=AxArtifactKey:(name=outEvent0,version=0.0.1)
key=AxArtifactKey:(name=outEvent1,version=0.0.1)
key=AxArtifactKey:(name=policies,version=0.0.1)
key=AxArtifactKey:(name=policy,version=0.0.1)
key=AxArtifactKey:(name=task,version=0.0.1)
key=AxArtifactKey:(name=tasks,version=0.0.1)
-***********************************
-
+*********************************** \ No newline at end of file
diff --git a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
index 77d17f679..53cadd979 100644
--- a/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
+++ b/model/policy-model/src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseValues.txt
@@ -6,10 +6,10 @@ left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtif
*** all right keys in left
*** all values in left and right are identical
*** list of identical entries in left and right
-key=AxArtifactKey:(name=MapType,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=MapType,version=0.0.1),schemaFlavour=Java,schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A)
-key=AxArtifactKey:(name=StringType,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=StringType,version=0.0.1),schemaFlavour=Java,schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem000)
-key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),schemaFlavour=Java,schemaDefinition=java.lang.String)
-key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),schemaFlavour=Java,schemaDefinition=java.lang.Long)
+key=AxArtifactKey:(name=MapType,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=MapType,version=0.0.1), schemaFlavour=Java, schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem00A)
+key=AxArtifactKey:(name=StringType,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=StringType,version=0.0.1), schemaFlavour=Java, schemaDefinition=org.onap.policy.apex.model.policymodel.concepts.TestContextItem000)
+key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=eventContextItem0,version=0.0.1), schemaFlavour=Java, schemaDefinition=java.lang.String)
+key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),value=AxContextSchema(key=AxArtifactKey:(name=eventContextItem1,version=0.0.1), schemaFlavour=Java, schemaDefinition=java.lang.Long)
*** event differences ***
left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1)
*** all left keys in right
@@ -25,8 +25,8 @@ left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtif
*** all right keys in left
*** all values in left and right are identical
*** list of identical entries in left and right
-key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),value=AxContextAlbum(key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),scope=APPLICATION,isWritable=true,itemSchema=AxArtifactKey:(name=MapType,version=0.0.1))
-key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),value=AxContextAlbum(key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),scope=GLOBAL,isWritable=false,itemSchema=AxArtifactKey:(name=StringType,version=0.0.1))
+key=AxArtifactKey:(name=contextAlbum0,version=0.0.1),value=AxContextAlbum(key=AxArtifactKey:(name=contextAlbum0,version=0.0.1), scope=APPLICATION, isWritable=true, itemSchema=AxArtifactKey:(name=MapType,version=0.0.1))
+key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),value=AxContextAlbum(key=AxArtifactKey:(name=contextAlbum1,version=0.0.1), scope=GLOBAL, isWritable=false, itemSchema=AxArtifactKey:(name=StringType,version=0.0.1))
*** task differences ***
left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtifactKey:(name=PolicyModel,version=0.0.1)
*** all left keys in right
@@ -47,8 +47,7 @@ left key AxArtifactKey:(name=PolicyModel,version=0.0.1) equals right key AxArtif
key=AxArtifactKey:(name=LeftOnlyKeyInfo,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=LeftOnlyKeyInfo,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6f000,description=Left only key info)
*** list of keys on right only
key=AxArtifactKey:(name=RightOnlyKeyInfo,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=RightOnlyKeyInfo,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6f001,description=Right only key info)
-*** list of differing entries between left and right
-key=AxArtifactKey:(name=inEvent,version=0.0.1),values={AxKeyInfo:(artifactId=AxArtifactKey:(name=inEvent,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e011,description=Left InEvent Description)AxKeyInfo:(artifactId=AxArtifactKey:(name=inEvent,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e011,description=Right InEvent Description),}
+*** all values in left and right are identical
*** list of identical entries in left and right
key=AxArtifactKey:(name=ContextSchemas,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=ContextSchemas,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e000,description=Generated description for concept referred to by key "ContextSchemas:0.0.1")
key=AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e001,description=Generated description for concept referred to by key "KeyInfoMapKey:0.0.1")
@@ -61,6 +60,7 @@ key=AxArtifactKey:(name=contextAlbum1,version=0.0.1),value=AxKeyInfo:(artifactId
key=AxArtifactKey:(name=eventContextItem0,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=eventContextItem0,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e008,description=Generated description for concept referred to by key "eventContextItem0:0.0.1")
key=AxArtifactKey:(name=eventContextItem1,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=eventContextItem1,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e009,description=Generated description for concept referred to by key "eventContextItem1:0.0.1")
key=AxArtifactKey:(name=events,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=events,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e010,description=Generated description for concept referred to by key "events:0.0.1")
+key=AxArtifactKey:(name=inEvent,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=inEvent,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e011,description=Left InEvent Description)
key=AxArtifactKey:(name=outEvent0,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=outEvent0,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e012,description=Generated description for concept referred to by key "outEvent0:0.0.1")
key=AxArtifactKey:(name=outEvent1,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=outEvent1,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e013,description=Generated description for concept referred to by key "outEvent1:0.0.1")
key=AxArtifactKey:(name=policies,version=0.0.1),value=AxKeyInfo:(artifactId=AxArtifactKey:(name=policies,version=0.0.1),uuid=0ce9168c-e6df-414f-9646-6da464b6e014,description=Generated description for concept referred to by key "policies:0.0.1")