Replace uses of getCanonicalName() with getName() in APEX
[policy/apex-pdp.git] / plugins / plugins-persistence / plugins-persistence-jpa / plugins-persistence-jpa-eclipselink / src / test / java / org / onap / policy / apex / plugins / persistence / jpa / eclipselink / EclipselinkApexDaoTest.java
index d33621e..de3a39e 100644 (file)
@@ -5,15 +5,15 @@
  * 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=========================================================
  */
@@ -32,32 +32,37 @@ import java.util.List;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.onap.policy.apex.context.test.entities.ArtifactKeyTestEntity;
-import org.onap.policy.apex.context.test.entities.ReferenceKeyTestEntity;
 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.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
- * 
+ * 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 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 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.getCanonicalName());
+        daoParameters.setPluginClass(EclipselinkApexDao.class.getName());
         daoParameters.setPersistenceUnit("DAOTest");
         eclipselinkApexDao = new EclipselinkApexDao();
         eclipselinkApexDao.init(daoParameters);
@@ -115,7 +120,6 @@ public class EclipselinkApexDaoTest {
         }
     }
 
-
     @Test
     public void test_getArtifactByReferenceKey() {
         final AxArtifactKey artifactKey = new AxArtifactKey("XXX", "0.0.1");
@@ -133,12 +137,11 @@ public class EclipselinkApexDaoTest {
         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);
+        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");
@@ -152,12 +155,12 @@ public class EclipselinkApexDaoTest {
         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);
+        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
@@ -177,7 +180,6 @@ public class EclipselinkApexDaoTest {
         assertEquals(100.0, remainingEntities.get(0).getDoubleValue(), 0.0);
     }
 
-
     @Test
     public void test_deleteByReferenceKey() {
         // prepare 2 AxArtifactKeys
@@ -185,9 +187,12 @@ public class EclipselinkApexDaoTest {
         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")});
+        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");
@@ -218,7 +223,6 @@ public class EclipselinkApexDaoTest {
         assertEquals(0, eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class).size());
     }
 
-
     @Test
     public void test_getAllByArtifactKey() {
 
@@ -228,7 +232,6 @@ public class EclipselinkApexDaoTest {
         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));
         assertTrue(eclipselinkApexDao.getAll(null, artiKey1).equals(Collections.emptyList()));
@@ -246,6 +249,4 @@ public class EclipselinkApexDaoTest {
         assertEquals(200.0, retEntity.getDoubleValue(), 0);
     }
 
-
-
 }