diff options
64 files changed, 265 insertions, 4137 deletions
diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java deleted file mode 100644 index 58987533a..000000000 --- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmDbWriteTest.java +++ /dev/null @@ -1,49 +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.examples.aadm; - -import org.junit.Before; -import org.junit.Test; -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 AadmDbWriteTest { - TestApexModel<AxPolicyModel> testApexModel; - - /** - * Sets up embedded Derby database and the Apex AADM model for the tests. - * @throws Exception exception to be thrown while setting up the database connection - */ - @Before - public void setup() throws Exception { - testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new TestAadmModelCreator()); - } - - @Test - public void testModelWriteReadJpa() throws Exception { - final DaoParameters DaoParameters = new DaoParameters(); - DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); - DaoParameters.setPersistenceUnit("AADMModelTest"); - - testApexModel.testApexModelWriteReadJpa(DaoParameters); - } -} diff --git a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java index 99625f136..f0f0cea99 100644 --- a/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.java +++ b/examples/examples-aadm/src/test/java/org/onap/policy/apex/examples/aadm/AadmModelTest.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. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,7 +27,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.policymodel.concepts.AxPolicyModel; @@ -60,13 +59,4 @@ public class AadmModelTest { 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("AADMModelTest"); - - testApexModel.testApexModelWriteReadJpa(DaoParameters); - } } diff --git a/examples/examples-aadm/src/test/resources/META-INF/persistence.xml b/examples/examples-aadm/src/test/resources/META-INF/persistence.xml deleted file mode 100644 index 10a720dd7..000000000 --- a/examples/examples-aadm/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="AADMModelTest" 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/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java deleted file mode 100644 index 3004bccb3..000000000 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionDbWriteTest.java +++ /dev/null @@ -1,48 +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.examples.adaptive; - -import org.junit.Before; -import org.junit.Test; -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 AnomalyDetectionDbWriteTest { - TestApexModel<AxPolicyModel> testApexModel; - - /** - * Sets up embedded Derby database and the Apex anomaly detection model for the tests. - * @throws Exception exception to be thrown while setting up the database connection - */ - @Before - public void setup() throws Exception { - testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAnomalyDetectionModelCreator()); - } - - @Test - public void testModelWriteReadJpa() throws Exception { - final DaoParameters DaoParameters = new DaoParameters(); - DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); - DaoParameters.setPersistenceUnit("AdaptiveModelsTest"); - testApexModel.testApexModelWriteReadJpa(DaoParameters); - } -} diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java index 85cecbe8b..310b43f68 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AnomalyDetectionModelTest.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,12 @@ 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 AnomalyDetectionModelTest { + private static final String VALID_MODEL_STRING = "***validation of model successful***"; + TestApexModel<AxPolicyModel> testApexModel; /** @@ -57,15 +58,4 @@ public class AnomalyDetectionModelTest { 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("AdaptiveModelsTest"); - - testApexModel.testApexModelWriteReadJpa(DaoParameters); - } - - private static final String VALID_MODEL_STRING = "***validation of model successful***"; } diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java deleted file mode 100644 index b72514f49..000000000 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnDbWriteTest.java +++ /dev/null @@ -1,49 +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.examples.adaptive; - -import org.junit.Before; -import org.junit.Test; -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 AutoLearnDbWriteTest { - TestApexModel<AxPolicyModel> testApexModel; - - /** - * Sets up embedded Derby database and the Apex AutoLearn model for the tests. - * @throws Exception exception to be thrown while setting up the database connection - */ - @Before - public void setup() throws Exception { - testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAutoLearnModelCreator()); - } - - @Test - public void testModelWriteReadJpa() throws Exception { - final DaoParameters DaoParameters = new DaoParameters(); - DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); - DaoParameters.setPersistenceUnit("AdaptiveModelsTest"); - - testApexModel.testApexModelWriteReadJpa(DaoParameters); - } -} diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java index 3479ccc9e..515451490 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/AutoLearnModelTest.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,12 @@ 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 AutoLearnModelTest { + private static final String VALID_MODEL_STRING = "***validation of model successful***"; + TestApexModel<AxPolicyModel> testApexModel; /** @@ -57,15 +58,4 @@ public class AutoLearnModelTest { 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("AdaptiveModelsTest"); - - testApexModel.testApexModelWriteReadJpa(DaoParameters); - } - - private static final String VALID_MODEL_STRING = "***validation of model successful***"; } diff --git a/examples/examples-adaptive/src/test/resources/META-INF/persistence.xml b/examples/examples-adaptive/src/test/resources/META-INF/persistence.xml deleted file mode 100644 index 1e70abc6d..000000000 --- a/examples/examples-adaptive/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="AdaptiveModelsTest" 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/examples/examples-myfirstpolicy/src/test/resources/META-INF/persistence.xml b/examples/examples-myfirstpolicy/src/test/resources/META-INF/persistence.xml deleted file mode 100644 index 909f413eb..000000000 --- a/examples/examples-myfirstpolicy/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="MFPModelTest" 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/examples/examples-pcvs/src/test/resources/META-INF/persistence.xml b/examples/examples-pcvs/src/test/resources/META-INF/persistence.xml deleted file mode 100644 index 632ae0fca..000000000 --- a/examples/examples-pcvs/src/test/resources/META-INF/persistence.xml +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2016-2018 Ericsson. All rights reserved. - Modifications Copyright (C) 2019-2021 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========================================================= ---> - -<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"> - <persistence-unit name="MFPModelTest" 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:derby:memory:apex_test" /> - <property name="eclipselink.target-database" value="Derby" /> - <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" /> - - <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/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") diff --git a/packages/apex-pdp-package-full/src/main/resources/META-INF/persistence.xml b/packages/apex-pdp-package-full/src/main/resources/META-INF/persistence.xml deleted file mode 100644 index 23c70b18b..000000000 --- a/packages/apex-pdp-package-full/src/main/resources/META-INF/persistence.xml +++ /dev/null @@ -1,263 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2016-2018 Ericsson. All rights reserved. - Modifications Copyright (C) 2019-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. - 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="org.onap.policy.apex.core.model.eclipselink.runtime" - transaction-type="RESOURCE_LOCAL"> - <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> - - <class>org.onap.policy.apex.core.basicmodel.dao.converters.UUID2String</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxArtifactKey</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxConcept</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxDataType</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxKeyInfo</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxKeyInformation</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxModel</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.TestEntity</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextType</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextItem</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextItemTemplate</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextScope</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextType</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextMap</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContext</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextModel</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEventParameter</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEvent</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEvents</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEventModel</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxLogic</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxTaskParameter</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxTask</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxTasks</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxState</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxPolicy</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxPolicies</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxPolicyModel</class> - <class>org.onap.policy.apex.core.enginemodel.concepts.AxEngineStats</class> - <class>org.onap.policy.apex.core.enginemodel.concepts.AxEngineModel</class> - <class>org.onap.policy.apex.domains.aadm.concepts.ENodeBStatus</class> - <class>org.onap.policy.apex.domains.aadm.concepts.IMSIStatus</class> - <class>org.onap.policy.apex.domains.aadm.concepts.IPAddressStatus</class> - <class>org.onap.policy.apex.domains.adaptive.concepts.AnomalyDetection</class> - <class>org.onap.policy.apex.domains.adaptive.concepts.Autmer</class> - <class>org.onap.policy.apex.domains.vpn.concepts.VPNCustooLearn</class> - <class>org.onap.policy.apex.domains.vpn.concepts.VPNLink</class> - <class>org.onap.policy.apex.domains.vpn.concepts.VPNProblem</class> - - <exclude-unlisted-classes>false</exclude-unlisted-classes> - <properties> - <property name="eclipselink.target-database" value="${database.target-database}" /> - <property name="javax.persistence.jdbc.driver" value="${database.jdbc.driver}" /> - <property name="javax.persistence.jdbc.url" value="${database.jdbc.url}" /> - <property name="javax.persistence.jdbc.user" value="${database.jdbc.user}" /> - <property name="javax.persistence.jdbc.password" value="${database.jdbc.password}" /> - - <property name="eclipselink.ddl-generation" value="create-or-extend-tables" /> - <property name="eclipselink.logging.level" value="INFO" /> - - </properties> - </persistence-unit> - - <persistence-unit name="org.onap.policy.apex.core.model.eclipselink.test" - transaction-type="RESOURCE_LOCAL"> - <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> - - <class>org.onap.policy.apex.core.basicmodel.dao.converters.UUID2String</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxArtifactKey</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxConcept</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxDataType</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxKeyInfo</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxKeyInformation</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxModel</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.TestEntity</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextType</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextItem</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextItemTemplate</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextScope</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextType</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextMap</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContext</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextModel</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEventParameter</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEvent</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEvents</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEventModel</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxLogic</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxTaskParameter</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxTask</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxTasks</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxState</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxPolicy</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxPolicies</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxPolicyModel</class> - <class>org.onap.policy.apex.core.enginemodel.concepts.AxEngineStats</class> - <class>org.onap.policy.apex.core.enginemodel.concepts.AxEngineModel</class> - <class>org.onap.policy.apex.domains.aadm.concepts.ENodeBStatus</class> - <class>org.onap.policy.apex.domains.aadm.concepts.IMSIStatus</class> - <class>org.onap.policy.apex.domains.aadm.concepts.IPAddressStatus</class> - <class>org.onap.policy.apex.domains.adaptive.concepts.AnomalyDetection</class> - <class>org.onap.policy.apex.domains.adaptive.concepts.AutoLearn</class> - <class>org.onap.policy.apex.domains.vpn.concepts.VPNCustomer</class> - <class>org.onap.policy.apex.domains.vpn.concepts.VPNLink</class> - <class>org.onap.policy.apex.domains.vpn.concepts.VPNProblem</class> - - <exclude-unlisted-classes>false</exclude-unlisted-classes> - <properties> - <property name="eclipselink.target-database" value="${database.target-database}" /> - <property name="javax.persistence.jdbc.driver" value="${database.jdbc.driver}" /> - <property name="javax.persistence.jdbc.url" value="${database.jdbc.url}" /> - <property name="javax.persistence.jdbc.user" value="${database.jdbc.user}" /> - <property name="javax.persistence.jdbc.password" value="${database.jdbc.password}" /> - - <property name="eclipselink.ddl-generation" value="drop-and-create-tables" /> - <property name="eclipselink.logging.level" value="INFO" /> - - </properties> - </persistence-unit> - - <persistence-unit name="org.onap.policy.apex.core.model.hibernate.runtime"> - <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> - - <class>org.onap.policy.apex.core.basicmodel.dao.converters.UUID2String</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxArtifactKey</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxConcept</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxDataType</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxKeyInfo</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxKeyInformation</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxModel</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.TestEntity</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextType</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextItem</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextItemTemplate</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextScope</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextType</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextMap</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContext</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextModel</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEventParameter</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEvent</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEvents</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEventModel</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxLogic</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxTaskParameter</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxTask</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxTasks</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxState</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxPolicy</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxPolicies</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxPolicyModel</class> - <class>org.onap.policy.apex.core.enginemodel.concepts.AxEngineStats</class> - <class>org.onap.policy.apex.core.enginemodel.concepts.AxEngineModel</class> - <class>org.onap.policy.apex.domains.aadm.concepts.ENodeBStatus</class> - <class>org.onap.policy.apex.domains.aadm.concepts.IMSIStatus</class> - <class>org.onap.policy.apex.domains.aadm.concepts.IPAddressStatus</class> - <class>org.onap.policy.apex.domains.adaptive.concepts.AnomalyDetection</class> - <class>org.onap.policy.apex.domains.adaptive.concepts.AutoLearn</class> - <class>org.onap.policy.apex.domains.vpn.concepts.VPNCustomer</class> - <class>org.onap.policy.apex.domains.vpn.concepts.VPNLink</class> - <class>org.onap.policy.apex.domains.vpn.concepts.VPNProblem</class> - - <properties> - <property name="eclipselink.target-database" value="${database.target-database}" /> - <property name="javax.persistence.jdbc.driver" value="${database.jdbc.driver}" /> - <property name="javax.persistence.jdbc.url" value="${database.jdbc.url}" /> - <property name="javax.persistence.jdbc.user" value="${database.jdbc.user}" /> - <property name="javax.persistence.jdbc.password" value="${database.jdbc.password}" /> - - <property name="hibernate.dialect" value="${database.dialect}" /> - <property name="hibernate.hbm2ddl.auto" value="update" /> - <property name="hibernate.connection.provider_class" - value="org.hibernate.connection.C3P0ConnectionProvider" /> - <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false" /> - <property name="hibernate.c3p0.max_size" value="100" /> - <property name="hibernate.c3p0.min_size" value="0" /> - <property name="hibernate.c3p0.acquire_increment" value="1" /> - <property name="hibernate.c3p0.idle_test_period" value="300" /> - <property name="hibernate.c3p0.max_statements" value="0" /> - <property name="hibernate.c3p0.timeout" value="100" /> - </properties> - </persistence-unit> - - <persistence-unit name="org.onap.policy.apex.core.model.hibernate.test"> - <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> - - <class>org.onap.policy.apex.core.basicmodel.dao.converters.UUID2String</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxArtifactKey</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxConcept</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxDataType</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxKeyInfo</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxKeyInformation</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.AxModel</class> - <class>org.onap.policy.apex.core.basicmodel.concepts.TestEntity</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextType</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextItem</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextItemTemplate</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextScope</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextType</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextMap</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContext</class> - <class>org.onap.policy.apex.core.contextmodel.concepts.AxContextModel</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEventParameter</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEvent</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEvents</class> - <class>org.onap.policy.apex.core.eventmodel.concepts.AxEventModel</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxLogic</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxTaskParameter</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxTask</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxTasks</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxState</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxPolicy</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxPolicies</class> - <class>org.onap.policy.apex.core.policymodel.concepts.AxPolicyModel</class> - <class>org.onap.policy.apex.core.enginemodel.concepts.AxEngineStats</class> - <class>org.onap.policy.apex.core.enginemodel.concepts.AxEngineModel</class> - <class>org.onap.policy.apex.domains.aadm.concepts.ENodeBStatus</class> - <class>org.onap.policy.apex.domains.aadm.concepts.IMSIStatus</class> - <class>org.onap.policy.apex.domains.aadm.concepts.IPAddressStatus</class> - <class>org.onap.policy.apex.domains.adaptive.concepts.AnomalyDetection</class> - <class>org.onap.policy.apex.domains.adaptive.concepts.AutoLearn</class> - <class>org.onap.policy.apex.domains.vpn.concepts.VPNCustomer</class> - <class>org.onap.policy.apex.domains.vpn.concepts.VPNLink</class> - <class>org.onap.policy.apex.domains.vpn.concepts.VPNProblem</class> - - <properties> - <property name="eclipselink.target-database" value="${database.target-database}" /> - <property name="javax.persistence.jdbc.driver" value="${database.jdbc.driver}" /> - <property name="javax.persistence.jdbc.url" value="${database.jdbc.url}" /> - <property name="javax.persistence.jdbc.user" value="${database.jdbc.user}" /> - <property name="javax.persistence.jdbc.password" value="${database.jdbc.password}" /> - <property name="hibernate.dialect" value="${database.dialect}" /> - <property name="hibernate.hbm2ddl.auto" value="create" /> - <property name="hibernate.connection.provider_class" - value="org.hibernate.connection.C3P0ConnectionProvider" /> - <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false" /> - <property name="hibernate.c3p0.max_size" value="100" /> - <property name="hibernate.c3p0.min_size" value="0" /> - <property name="hibernate.c3p0.acquire_increment" value="1" /> - <property name="hibernate.c3p0.idle_test_period" value="300" /> - <property name="hibernate.c3p0.max_statements" value="0" /> - <property name="hibernate.c3p0.timeout" value="100" /> - </properties> - </persistence-unit> - -</persistence> diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/pom.xml b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/pom.xml deleted file mode 100644 index 8df1b8168..000000000 --- a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Copyright (C) 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========================================================= ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-persistence.plugins-persistence-jpa</groupId> - <artifactId>plugins-persistence-jpa</artifactId> - <version>2.7.1-SNAPSHOT</version> - </parent> - <artifactId>plugins-persistence-jpa-eclipselink</artifactId> - <name>${project.artifactId}</name> - <description>[${project.parent.artifactId}] Plugin for persistence using EclipseLink</description> -</project>
\ No newline at end of file diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/main/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDao.java b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/main/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDao.java deleted file mode 100644 index e0bce2dd6..000000000 --- a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/main/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDao.java +++ /dev/null @@ -1,32 +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.plugins.persistence.jpa.eclipselink; - -import org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao; - -/** - * The Class EclipselinkApexDao is the EclipseLink JPA implementation. It just uses the standard Apex JPA - * implementation. - * - * @author Sergey Sachkov (sergey.sachkov@ericsson.com) - */ -public class EclipselinkApexDao extends DefaultApexDao { -} diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/main/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/package-info.java b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/main/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/package-info.java deleted file mode 100644 index f58e5fc76..000000000 --- a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/main/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/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========================================================= - */ - -/** - * Provides the <a href="http://www.eclipse.org/eclipselink/">EclipseLink</a> implementation on the APEX DAO for - * persistence over <a href="https://en.wikipedia.org/wiki/Java_Database_Connectivity">JDBC</a>. - * - * @author Liam Fallon (liam.fallon@ericsson.com) - */ - -package org.onap.policy.apex.plugins.persistence.jpa.eclipselink; diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java deleted file mode 100644 index 4f3c68b0f..000000000 --- a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java +++ /dev/null @@ -1,251 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 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.plugins.persistence.jpa.eclipselink; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import org.junit.After; -import org.junit.Before; -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.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.dao.DaoParameters; -import org.onap.policy.apex.plugins.persistence.jpa.eclipselink.entities.ArtifactKeyTestEntity; -import org.onap.policy.apex.plugins.persistence.jpa.eclipselink.entities.ReferenceKeyTestEntity; - -/** - * Junit tests for class EclipselinkApexDao. - * - * @author Dinh Danh Le (dinh.danh.le@ericsson.com) - * - */ - -public class EclipselinkApexDaoTest { - - private static final List<AxArtifactKey> TEST_ARTIKEYS = Arrays.asList(new AxArtifactKey[] - { new AxArtifactKey("ABC", "0.0.1"), new AxArtifactKey("DEF", "0.1.1"), new AxArtifactKey("XYZ", "1.1.1") }); - - private final DaoParameters daoParameters = new DaoParameters(); - - private EclipselinkApexDao eclipselinkApexDao = null; - - /** - * Setup the tests. - * - * @throws ApexException Exceptions from test setup - */ - @Before - public void setup() throws ApexException { - daoParameters.setPluginClass(EclipselinkApexDao.class.getName()); - daoParameters.setPersistenceUnit("DAOTest"); - eclipselinkApexDao = new EclipselinkApexDao(); - eclipselinkApexDao.init(daoParameters); - } - - @After - public void teardown() { - eclipselinkApexDao.close(); - } - - @Test - public void test_NullArguments() { - final AxArtifactKey nullArtifactKey = null; - final AxArtifactKey nullRefernceKey = null; - final List<Object> emptyList = Collections.emptyList(); - - assertNull(eclipselinkApexDao.getArtifact(null, nullArtifactKey)); - assertNull(eclipselinkApexDao.getArtifact(ArtifactKeyTestEntity.class, nullArtifactKey)); - - assertNull(eclipselinkApexDao.getArtifact(null, nullRefernceKey)); - assertNull(eclipselinkApexDao.getArtifact(ReferenceKeyTestEntity.class, nullRefernceKey)); - - assertNotNull(eclipselinkApexDao.getAll(null)); - assertEquals(emptyList, eclipselinkApexDao.getAll(null)); - assertNotNull(eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class)); - } - - @Test - public void test_createObject() throws ApexException { - // create 3 more entities from testArtiKeys - for (final AxArtifactKey akey : TEST_ARTIKEYS) { - eclipselinkApexDao.create(new ReferenceKeyTestEntity(new AxReferenceKey(akey), Math.random())); - } - assertEquals(3, eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class).size()); - } - - @Test - public void test_getAll() { - // create a list of three entities from testArtiKeys - final double[] genDoubleVals = new double[TEST_ARTIKEYS.size()]; - - for (int i = 0; i < TEST_ARTIKEYS.size(); i++) { - final AxArtifactKey akey = TEST_ARTIKEYS.get(i); - genDoubleVals[i] = Math.random(); - eclipselinkApexDao.create(new ReferenceKeyTestEntity(new AxReferenceKey(akey), genDoubleVals[i])); - } - - final List<ReferenceKeyTestEntity> ret = eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class); - assertEquals(TEST_ARTIKEYS.size(), ret.size()); - - for (int i = 0; i < TEST_ARTIKEYS.size(); i++) { - final ReferenceKeyTestEntity e = ret.get(i); - assertEquals(TEST_ARTIKEYS.get(i), e.getKey().getParentArtifactKey()); - assertEquals(genDoubleVals[i], e.getDoubleValue(), 0.0); - } - } - - @Test - public void test_getArtifactByReferenceKey() { - final AxArtifactKey artifactKey = new AxArtifactKey("XXX", "0.0.1"); - final AxReferenceKey referenceKey = new AxReferenceKey(artifactKey, "Entity1"); - - // assert null if Entity Class is null - assertNull(eclipselinkApexDao.getArtifact(null, referenceKey)); - - // create PersistenceContext with an entity - eclipselinkApexDao.create(new ReferenceKeyTestEntity(referenceKey, 1.0)); - // assert null when trying to find an entity with an unknown key - final AxArtifactKey anotherArtifactKey = new AxArtifactKey("YYY", "0.0.2"); - final AxReferenceKey anotherReferenceKey = new AxReferenceKey(anotherArtifactKey); - - assertNull(eclipselinkApexDao.getArtifact(ReferenceKeyTestEntity.class, anotherReferenceKey)); - - // assert return only one entity when finding an entity with correct key - final ReferenceKeyTestEntity retEntity = eclipselinkApexDao.getArtifact(ReferenceKeyTestEntity.class, - referenceKey); - assertEquals(referenceKey, retEntity.getKey()); - } - - @Test - public void test_getArtifactByArtifactKey() { - final AxArtifactKey artifactKey = new AxArtifactKey("XXX", "0.0.1"); - // assert null if either Entity Class is null - assertNull(eclipselinkApexDao.getArtifact(null, artifactKey)); - // create an entity - eclipselinkApexDao.create(new ArtifactKeyTestEntity(artifactKey, 1.0)); - - // assert null when trying to find an entity with an unknown key - final AxArtifactKey otherArtifactKey = new AxArtifactKey("YYY", "0.0.2"); - assertNull(eclipselinkApexDao.getArtifact(ArtifactKeyTestEntity.class, otherArtifactKey)); - - // assert return only one entity when finding an entity with correct key - final ArtifactKeyTestEntity retEntity = eclipselinkApexDao.getArtifact(ArtifactKeyTestEntity.class, - artifactKey); - assertNotNull(retEntity); - assertEquals(artifactKey, retEntity.getKey()); - } - - @Test - public void test_deleteByArtifactKey() { - // initialize a list of (3) entities corresponding to the list of testArtiKeys - for (final AxArtifactKey akey : TEST_ARTIKEYS) { - eclipselinkApexDao.create(new ArtifactKeyTestEntity(akey, Math.random())); - } - // create one more entity - final ArtifactKeyTestEntity entity = new ArtifactKeyTestEntity(new AxArtifactKey("XYZ", "100.0.0"), 100.0); - eclipselinkApexDao.create(entity); - - assertEquals(3, eclipselinkApexDao.deleteByArtifactKey(ArtifactKeyTestEntity.class, TEST_ARTIKEYS)); - - // after deleteByArtifactKey()--> getAll().size() == 1 - final List<ArtifactKeyTestEntity> remainingEntities = eclipselinkApexDao.getAll(ArtifactKeyTestEntity.class); - assertEquals(1, remainingEntities.size()); - // more details about the remainingEntities - assertEquals(100.0, remainingEntities.get(0).getDoubleValue(), 0.0); - } - - @Test - public void test_deleteByReferenceKey() { - // prepare 2 AxArtifactKeys - final AxArtifactKey owner0Key = new AxArtifactKey("Owner0", "0.0.1"); - final AxArtifactKey owner1Key = new AxArtifactKey("Owner1", "0.0.1"); - - // prepare a list of (3) AxReferenceKeys corresponding to owner0Key - final List<AxReferenceKey> refKey0s = Arrays.asList(new AxReferenceKey[] { - new AxReferenceKey(owner0Key, "Entity01"), - new AxReferenceKey(owner0Key, "Entity02"), - new AxReferenceKey(owner0Key, "Entity03") - }); - - // prepare 2 more AxReferenceKeys corresponding to owner1Key - final AxReferenceKey refKey11 = new AxReferenceKey(owner1Key, "Entity11"); - final AxReferenceKey refKey12 = new AxReferenceKey(owner1Key, "Entity12"); - - // create a list of 5 entities - eclipselinkApexDao.create(new ReferenceKeyTestEntity(refKey0s.get(0), 101.0)); - eclipselinkApexDao.create(new ReferenceKeyTestEntity(refKey0s.get(1), 102.0)); - eclipselinkApexDao.create(new ReferenceKeyTestEntity(refKey0s.get(2), 103.0)); - eclipselinkApexDao.create(new ReferenceKeyTestEntity(refKey11, 104.0)); - eclipselinkApexDao.create(new ReferenceKeyTestEntity(refKey12, 105.0)); - - // assert 3 entities are deleted by this deletion - assertEquals(3, eclipselinkApexDao.deleteByReferenceKey(ReferenceKeyTestEntity.class, refKey0s)); - // after deletion, make sure getAll().size() == 2 - assertEquals(2, eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class).size()); - } - - @Test - public void test_deleteAll() { - // initialize a list of (3) entities and add to the PersistenceContext - for (final AxArtifactKey akey : TEST_ARTIKEYS) { - eclipselinkApexDao.create(new ReferenceKeyTestEntity(new AxReferenceKey(akey), Math.random())); - } - // before deleteAll()--> getAll().size() == 3 - assertEquals(3, eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class).size()); - eclipselinkApexDao.deleteAll(ReferenceKeyTestEntity.class); - // after deleteAll()--> getAll().size() == 0 - assertEquals(0, eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class).size()); - } - - @Test - public void test_getAllByArtifactKey() { - - final AxArtifactKey artiKey0 = new AxArtifactKey("XYZA", "0.1.2"); - final AxArtifactKey artiKey1 = new AxArtifactKey("ONAP", "0.0.1"); - - final AxReferenceKey refKey0 = new AxReferenceKey(artiKey0, "Entity0"); - final AxReferenceKey refKey1 = new AxReferenceKey(artiKey1, "Entity1"); - - // test with null class with known key --> return an empty list - assertNotNull(eclipselinkApexDao.getAll(null, artiKey1)); - assertEquals(Collections.emptyList(), eclipselinkApexDao.getAll(null, artiKey1)); - - // test with (not_null) ArtifactKeyTestEntity class - assertEquals(0, eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class, artiKey0).size()); - // create 2 entities - eclipselinkApexDao.create(new ReferenceKeyTestEntity(refKey0, 100.0)); - eclipselinkApexDao.create(new ReferenceKeyTestEntity(refKey0, 200.0)); - eclipselinkApexDao.create(new ReferenceKeyTestEntity(refKey1, 100.0)); - - final List<ReferenceKeyTestEntity> ret = eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class, artiKey0); - assertEquals(1, ret.size()); - final ReferenceKeyTestEntity retEntity = ret.get(0); - assertEquals(200.0, retEntity.getDoubleValue(), 0); - } - -} diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ArtifactKeyTestEntity.java b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ArtifactKeyTestEntity.java deleted file mode 100644 index 98a4c5738..000000000 --- a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ArtifactKeyTestEntity.java +++ /dev/null @@ -1,160 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 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.plugins.persistence.jpa.eclipselink.entities; - -import java.util.Arrays; -import java.util.List; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.xml.bind.annotation.XmlElement; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.apache.commons.lang3.builder.CompareToBuilder; -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.AxKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; - -/** - * The Class ArtifactKeyTestEntity is an entity for testing artifact keys. - */ -@Entity -@Table(name = "ArtifactKeyTestEntity") -@Getter -@Setter -@ToString -@EqualsAndHashCode(callSuper = false) -public class ArtifactKeyTestEntity extends AxConcept { - private static final long serialVersionUID = -2962570563281067896L; - - @EmbeddedId() - @XmlElement(name = "key", required = true) - protected AxArtifactKey key; - - private double doubleValue; - - /** - * Instantiates a new artifact key test entity. - */ - public ArtifactKeyTestEntity() { - this.key = new AxArtifactKey(); - this.doubleValue = 0; - } - - /** - * Instantiates a new artifact key test entity. - * - * @param doubleValue the double value - */ - public ArtifactKeyTestEntity(final Double doubleValue) { - this.key = new AxArtifactKey(); - this.doubleValue = doubleValue; - } - - /** - * Instantiates a new artifact key test entity. - * - * @param key the key - * @param doubleValue the double value - */ - public ArtifactKeyTestEntity(final AxArtifactKey key, final Double doubleValue) { - this.key = key; - this.doubleValue = doubleValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public List<AxKey> getKeys() { - return Arrays.asList((AxKey) getKey()); - } - - /** - * Check set key. - * - * @return true, if successful - */ - public boolean checkSetKey() { - return (this.key != null); - } - - /** - * {@inheritDoc}. - */ - @Override - public AxValidationResult validate(final AxValidationResult result) { - return key.validate(result); - } - - /** - * {@inheritDoc}. - */ - @Override - public void clean() { - key.clean(); - } - - /** - * {@inheritDoc}. - */ - @Override - public AxConcept copyTo(final AxConcept target) { - final Object copyObject = ((target == null) ? new ArtifactKeyTestEntity() : target); - if (copyObject instanceof ArtifactKeyTestEntity) { - final ArtifactKeyTestEntity copy = ((ArtifactKeyTestEntity) copyObject); - if (this.checkSetKey()) { - copy.setKey(new AxArtifactKey(key)); - } else { - copy.key = null; - } - copy.doubleValue = doubleValue; - return copy; - } else { - return null; - } - } - - /** - * {@inheritDoc}. - */ - @Override - public int compareTo(final AxConcept otherObj) { - if (otherObj == null) { - return -1; - } - if (this == otherObj) { - return 0; - } - if (getClass() != otherObj.getClass()) { - return -1; - } - final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) otherObj; - return new CompareToBuilder() - .append(key, other.key) - .append(doubleValue, other.doubleValue) - .toComparison(); - } -} diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ReferenceKeyTestEntity.java b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ReferenceKeyTestEntity.java deleted file mode 100644 index cadc9b8db..000000000 --- a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/ReferenceKeyTestEntity.java +++ /dev/null @@ -1,163 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 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.plugins.persistence.jpa.eclipselink.entities; - -import java.util.Arrays; -import java.util.List; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; -import org.apache.commons.lang3.builder.CompareToBuilder; -import org.onap.policy.apex.model.basicmodel.concepts.AxConcept; -import org.onap.policy.apex.model.basicmodel.concepts.AxKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; -import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; -import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter; - -/** - * The Class ReferenceKeyTestEntity provides a reference key test concept. - */ -@Entity -@Table(name = "ReferenceKeyTestEntity") -@Getter -@Setter -@ToString -@EqualsAndHashCode(callSuper = false) -public class ReferenceKeyTestEntity extends AxConcept { - private static final long serialVersionUID = -2962570563281067895L; - - @EmbeddedId() - @XmlElement(name = "key", required = true) - @XmlJavaTypeAdapter(AxReferenceKeyAdapter.class) - protected AxReferenceKey key; - - private double doubleValue; - - /** - * Instantiates a new reference key test entity. - */ - public ReferenceKeyTestEntity() { - this.key = new AxReferenceKey(); - this.doubleValue = 0; - } - - /** - * Instantiates a new reference key test entity. - * - * @param doubleValue the double value - */ - public ReferenceKeyTestEntity(final Double doubleValue) { - this.key = new AxReferenceKey(); - this.doubleValue = doubleValue; - } - - /** - * Instantiates a new reference key test entity. - * - * @param key the key - * @param doubleValue the double value - */ - public ReferenceKeyTestEntity(final AxReferenceKey key, final Double doubleValue) { - this.key = key; - this.doubleValue = doubleValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public List<AxKey> getKeys() { - return Arrays.asList((AxKey) getKey()); - } - - /** - * Check set key. - * - * @return true, if successful - */ - public boolean checkSetKey() { - return (this.key != null); - } - - /** - * {@inheritDoc}. - */ - @Override - public AxValidationResult validate(final AxValidationResult result) { - return key.validate(result); - } - - /** - * {@inheritDoc}. - */ - @Override - public void clean() { - key.clean(); - } - - /** - * {@inheritDoc}. - */ - @Override - public AxConcept copyTo(final AxConcept target) { - final Object copyObject = ((target == null) ? new ReferenceKeyTestEntity() : target); - if (copyObject instanceof ReferenceKeyTestEntity) { - final ReferenceKeyTestEntity copy = ((ReferenceKeyTestEntity) copyObject); - if (this.checkSetKey()) { - copy.setKey(new AxReferenceKey(key)); - } else { - copy.key = null; - } - copy.doubleValue = doubleValue; - return copy; - } else { - return null; - } - } - - /** - * {@inheritDoc}. - */ - @Override - public int compareTo(final AxConcept otherObj) { - if (otherObj == null) { - return -1; - } - if (this == otherObj) { - return 0; - } - if (getClass() != otherObj.getClass()) { - return -1; - } - final ReferenceKeyTestEntity other = (ReferenceKeyTestEntity) otherObj; - return new CompareToBuilder() - .append(key, other.key) - .append(doubleValue, other.doubleValue) - .toComparison(); - } -} diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/package-info.java b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/package-info.java deleted file mode 100644 index b30d40559..000000000 --- a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/entities/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 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========================================================= - */ - -/** - * Contains common test entities. - */ -package org.onap.policy.apex.plugins.persistence.jpa.eclipselink.entities; diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/resources/META-INF/persistence.xml b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/resources/META-INF/persistence.xml deleted file mode 100644 index 3f8be58e4..000000000 --- a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/resources/META-INF/persistence.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - Copyright (C) 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========================================================= ---> -<!-- This is to configure H2-IMDB using EclipseLink JPA--> - -<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.plugins.persistence.jpa.eclipselink.entities.ReferenceKeyTestEntity</class> - <class>org.onap.policy.apex.plugins.persistence.jpa.eclipselink.entities.ArtifactKeyTestEntity</class> - - <properties> - <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" /> - <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:test" /> - <property name="javax.persistence.jdbc.user" value="sa" /> - <property name="javax.persistence.jdbc.password" value="" /> - <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>
\ No newline at end of file diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/pom.xml b/plugins/plugins-persistence/plugins-persistence-jpa/pom.xml deleted file mode 100644 index 647c3e03a..000000000 --- a/plugins/plugins-persistence/plugins-persistence-jpa/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Copyright (C) 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========================================================= ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.policy.apex-pdp.plugins.plugins-persistence</groupId> - <artifactId>plugins-persistence</artifactId> - <version>2.7.1-SNAPSHOT</version> - </parent> - - <groupId>org.onap.policy.apex-pdp.plugins.plugins-persistence.plugins-persistence-jpa</groupId> - <artifactId>plugins-persistence-jpa</artifactId> - <packaging>pom</packaging> - - <name>${project.artifactId}</name> - <description>Plugins for 3pps that handle persistence over JPA</description> - - <dependencies> - <dependency> - <groupId>org.onap.policy.apex-pdp.model</groupId> - <artifactId>basic-model</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <modules> - <module>plugins-persistence-jpa-eclipselink</module> - </modules> -</project> diff --git a/plugins/plugins-persistence/pom.xml b/plugins/plugins-persistence/pom.xml deleted file mode 100644 index 4e16478eb..000000000 --- a/plugins/plugins-persistence/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Copyright (C) 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========================================================= ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.policy.apex-pdp.plugins</groupId> - <artifactId>plugins</artifactId> - <version>2.7.1-SNAPSHOT</version> - </parent> - - <groupId>org.onap.policy.apex-pdp.plugins.plugins-persistence</groupId> - <artifactId>plugins-persistence</artifactId> - <packaging>pom</packaging> - - <name>${project.artifactId}</name> - <description>Plugins for 3pps that implement persistence</description> - - <dependencies> - <dependency> - <groupId>org.postgresql</groupId> - <artifactId>postgresql</artifactId> - <version>42.2.14</version> - <scope>test</scope> - </dependency> - </dependencies> - <modules> - <module>plugins-persistence-jpa</module> - </modules> -</project>
\ No newline at end of file diff --git a/plugins/pom.xml b/plugins/pom.xml index b1ef1fac6..b30bf65af 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -1,7 +1,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 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. @@ -42,6 +42,5 @@ <module>plugins-context</module> <module>plugins-event</module> <module>plugins-executor</module> - <module>plugins-persistence</module> </modules> </project> diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java index b0370c5d9..8d5b702b0 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/distribution/ContextUpdate.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. * 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 static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.APEX_DISTRIBUTOR; import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.DATE_CONTEXT_ALBUM; import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.LONG_CONTEXT_ALBUM; diff --git a/testsuites/integration/integration-context-test/src/test/resources/META-INF/persistence.xml b/testsuites/integration/integration-context-test/src/test/resources/META-INF/persistence.xml deleted file mode 100644 index 341c33e89..000000000 --- a/testsuites/integration/integration-context-test/src/test/resources/META-INF/persistence.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2016-2018 Ericsson. All rights reserved. - Modifications Copyright (C) 2019-2021 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========================================================= ---> - -<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:derby:memory:apex_test" /> - <property name="eclipselink.target-database" value="Derby" /> - <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" /> - - <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/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyDbWrite.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyDbWrite.java deleted file mode 100644 index 413b57880..000000000 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyDbWrite.java +++ /dev/null @@ -1,64 +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.testsuites.integration.executor.handling; - -import java.sql.Connection; -import java.sql.DriverManager; -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.apex.model.basicmodel.dao.DaoParameters; -import org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao; -import org.onap.policy.apex.model.basicmodel.test.TestApexModel; -import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; - -/** - * The Class TestApexSamplePolicyDbWrite. - */ -public class TestApexSamplePolicyDbWrite { - TestApexModel<AxPolicyModel> testApexModel; - - /** - * Setup. - * - * @throws Exception the exception - */ - @Before - public void setup() throws Exception { - final TestApexSamplePolicyModelCreator apexPolicyModelCreator = new TestApexSamplePolicyModelCreator("MVEL"); - testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, apexPolicyModelCreator); - } - - /** - * Test model write read jpa. - * - * @throws Exception the exception - */ - @Test - public void testModelWriteReadJpa() throws Exception { - final DaoParameters DaoParameters = new DaoParameters(); - DaoParameters.setPluginClass(DefaultApexDao.class.getName()); - DaoParameters.setPersistenceUnit("SampleModelTest"); - - Connection connection = DriverManager.getConnection("jdbc:h2:mem:testdb"); - testApexModel.testApexModelWriteReadJpa(DaoParameters); - connection.close(); - } -} diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java index 0561162c8..54adc166d 100644 --- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java +++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.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. @@ -23,13 +23,9 @@ package org.onap.policy.apex.testsuites.integration.executor.handling; import static org.junit.Assert.assertEquals; -import java.sql.Connection; -import java.sql.DriverManager; 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.dao.impl.DefaultApexDao; import org.onap.policy.apex.model.basicmodel.test.TestApexModel; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; @@ -81,22 +77,4 @@ public class TestApexSamplePolicyModel { public void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); } - - /** - * Test model write read jpa. - * - * @throws Exception the exception - */ - @Test - public void testModelWriteReadJpa() throws Exception { - final DaoParameters DaoParameters = new DaoParameters(); - DaoParameters.setPluginClass(DefaultApexDao.class.getName()); - DaoParameters.setPersistenceUnit("SampleModelTest"); - - Connection connection = DriverManager.getConnection("jdbc:h2:mem:testdb"); - testApexModel.testApexModelWriteReadJpa(DaoParameters); - connection.close(); - } - - } diff --git a/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml b/testsuites/integration/integration-executor-test/src/test/resources/META-INF/persistence.xml deleted file mode 100644 index b2d6a96ed..000000000 --- a/testsuites/integration/integration-executor-test/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="SampleModelTest" 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> |