Refactor models for common type handling
[policy/models.git] / models-tosca / src / test / java / org / onap / policy / models / tosca / simple / provider / SimpleToscaProviderTest.java
index 3c363b3..07624ae 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019-2020 Nordix Foundation.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ *  Copyright (C) 2019-2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2019-2020 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.
@@ -38,6 +38,7 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
 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.base.Validated;
 import org.onap.policy.models.dao.DaoParameters;
 import org.onap.policy.models.dao.PfDao;
 import org.onap.policy.models.dao.PfDaoFactory;
@@ -399,13 +400,12 @@ public class SimpleToscaProviderTest {
 
         assertThatThrownBy(() -> {
             originalServiceTemplate.fromAuthorative(toscaServiceTemplate);
-        }).hasMessage("PolicyType type not specified, the type of the PolicyType for this policy must be "
-                + "specified in the type field");
+        }).hasMessage("Type not specified, the type of this TOSCA entity must be specified in the type field");
 
         toscaPolicy.setType("IDontExist");
         assertThatThrownBy(() -> {
             originalServiceTemplate.fromAuthorative(toscaServiceTemplate);
-        }).hasMessage("PolicyType version not specified, the version of the PolicyType for this policy must be "
+        }).hasMessage("Version not specified, the version of this TOSCA entity must be "
                 + "specified in the type_version field");
 
         toscaPolicy.setTypeVersion("hello");
@@ -418,7 +418,8 @@ public class SimpleToscaProviderTest {
 
         assertThatThrownBy(() -> {
             new SimpleToscaProvider().createPolicies(pfDao, originalServiceTemplate);
-        }).hasMessageContaining("policy type IDontExist:99.100.101 referenced in policy not found");
+        }).hasMessageContaining("policy type").hasMessageContaining("IDontExist:99.100.101")
+                .hasMessageContaining(Validated.NOT_FOUND);
 
         toscaPolicy.setType("IDontExist");
         originalServiceTemplate.fromAuthorative(toscaServiceTemplate);
@@ -427,8 +428,7 @@ public class SimpleToscaProviderTest {
 
         assertThatThrownBy(() -> {
             originalServiceTemplate.fromAuthorative(toscaServiceTemplate);
-        }).hasMessage("PolicyType type not specified, the type of the PolicyType for this policy must be "
-                + "specified in the type field");
+        }).hasMessage("Type not specified, the type of this TOSCA entity must be specified in the type field");
 
         toscaPolicy.setType(originalPolicyType);
         toscaPolicy.setTypeVersion(originalPolicyTypeVersion);
@@ -523,8 +523,8 @@ public class SimpleToscaProviderTest {
         serviceTemplateFragment.getPolicyTypes().getConceptMap().put(badPt.getKey(), badPt);
 
         assertThatThrownBy(() -> new SimpleToscaProvider().appendToServiceTemplate(pfDao, serviceTemplateFragment))
-                .hasMessageContaining(
-                        "key on concept entry PfConceptKey(name=NULL, version=0.0.0) may not be the null key");
+                .hasMessageContaining("key on concept entry").hasMessageContaining("NULL:0.0.0")
+                .hasMessageContaining(Validated.IS_A_NULL_KEY);
     }
 
     @Test