Change getCanonicalName to getName in models 03/90103/1
authorJim Hahn <jrh3@att.com>
Tue, 18 Jun 2019 16:47:14 +0000 (12:47 -0400)
committerJim Hahn <jrh3@att.com>
Tue, 18 Jun 2019 16:49:11 +0000 (12:49 -0400)
Per javadocs, getName() should generally be used instead of
Class.getCanonicalName(). This change only applies to classes; it
does not apply to File objects.

Note: this impacts the output from PfValidationMessage, as it will
now list the names of embedded classes with a "$" separator instead
of a ".".

Change-Id: I2cd64bc0281dd324bf80eac57335a7299a516447
Issue-ID: POLICY-1646
Signed-off-by: Jim Hahn <jrh3@att.com>
21 files changed:
models-base/src/main/java/org/onap/policy/models/base/PfValidationMessage.java
models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java
models-base/src/test/java/org/onap/policy/models/base/ValidationTest.java
models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java
models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java
models-interactions/model-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java
models-interactions/model-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java
models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java
models-pdp/src/test/java/org/onap/policy/models/pdp/persistence/provider/PdpProviderTest.java
models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderFactory.java
models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java
models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/DmaapSimCommandLineArguments.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorCommandLineArguments.java
models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java
models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyGuardTest.java
models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider4LegacyOperationalTest.java
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProviderTest.java
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java

index 708bfdd..cd8b08b 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 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.
@@ -50,7 +51,7 @@ public class PfValidationMessage {
         Assertions.argumentNotNull(message, "message may not be null");
 
         this.observedKey = observedKey;
-        this.observedClass = observedClass.getCanonicalName();
+        this.observedClass = observedClass.getName();
         this.validationResult = validationResult;
         this.message = message;
     }
