Add missing fields to initial subgroups 22/85522/2
authorJim Hahn <jrh3@att.com>
Tue, 16 Apr 2019 22:08:54 +0000 (18:08 -0400)
committerJim Hahn <jrh3@att.com>
Tue, 16 Apr 2019 22:14:31 +0000 (18:14 -0400)
Some required fields were missing from the subgroups in the
inital DB.  Also added code to validate what is initially loaded into
the DB.

Change-Id: Iffa56a5a0dee833691d1bb7859b075c3b4d86595
Issue-ID: POLICY-1542
Signed-off-by: Jim Hahn <jrh3@att.com>
main/src/main/java/org/onap/policy/pap/main/startstop/PapDatabaseInitializer.java
main/src/main/resources/PapDb.json

index 7c1e2e8..affe1e9 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 AT&T Intellectual Property.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,7 +22,7 @@
 package org.onap.policy.pap.main.startstop;
 
 import java.util.List;
-
+import org.onap.policy.common.parameters.ValidationResult;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -71,6 +72,10 @@ public class PapDatabaseInitializer {
             final List<PdpGroup> pdpGroupsFromDb = databaseProvider.getPdpGroups(
                     pdpGroupsToCreate.getGroups().get(0).getName());
             if (pdpGroupsFromDb.isEmpty()) {
+                ValidationResult result = pdpGroupsToCreate.validatePapRest();
+                if (!result.isValid()) {
+                    throw new PolicyPapException(result.getResult());
+                }
                 databaseProvider.createPdpGroups(pdpGroupsToCreate.getGroups());
                 LOGGER.debug("Created initial pdpGroup in DB - {}", pdpGroupsToCreate);
             } else {
index c6452cc..6df3fc9 100644 (file)
@@ -15,7 +15,8 @@
             }
           ],
           "currentInstanceCount": 0,
-          "desiredInstanceCount": 1
+          "desiredInstanceCount": 1,
+          "policies": []
         },
         {
           "pdpType": "drools",
@@ -26,7 +27,8 @@
             }
           ],
           "currentInstanceCount": 0,
-          "desiredInstanceCount": 1
+          "desiredInstanceCount": 1,
+          "policies": []
         },
         {
           "pdpType": "apex",
@@ -37,7 +39,8 @@
             }
           ],
           "currentInstanceCount": 0,
-          "desiredInstanceCount": 1
+          "desiredInstanceCount": 1,
+          "policies": []
         }
       ]
     },
@@ -56,7 +59,8 @@
             }
           ],
           "currentInstanceCount": 0,
-          "desiredInstanceCount": 1
+          "desiredInstanceCount": 1,
+          "policies": []
         }
       ]
     }