Add DAO module for Models

This patch set fixes some typos and license headers.

Issue-ID: POLICY-1195
Change-Id: I2d15b00fcb50ea92746ab7c5a87b57efa07196fe
Signed-off-by: liamfallon <liam.fallon@est.tech>
diff --git a/models-dao/src/test/java/org/onap/policy/models/dao/DaoMiscTest.java b/models-dao/src/test/java/org/onap/policy/models/dao/DaoMiscTest.java
new file mode 100644
index 0000000..4dd70ce
--- /dev/null
+++ b/models-dao/src/test/java/org/onap/policy/models/dao/DaoMiscTest.java
@@ -0,0 +1,89 @@
+/*-
+ * ============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=========================================================
+ */
+
+package org.onap.policy.models.dao;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.util.Properties;
+
+import org.junit.Test;
+import org.onap.policy.models.dao.DaoParameters;
+import org.onap.policy.models.dao.PfDaoFactory;
+import org.onap.policy.models.dao.converters.CDataConditioner;
+import org.onap.policy.models.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");
+        try {
+            new PfDaoFactory().createPfDao(daoParameters);
+            fail("test shold throw an exception here");
+        } catch (final Exception e) {
+            assertEquals("Policy Framework DAO class not found for DAO plugin \"somewhere.over.the.rainbow\"",
+                    e.getMessage());
+        }
+
+        daoParameters.setPluginClass("java.lang.String");
+        try {
+            new PfDaoFactory().createPfDao(daoParameters);
+            fail("test shold throw an exception here");
+        } catch (final Exception e) {
+            assertEquals("Specified DAO plugin class \"java.lang.String\" " + "does not implement the PfDao interface",
+                    e.getMessage());
+        }
+    }
+
+    @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/models-dao/src/test/java/org/onap/policy/models/dao/DummyConceptEntity.java b/models-dao/src/test/java/org/onap/policy/models/dao/DummyConceptEntity.java
new file mode 100644
index 0000000..fa2e71a
--- /dev/null
+++ b/models-dao/src/test/java/org/onap/policy/models/dao/DummyConceptEntity.java
@@ -0,0 +1,139 @@
+/*-
+ * ============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=========================================================
+ */
+
+package org.onap.policy.models.dao;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfValidationResult;
+
+@Entity
+@Table(name = "DummyConceptEntity")
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class DummyConceptEntity extends PfConcept {
+    private static final long serialVersionUID = -2962570563281067894L;
+
+    @EmbeddedId()
+    @NonNull
+    private PfConceptKey key;
+
+    @Column
+    @NonNull
+    private UUID uuid;
+
+    @Column
+    @NonNull
+    private String description;
+
+    public DummyConceptEntity() {
+        this.key = new PfConceptKey();
+    }
+
+    public DummyConceptEntity(final Double doubleValue) {
+        this.key = new PfConceptKey();
+    }
+
+    public DummyConceptEntity(final PfConceptKey key, final Double doubleValue) {
+        this.key = key;
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param key the key
+     * @param uuid the uuid
+     * @param description the description
+     */
+    public DummyConceptEntity(PfConceptKey key, UUID uuid, String description) {
+        this.key = key;
+        this.uuid = uuid;
+        this.description = description;
+    }
+
+    @Override
+    public List<PfKey> getKeys() {
+        final List<PfKey> keyList = new ArrayList<>();
+        keyList.add(getKey());
+        return keyList;
+    }
+
+    @Override
+    public PfValidationResult validate(final PfValidationResult result) {
+        return key.validate(result);
+    }
+
+    @Override
+    public void clean() {
+        key.clean();
+    }
+
+    @Override
+    public PfConcept copyTo(final PfConcept target) {
+        Assertions.argumentNotNull(target, "target may not be null");
+
+        final PfConcept copyObject = target;
+        Assertions.instanceOf(copyObject, DummyConceptEntity.class);
+
+        final DummyConceptEntity copy = ((DummyConceptEntity) copyObject);
+        copy.setKey(key);
+        copy.setUuid(uuid);
+        copy.setDescription(description);
+
+        return copyObject;
+    }
+
+    @Override
+    public int compareTo(final PfConcept otherObj) {
+        Assertions.argumentNotNull(otherObj, "comparison object may not be null");
+
+        if (this == otherObj) {
+            return 0;
+        }
+        if (getClass() != otherObj.getClass()) {
+            return this.hashCode() - otherObj.hashCode();
+        }
+
+        final DummyConceptEntity other = (DummyConceptEntity) otherObj;
+
+        if (!key.equals(other.key)) {
+            return key.compareTo(other.key);
+        }
+        if (!uuid.equals(other.uuid)) {
+            return uuid.compareTo(other.uuid);
+        }
+        return description.compareTo(other.description);
+    }
+}
diff --git a/models-dao/src/test/java/org/onap/policy/models/dao/DummyReferenceEntity.java b/models-dao/src/test/java/org/onap/policy/models/dao/DummyReferenceEntity.java
new file mode 100644
index 0000000..044a63d
--- /dev/null
+++ b/models-dao/src/test/java/org/onap/policy/models/dao/DummyReferenceEntity.java
@@ -0,0 +1,121 @@
+/*-
+ * ============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=========================================================
+ */
+
+package org.onap.policy.models.dao;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NonNull;
+
+import org.onap.policy.common.utils.validation.Assertions;
+import org.onap.policy.models.base.PfConcept;
+import org.onap.policy.models.base.PfKey;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.base.PfValidationResult;
+
+@Entity
+@Table(name = "DummyReferenceEntity")
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class DummyReferenceEntity extends PfConcept {
+    private static final long serialVersionUID = -2962570563281067894L;
+
+    @EmbeddedId()
+    @NonNull
+    private PfReferenceKey key;
+
+    @Column
+    private double doubleValue;
+
+    /**
+     * Default constructor.
+     */
+    public DummyReferenceEntity() {
+        this.key = new PfReferenceKey();
+        this.doubleValue = 123.45;
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param key the key
+     * @param doubleValue the double value
+     */
+    public DummyReferenceEntity(final PfReferenceKey key, final double doubleValue) {
+        this.key = key;
+        this.doubleValue = doubleValue;
+    }
+
+    @Override
+    public List<PfKey> getKeys() {
+        final List<PfKey> keyList = new ArrayList<>();
+        keyList.add(getKey());
+        return keyList;
+    }
+
+    @Override
+    public PfValidationResult validate(final PfValidationResult result) {
+        return key.validate(result);
+    }
+
+    @Override
+    public void clean() {
+        key.clean();
+    }
+
+    @Override
+    public PfConcept copyTo(final PfConcept target) {
+        Assertions.argumentNotNull(target, "target may not be null");
+
+        final PfConcept copyObject = target;
+        Assertions.instanceOf(copyObject, DummyReferenceEntity.class);
+
+        final DummyReferenceEntity copy = ((DummyReferenceEntity) copyObject);
+        copy.setKey(key);
+        copy.setDoubleValue(doubleValue);
+
+        return copyObject;
+    }
+
+
+    @Override
+    public int compareTo(final PfConcept otherObj) {
+        Assertions.argumentNotNull(otherObj, "comparison object may not be null");
+
+        if (this == otherObj) {
+            return 0;
+        }
+        if (getClass() != otherObj.getClass()) {
+            return this.hashCode() - otherObj.hashCode();
+        }
+
+        final DummyReferenceEntity other = (DummyReferenceEntity) otherObj;
+
+        return  new Double(doubleValue).compareTo(new Double(other.doubleValue));
+    }
+}
diff --git a/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java b/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java
new file mode 100644
index 0000000..8278cfe
--- /dev/null
+++ b/models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java
@@ -0,0 +1,299 @@
+/*-
+ * ============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=========================================================
+ */
+
+package org.onap.policy.models.dao;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.UUID;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.policy.models.base.PfConceptKey;
+import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.base.PfReferenceKey;
+import org.onap.policy.models.dao.DaoParameters;
+import org.onap.policy.models.dao.PfDao;
+import org.onap.policy.models.dao.PfDaoFactory;
+import org.onap.policy.models.dao.impl.DefaultPfDao;
+
+/**
+ * JUnit test class.
+ */
+public class EntityTest {
+    private Connection connection;
+    private PfDao pfDao;
+
+    @Before
+    public void setup() throws Exception {
+        connection = DriverManager.getConnection("jdbc:h2:mem:test");
+    }
+
+    @After
+    public void teardown() throws Exception {
+        connection.close();
+        new File("derby.log").delete();
+    }
+
+    @Test
+    public void testEntityTestSanity() throws PfModelException {
+        final DaoParameters daoParameters = new DaoParameters();
+
+        pfDao = new PfDaoFactory().createPfDao(daoParameters);
+
+        try {
+            pfDao.init(null);
+            fail("Test should throw an exception here");
+        } catch (final Exception e) {
+            assertEquals("Policy Framework persistence unit parameter not set", e.getMessage());
+        }
+
+        try {
+            pfDao.init(daoParameters);
+            fail("Test should throw an exception here");
+        } catch (final Exception e) {
+            assertEquals("Policy Framework persistence unit parameter not set", e.getMessage());
+        }
+
+        daoParameters.setPluginClass("somewhere.over.the.rainbow");
+        daoParameters.setPersistenceUnit("Dorothy");
+        try {
+            pfDao.init(daoParameters);
+            fail("Test should throw an exception here");
+        } catch (final Exception e) {
+            assertEquals("Creation of Policy Framework persistence unit \"Dorothy\" failed", e.getMessage());
+        }
+        try {
+            pfDao.create(new PfConceptKey());
+            fail("Test should throw an exception here");
+        } catch (final Exception e) {
+            assertEquals("Policy Framework DAO has not been initialized", e.getMessage());
+        }
+        pfDao.close();
+    }
+
+    @Test
+    public void testEntityTestAllOpsJpa() throws PfModelException {
+        final DaoParameters daoParameters = new DaoParameters();
+        daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
+        daoParameters.setPersistenceUnit("DaoTest");
+
+        pfDao = new PfDaoFactory().createPfDao(daoParameters);
+        pfDao.init(daoParameters);
+
+        testAllOps();
+        pfDao.close();
+    }
+
+    @Test
+    public void testEntityTestBadVals() throws PfModelException {
+        final DaoParameters daoParameters = new DaoParameters();
+        daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
+        daoParameters.setPersistenceUnit("DaoTest");
+
+        pfDao = new PfDaoFactory().createPfDao(daoParameters);
+        pfDao.init(daoParameters);
+
+        final PfConceptKey nullKey = null;
+        final PfReferenceKey nullRefKey = null;
+        final List<PfConceptKey> nullKeyList = null;
+        final List<PfConceptKey> emptyKeyList = new ArrayList<>();
+        final List<PfReferenceKey> nullRKeyList = null;
+        final List<PfReferenceKey> emptyRKeyList = new ArrayList<>();
+
+        pfDao.create(nullKey);
+        pfDao.createCollection(nullKeyList);
+        pfDao.createCollection(emptyKeyList);
+
+        pfDao.delete(nullKey);
+        pfDao.deleteCollection(nullKeyList);
+        pfDao.deleteCollection(emptyKeyList);
+        pfDao.delete(PfConceptKey.class, nullKey);
+        pfDao.delete(PfReferenceKey.class, nullRefKey);
+        pfDao.deleteByConceptKey(PfConceptKey.class, nullKeyList);
+        pfDao.deleteByConceptKey(PfConceptKey.class, emptyKeyList);
+        pfDao.deleteByReferenceKey(PfReferenceKey.class, nullRKeyList);
+        pfDao.deleteByReferenceKey(PfReferenceKey.class, emptyRKeyList);
+
+        pfDao.get(null, nullKey);
+        pfDao.get(null, nullRefKey);
+        pfDao.getAll(null);
+        pfDao.getAll(null, nullKey);
+        pfDao.getConcept(null, nullKey);
+        pfDao.getConcept(PfConceptKey.class, nullKey);
+        pfDao.getConcept(null, nullRefKey);
+        pfDao.getConcept(PfReferenceKey.class, nullRefKey);
+        pfDao.size(null);
+
+        pfDao.close();
+    }
+
+    private void testAllOps() {
+        final PfConceptKey aKey0 = new PfConceptKey("A-KEY0", "0.0.1");
+        final PfConceptKey aKey1 = new PfConceptKey("A-KEY1", "0.0.1");
+        final PfConceptKey aKey2 = new PfConceptKey("A-KEY2", "0.0.1");
+        final DummyConceptEntity keyInfo0 = new DummyConceptEntity(aKey0,
+                UUID.fromString("00000000-0000-0000-0000-000000000000"), "key description 0");
+        final DummyConceptEntity keyInfo1 = new DummyConceptEntity(aKey1,
+                UUID.fromString("00000000-0000-0000-0000-000000000001"), "key description 1");
+        final DummyConceptEntity keyInfo2 = new DummyConceptEntity(aKey2,
+                UUID.fromString("00000000-0000-0000-0000-000000000002"), "key description 2");
+
+        pfDao.create(keyInfo0);
+
+        final DummyConceptEntity keyInfoBack0 = pfDao.get(DummyConceptEntity.class, aKey0);
+        assertTrue(keyInfo0.equals(keyInfoBack0));
+
+        final DummyConceptEntity keyInfoBackNull = pfDao.get(DummyConceptEntity.class, PfConceptKey.getNullKey());
+        assertNull(keyInfoBackNull);
+
+        final DummyConceptEntity keyInfoBack1 = pfDao.getConcept(DummyConceptEntity.class, aKey0);
+        assertTrue(keyInfoBack0.equals(keyInfoBack1));
+
+        final DummyConceptEntity keyInfoBack2 =
+                pfDao.getConcept(DummyConceptEntity.class, new PfConceptKey("A-KEY3", "0.0.1"));
+        assertNull(keyInfoBack2);
+
+        final Set<DummyConceptEntity> keyInfoSetIn = new TreeSet<DummyConceptEntity>();
+        keyInfoSetIn.add(keyInfo1);
+        keyInfoSetIn.add(keyInfo2);
+
+        pfDao.createCollection(keyInfoSetIn);
+
+        Set<DummyConceptEntity> keyInfoSetOut = new TreeSet<DummyConceptEntity>(pfDao.getAll(DummyConceptEntity.class));
+
+        keyInfoSetIn.add(keyInfo0);
+        assertTrue(keyInfoSetIn.equals(keyInfoSetOut));
+
+        pfDao.delete(keyInfo1);
+        keyInfoSetIn.remove(keyInfo1);
+        keyInfoSetOut = new TreeSet<DummyConceptEntity>(pfDao.getAll(DummyConceptEntity.class));
+        assertTrue(keyInfoSetIn.equals(keyInfoSetOut));
+
+        pfDao.deleteCollection(keyInfoSetIn);
+        keyInfoSetOut = new TreeSet<DummyConceptEntity>(pfDao.getAll(DummyConceptEntity.class));
+        assertEquals(0, keyInfoSetOut.size());
+
+        keyInfoSetIn.add(keyInfo0);
+        keyInfoSetIn.add(keyInfo1);
+        keyInfoSetIn.add(keyInfo0);
+        pfDao.createCollection(keyInfoSetIn);
+        keyInfoSetOut = new TreeSet<DummyConceptEntity>(pfDao.getAll(DummyConceptEntity.class));
+        assertTrue(keyInfoSetIn.equals(keyInfoSetOut));
+
+        pfDao.delete(DummyConceptEntity.class, aKey0);
+        keyInfoSetOut = new TreeSet<DummyConceptEntity>(pfDao.getAll(DummyConceptEntity.class));
+        assertEquals(2, keyInfoSetOut.size());
+        assertEquals(2, pfDao.size(DummyConceptEntity.class));
+
+        final Set<PfConceptKey> keySetIn = new TreeSet<PfConceptKey>();
+        keySetIn.add(aKey1);
+        keySetIn.add(aKey2);
+
+        final int deletedCount = pfDao.deleteByConceptKey(DummyConceptEntity.class, keySetIn);
+        assertEquals(2, deletedCount);
+
+        keyInfoSetOut = new TreeSet<DummyConceptEntity>(pfDao.getAll(DummyConceptEntity.class));
+        assertEquals(0, keyInfoSetOut.size());
+
+        keyInfoSetIn.add(keyInfo0);
+        keyInfoSetIn.add(keyInfo1);
+        keyInfoSetIn.add(keyInfo0);
+        pfDao.createCollection(keyInfoSetIn);
+        keyInfoSetOut = new TreeSet<DummyConceptEntity>(pfDao.getAll(DummyConceptEntity.class));
+        assertTrue(keyInfoSetIn.equals(keyInfoSetOut));
+
+        pfDao.deleteAll(DummyConceptEntity.class);
+        assertEquals(0, pfDao.size(DummyConceptEntity.class));
+
+        final PfConceptKey owner0Key = new PfConceptKey("Owner0", "0.0.1");
+        final PfConceptKey owner1Key = new PfConceptKey("Owner1", "0.0.1");
+        final PfConceptKey owner2Key = new PfConceptKey("Owner2", "0.0.1");
+        final PfConceptKey owner3Key = new PfConceptKey("Owner3", "0.0.1");
+        final PfConceptKey owner4Key = new PfConceptKey("Owner4", "0.0.1");
+        final PfConceptKey owner5Key = new PfConceptKey("Owner5", "0.0.1");
+
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner0Key, "Entity0"), 100.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner0Key, "Entity1"), 101.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner0Key, "Entity2"), 102.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner0Key, "Entity3"), 103.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner0Key, "Entity4"), 104.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner1Key, "Entity5"), 105.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner1Key, "Entity6"), 106.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner1Key, "Entity7"), 107.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner2Key, "Entity8"), 108.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner2Key, "Entity9"), 109.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner3Key, "EntityA"), 110.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner4Key, "EntityB"), 111.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner5Key, "EntityC"), 112.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner5Key, "EntityD"), 113.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner5Key, "EntityE"), 114.0));
+        pfDao.create(new DummyReferenceEntity(new PfReferenceKey(owner5Key, "EntityF"), 115.0));
+
+        TreeSet<DummyReferenceEntity> testEntitySetOut =
+                new TreeSet<DummyReferenceEntity>(pfDao.getAll(DummyReferenceEntity.class));
+        assertEquals(16, testEntitySetOut.size());
+
+        testEntitySetOut = new TreeSet<DummyReferenceEntity>(pfDao.getAll(DummyReferenceEntity.class, owner0Key));
+        assertEquals(5, testEntitySetOut.size());
+
+        testEntitySetOut = new TreeSet<DummyReferenceEntity>(pfDao.getAll(DummyReferenceEntity.class, owner1Key));
+        assertEquals(3, testEntitySetOut.size());
+
+        testEntitySetOut = new TreeSet<DummyReferenceEntity>(pfDao.getAll(DummyReferenceEntity.class, owner2Key));
+        assertEquals(2, testEntitySetOut.size());
+
+        testEntitySetOut = new TreeSet<DummyReferenceEntity>(pfDao.getAll(DummyReferenceEntity.class, owner3Key));
+        assertEquals(1, testEntitySetOut.size());
+
+        testEntitySetOut = new TreeSet<DummyReferenceEntity>(pfDao.getAll(DummyReferenceEntity.class, owner4Key));
+        assertEquals(1, testEntitySetOut.size());
+
+        testEntitySetOut = new TreeSet<DummyReferenceEntity>(pfDao.getAll(DummyReferenceEntity.class, owner5Key));
+        assertEquals(4, testEntitySetOut.size());
+
+        assertNotNull(pfDao.get(DummyReferenceEntity.class, new PfReferenceKey(owner0Key, "Entity0")));
+        assertNotNull(pfDao.getConcept(DummyReferenceEntity.class, new PfReferenceKey(owner0Key, "Entity0")));
+        assertNull(pfDao.get(DummyReferenceEntity.class, new PfReferenceKey(owner0Key, "Entity1000")));
+        assertNull(pfDao.getConcept(DummyReferenceEntity.class, new PfReferenceKey(owner0Key, "Entity1000")));
+        pfDao.delete(DummyReferenceEntity.class, new PfReferenceKey(owner0Key, "Entity0"));
+
+        final Set<PfReferenceKey> rKeySetIn = new TreeSet<PfReferenceKey>();
+        rKeySetIn.add(new PfReferenceKey(owner4Key, "EntityB"));
+        rKeySetIn.add(new PfReferenceKey(owner5Key, "EntityD"));
+
+        final int deletedRCount = pfDao.deleteByReferenceKey(DummyReferenceEntity.class, rKeySetIn);
+        assertEquals(2, deletedRCount);
+
+        pfDao.update(new DummyReferenceEntity(new PfReferenceKey(owner5Key, "EntityF"), 120.0));
+    }
+}
diff --git a/models-dao/src/test/resources/META-INF/persistence.xml b/models-dao/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..1f430bc
--- /dev/null
+++ b/models-dao/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ============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=========================================================
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
+    <persistence-unit name="DaoTest" transaction-type="RESOURCE_LOCAL">
+        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+
+        <class>org.onap.policy.models.dao.converters.CDataConditioner</class>
+        <class>org.onap.policy.models.dao.converters.Uuid2String</class>
+        <class>org.onap.policy.models.base.concepts.PfConcepttKey</class>
+        <class>org.onap.policy.models.dao.DummyConceptEntity</class>
+        <class>org.onap.policy.models.dao.DummyReferenceEntity</class>
+
+        <properties>
+            <property name="javax.persistence.jdbc.driver" value="org.h2.Driver" />
+            <property name="javax.persistence.jdbc.url" value="jdbc:h2:mem:testdb" />
+            <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>
diff --git a/models-dao/src/test/resources/logback-test.xml b/models-dao/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..f0c510c
--- /dev/null
+++ b/models-dao/src/test/resources/logback-test.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ============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=========================================================
+-->
+
+<configuration>
+
+    <contextName>PolicyModels</contextName>
+    <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
+    <property name="LOG_DIR" value="${java.io.tmpdir}/onap_policy_logging/" />
+
+    <!-- USE FOR STD OUT ONLY -->
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+        </encoder>
+    </appender>
+
+    <root level="INFO">
+        <appender-ref ref="STDOUT" />
+    </root>
+
+    <logger name="org.infinispan" level="INFO" additivity="false">
+        <appender-ref ref="STDOUT" />
+    </logger>
+
+    <logger name="org.apache.zookeeper.ClientCnxn" level="OFF" additivity="false">
+        <appender-ref ref="STDOUT" />
+    </logger>
+
+    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+        <file>${LOG_DIR}/models.log</file>
+        <encoder>
+            <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
+                %logger{26} - %msg %n %ex{full}</pattern>
+        </encoder>
+    </appender>
+
+    <logger name="org.onap.policy.models.dao" level="INFO" additivity="false">
+        <appender-ref ref="STDOUT" />
+    </logger>
+</configuration>