index 120ddbf..6461223 100644 (file)
@@ -290,13 +290,13 @@ public class ValidatedTest {
 
         // check first item
         PfValidationMessage msg = it.next();
-        assertEquals(MyValid.class.getName().replace('$', '.'), msg.getObservedClass());
+        assertEquals(MyValid.class.getName(), msg.getObservedClass());
         assertEquals(MY_TO_STRING, msg.getObservedKey().toString());
         assertTrue(msg.getMessage().contains("index.0 invalid-wrong value"));
 
         // check null value
         msg = it.next();
-        assertEquals(MyValid.class.getName().replace('$', '.'), msg.getObservedClass());
+        assertEquals(MyValid.class.getName(), msg.getObservedClass());
         assertEquals(MY_TO_STRING, msg.getObservedKey().toString());
         assertTrue(msg.getMessage().contains("index.2 invalid-wrong value"));
 
@@ -327,13 +327,13 @@ public class ValidatedTest {
 
         // check first item
         PfValidationMessage msg = it.next();
-        assertEquals(MyConcept.class.getName().replace('$', '.'), msg.getObservedClass());
+        assertEquals(MyConcept.class.getName(), msg.getObservedClass());
         assertEquals(MY_TO_STRING, msg.getObservedKey().toString());
         assertTrue(msg.getMessage().contains("index.0 invalid-wrong value"));
 
         // check null value
         msg = it.next();
-        assertEquals(MyConcept.class.getName().replace('$', '.'), msg.getObservedClass());
+        assertEquals(MyConcept.class.getName(), msg.getObservedClass());
         assertEquals(MY_TO_STRING, msg.getObservedKey().toString());
         assertTrue(msg.getMessage().contains("index.2 invalid-wrong value"));
 
index ef0d8d6..d536e40 100644 (file)
@@ -88,7 +88,7 @@ public class ValidationTest {
 
         assertEquals(PfValidationResult.ValidationResult.INVALID, result.getMessageList().get(3).getValidationResult());
         assertEquals(SOME_MESSAGE, result.getMessageList().get(3).getMessage());
-        assertEquals(PfConceptKey.class.getCanonicalName(), result.getMessageList().get(3).getObservedClass());
+        assertEquals(PfConceptKey.class.getName(), result.getMessageList().get(3).getObservedClass());
         assertEquals(PfConceptKey.getNullKey(), result.getMessageList().get(3).getObservedKey());
     }
 }
index c44d05f..b5739a6 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 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.
@@ -330,7 +331,7 @@ public class DefaultPfDao implements PfDao {
                     t.copyTo(clonedT);
                     return clonedT;
                 } catch (final Exception e) {
-                    LOGGER.warn("Could not clone object of class \"" + someClass.getCanonicalName() + "\"", e);
+                    LOGGER.warn("Could not clone object of class \"" + someClass.getName() + "\"", e);
                     return null;
                 }
             } else {
@@ -355,7 +356,7 @@ public class DefaultPfDao implements PfDao {
                     t.copyTo(clonedT);
                     return clonedT;
                 } catch (final Exception e) {
-                    LOGGER.warn("Could not clone object of class \"" + someClass.getCanonicalName() + "\"", e);
+                    LOGGER.warn("Could not clone object of class \"" + someClass.getName() + "\"", e);
                     return null;
                 }
             } else {
index e7a505d..70505aa 100644 (file)
@@ -93,7 +93,7 @@ public class EntityTest {
     public void testEntityTestAllOpsJpa() throws PfModelException {
 
         final DaoParameters daoParameters = new DaoParameters();
-        daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
+        daoParameters.setPluginClass(DefaultPfDao.class.getName());
         daoParameters.setPersistenceUnit("DaoTest");
 
         Properties jdbcProperties = new Properties();
@@ -119,7 +119,7 @@ public class EntityTest {
     @Test
     public void testEntityTestBadVals() throws PfModelException {
         final DaoParameters daoParameters = new DaoParameters();
-        daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
+        daoParameters.setPluginClass(DefaultPfDao.class.getName());
         daoParameters.setPersistenceUnit("DaoTest");
 
         pfDao = new PfDaoFactory().createPfDao(daoParameters);
index 61d9ed4..0b61991 100644 (file)
@@ -124,7 +124,7 @@ public class ControlLoopPolicyTest {
     }
 
     public void dump(Object obj) {
-        logger.debug("Dumping ", obj.getClass().getCanonicalName());
+        logger.debug("Dumping ", obj.getClass().getName());
         logger.debug("{}", obj);
     }
 }
index d90f541..3d4cb37 100644 (file)
@@ -154,7 +154,7 @@ public class ControlLoopGuardTest {
     }
 
     public void dump(Object obj) {
-        logger.debug("Dumping {}", obj.getClass().getCanonicalName());
+        logger.debug("Dumping {}", obj.getClass().getName());
         logger.debug("{}", obj);
     }
 }
index 1e77c09..36d5cc1 100644 (file)
@@ -285,7 +285,7 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative<PdpGroup> {
             return 0;
         }
         if (getClass() != otherConcept.getClass()) {
-            return this.getClass().getCanonicalName().compareTo(otherConcept.getClass().getCanonicalName());
+            return this.getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaPdpGroup other = (JpaPdpGroup) otherConcept;
index 5cbbaaa..824c0a4 100644 (file)
@@ -76,7 +76,7 @@ public class PdpProviderTest {
     @Before
     public void setupDao() throws Exception {
         final DaoParameters daoParameters = new DaoParameters();
-        daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
+        daoParameters.setPluginClass(DefaultPfDao.class.getName());
 
         daoParameters.setPersistenceUnit("ToscaConceptTest");
 
index 86551b3..4ba70fb 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 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.
@@ -59,7 +60,7 @@ public class PolicyModelsProviderFactory {
 
         // It is, now check if it is a PolicyModelsProvider
         if (!PolicyModelsProvider.class.isAssignableFrom(implementationClass)) {
-            String errorMessage = "the class \"" + implementationClass.getCanonicalName()
+            String errorMessage = "the class \"" + implementationClass.getName()
                     + "\" is not an implementation of the \"PolicyModelsProvider\" interface";
             LOGGER.warn(errorMessage);
             throw new PfModelException(Response.Status.BAD_REQUEST, errorMessage);
index 65aa72e..fa4d663 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 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.
@@ -51,7 +52,7 @@ import org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl;
 
 @Data
 public class PolicyModelsProviderParameters implements ParameterGroup {
-    private static final String DEFAULT_IMPLEMENTATION = DatabasePolicyModelsProviderImpl.class.getCanonicalName();
+    private static final String DEFAULT_IMPLEMENTATION = DatabasePolicyModelsProviderImpl.class.getName();
 
     private String name;
     private String implementation = DEFAULT_IMPLEMENTATION;
index af1a6ca..565eb9a 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 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.
@@ -94,7 +95,7 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
 
         // Parameters for the DAO
         final DaoParameters daoParameters = new DaoParameters();
-        daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
+        daoParameters.setPluginClass(DefaultPfDao.class.getName());
         daoParameters.setPersistenceUnit(parameters.getPersistenceUnit());
 
         // Decode the password using Base64
index e05c106..e30cea9 100644 (file)
@@ -55,7 +55,7 @@ public class DummyPolicyModelsProviderTest {
     @Test
     public void testProvider() throws Exception {
         PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
-        parameters.setImplementation(DummyPolicyModelsProviderImpl.class.getCanonicalName());
+        parameters.setImplementation(DummyPolicyModelsProviderImpl.class.getName());
         parameters.setDatabaseUrl("jdbc:dummy");
         parameters.setPersistenceUnit("dummy");
 
@@ -74,7 +74,7 @@ public class DummyPolicyModelsProviderTest {
     @Test
     public void testProviderMethods() throws Exception {
         PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
-        parameters.setImplementation(DummyPolicyModelsProviderImpl.class.getCanonicalName());
+        parameters.setImplementation(DummyPolicyModelsProviderImpl.class.getName());
         parameters.setDatabaseUrl("jdbc:dummy");
         parameters.setPersistenceUnit("dummy");
 
index c0db8a7..cf559f7 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 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.
@@ -124,7 +125,7 @@ public class DmaapSimCommandLineArguments {
         }
 
         if (commandLine.hasOption('h')) {
-            return help(Main.class.getCanonicalName());
+            return help(Main.class.getName());
         }
 
         if (commandLine.hasOption('v')) {
index fb517e2..50d2bd2 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 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.
@@ -139,7 +140,7 @@ public class PdpSimulatorCommandLineArguments {
         }
 
         if (commandLine.hasOption('h')) {
-            return help(Main.class.getCanonicalName());
+            return help(Main.class.getName());
         }
 
         if (commandLine.hasOption('v')) {
index 6c87d76..8b9003b 100644 (file)
@@ -73,7 +73,7 @@ public class AuthorativeToscaProviderPolicyTest {
     @Before
     public void setupDao() throws Exception {
         final DaoParameters daoParameters = new DaoParameters();
-        daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
+        daoParameters.setPluginClass(DefaultPfDao.class.getName());
 
         daoParameters.setPersistenceUnit("ToscaConceptTest");
 
index c2b3879..8bed1e4 100644 (file)
@@ -88,7 +88,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
     @Before
     public void setupDao() throws Exception {
         final DaoParameters daoParameters = new DaoParameters();
-        daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
+        daoParameters.setPluginClass(DefaultPfDao.class.getName());
 
         daoParameters.setPersistenceUnit("ToscaConceptTest");
 
index 59605ed..cc510b7 100644 (file)
@@ -70,7 +70,7 @@ public class LegacyProvider4LegacyGuardTest {
     @Before
     public void setupDao() throws Exception {
         final DaoParameters daoParameters = new DaoParameters();
-        daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
+        daoParameters.setPluginClass(DefaultPfDao.class.getName());
 
         daoParameters.setPersistenceUnit("ToscaConceptTest");
 
index dfbba44..4dd998e 100644 (file)
@@ -65,7 +65,7 @@ public class LegacyProvider4LegacyOperationalTest {
     @Before
     public void setupDao() throws Exception {
         final DaoParameters daoParameters = new DaoParameters();
-        daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
+        daoParameters.setPluginClass(DefaultPfDao.class.getName());
 
         daoParameters.setPersistenceUnit("ToscaConceptTest");
 
index 5e7e8fd..a3e3ba5 100644 (file)
@@ -67,7 +67,7 @@ public class SimpleToscaProviderTest {
     @Before
     public void setupDao() throws Exception {
         final DaoParameters daoParameters = new DaoParameters();
-        daoParameters.setPluginClass(DefaultPfDao.class.getCanonicalName());
+        daoParameters.setPluginClass(DefaultPfDao.class.getName());
 
         daoParameters.setPersistenceUnit("ToscaConceptTest");
 
index aa4fc95..20ba756 100644 (file)
@@ -205,7 +205,7 @@ public class MonitoringPolicyTypeSerializationTest {
                 firstDataTypeFirstProperty.getDescription());
         assertTrue(firstDataTypeFirstProperty.getConstraints().size() == 1);
         assertEquals("org.onap.policy.models.tosca.simple.concepts.JpaToscaConstraintValidValues",
-                firstDataTypeFirstProperty.getConstraints().iterator().next().getClass().getCanonicalName());
+                firstDataTypeFirstProperty.getConstraints().iterator().next().getClass().getName());
         assertTrue(((JpaToscaConstraintValidValues) (firstDataTypeFirstProperty.getConstraints().iterator().next()))
                 .getValidValues().size() == 2);