Changed identifiers to concept identifiers
[policy/models.git] / models-pdp / src / test / java / org / onap / policy / models / pdp / persistence / provider / PdpProviderTest.java
index c4a7a3d..d57204a 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019 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.
@@ -36,6 +36,7 @@ import org.junit.Test;
 import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.models.base.PfModelException;
+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;
@@ -48,8 +49,7 @@ import org.onap.policy.models.pdp.concepts.PdpStatistics;
 import org.onap.policy.models.pdp.concepts.PdpSubGroup;
 import org.onap.policy.models.pdp.enums.PdpHealthStatus;
 import org.onap.policy.models.pdp.enums.PdpState;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider;
 
 /**
@@ -88,7 +88,7 @@ public class PdpProviderTest {
         jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_DRIVER, "org.h2.Driver");
         jdbcProperties.setProperty(PersistenceUnitProperties.JDBC_URL, "jdbc:h2:mem:testdb");
 
-        daoParameters.setJdbcProperties(jdbcProperties );
+        daoParameters.setJdbcProperties(jdbcProperties);
 
         pfDao = new PfDaoFactory().createPfDao(daoParameters);
         pfDao.init(daoParameters);
@@ -152,11 +152,11 @@ public class PdpProviderTest {
 
         assertEquals(5, new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()).size());
 
-        List<ToscaPolicyTypeIdentifier> policyTypeList = new ArrayList<>();
-        policyTypeList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3"));
+        List<ToscaConceptIdentifier> policyTypeList = new ArrayList<>();
+        policyTypeList.add(new ToscaConceptIdentifier("policy.type.0", "1.2.3"));
 
-        List<ToscaPolicyIdentifier> policyList = new ArrayList<>();
-        policyList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6"));
+        List<ToscaConceptIdentifier> policyList = new ArrayList<>();
+        policyList.add(new ToscaConceptIdentifier("Policy0", "4.5.6"));
 
         // @formatter:off
         final PdpGroupFilter filter = PdpGroupFilter.builder()
@@ -204,7 +204,8 @@ public class PdpProviderTest {
         pdpGroups0.getGroups().get(0).setPdpGroupState(null);
         assertThatThrownBy(() -> {
             new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups());
-        }).hasMessageContaining("INVALID:pdpGroupState may not be null");
+        }).hasMessageContaining("PDP group").hasMessageContaining("pdpGroupState")
+                        .hasMessageContaining(Validated.IS_NULL);
     }
 
     @Test
@@ -269,7 +270,8 @@ public class PdpProviderTest {
         pdpGroups0.getGroups().get(0).setPdpGroupState(null);
         assertThatThrownBy(() -> {
             new PdpProvider().updatePdpGroups(pfDao, pdpGroups0.getGroups());
-        }).hasMessageContaining("INVALID:pdpGroupState may not be null");
+        }).hasMessageContaining("PDP group").hasMessageContaining("pdpGroupState")
+                    .hasMessageContaining(Validated.IS_NULL);
     }
 
     @Test
@@ -375,7 +377,8 @@ public class PdpProviderTest {
         existingSubGroup.setDesiredInstanceCount(-1);
         assertThatThrownBy(() -> {
             new PdpProvider().updatePdpSubGroup(pfDao, PDP_GROUP0, existingSubGroup);
-        }).hasMessageContaining("INVALID:the desired instance count of a PDP sub group may not be negative");
+        }).hasMessageContaining("PDP sub group").hasMessageContaining("desiredInstanceCount")
+                        .hasMessageContaining("below the minimum value");
         existingSubGroup.setDesiredInstanceCount(10);
     }
 
@@ -473,7 +476,7 @@ public class PdpProviderTest {
         existingPdp.setMessage("");
         assertThatThrownBy(() -> {
             new PdpProvider().updatePdp(pfDao, PDP_GROUP0, "APEX", existingPdp);
-        }).hasMessageContaining("INVALID:message may not be blank");
+        }).hasMessageContaining("PDP").hasMessageContaining("message").hasMessageContaining(Validated.IS_BLANK);
         existingPdp.setMessage("A Message");
     }