callnode handling updates
authorSmokowski, Kevin (ks6305) <kevin.smokowski@att.com>
Thu, 4 Oct 2018 18:55:57 +0000 (18:55 +0000)
committerKevin Smokowski <kevin.smokowski@att.com>
Fri, 5 Oct 2018 14:15:16 +0000 (14:15 +0000)
throw an exception if graph isnt found when executing a call node

Change-Id: I10158cbcd5ba5787e710bfb6161e7e04cbf46577
Issue-ID: CCSDK-609
Signed-off-by: Smokowski, Kevin (ks6305) <kevin.smokowski@att.com>
sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/CallNodeExecutor.java [changed mode: 0644->0755]
sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java
sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/ITCaseSvcLogicGraphExecutor.java

old mode 100644 (file)
new mode 100755 (executable)
index 6036c38..c8e6548
@@ -118,16 +118,18 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor {
         ctx.setAttribute("parentGraph", parentGraph);
 
                SvcLogicStore store = svc.getStore();
-
-        if (store != null) {
+               String errorMessage = "Parent " + parentGraph + " failed to call child [" + module + "," + rpc + "," + version + "," + mode + "] because the graph could not be found";
+               boolean graphWasCalled = false;
+               if (store != null) {
             SvcLogicGraph calledGraph = store.fetch(module, rpc, version, mode);
             if (calledGraph != null) {
                 LOG.debug("Parent " + parentGraph + " is calling child " + calledGraph.toString());
                 ctx.setAttribute("currentGraph", calledGraph.toString());
                 svc.execute(calledGraph, ctx);
                 outValue = ctx.getStatus();
+                graphWasCalled = true;
             } else {
-                LOG.debug("Parent " + parentGraph + " failed to call child [" + module + "," + rpc + "," + version + "," + mode + "] because the graph could not be found");
+                LOG.debug(errorMessage);
             }
         } else {
             LOG.debug("Could not get SvcLogicStore reference");
@@ -152,7 +154,18 @@ public class CallNodeExecutor extends SvcLogicNodeExecutor {
                                LOG.debug("no " + outValue + " or Other branch found");
                        }
                }
-        ctx.setAttribute("currentGraph", parentGraph);
+               
+               if (graphWasCalled == false) {
+                       if (node.getOutcomeValue("catch") != null) {
+                               nextNode = node.getOutcomeValue("catch");
+                               LOG.debug("graph could not be called, but catch node was found and will be executed");
+                       } else {
+                               LOG.debug("graph could not be called and no catch node was found, throwing exception");
+                               throw new SvcLogicException(errorMessage);
+                       }
+               }
+
+               ctx.setAttribute("currentGraph", parentGraph);
         ctx.setAttribute("parentGraph", null);
 
                return (nextNode);
index d83bfeb..15c4478 100644 (file)
@@ -180,28 +180,7 @@ public class SvcLogicServiceImpl implements SvcLogicService {
                     executor.getClass().getName());
             return (executor.execute(this, node, ctx));
         } else {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("{} node not implemented", node.getNodeType());
-            }
-            SvcLogicNode nextNode = node.getOutcomeValue("failure");
-            if (nextNode != null) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("about to execute failure branch");
-                }
-                return (nextNode);
-            }
-
-            nextNode = node.getOutcomeValue("Other");
-            if (nextNode != null) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("about to execute Other branch");
-                }
-            } else {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("no failure or Other branch found");
-                }
-            }
-            return (nextNode);
+            throw new SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type");
         }
     }
 
index d869886..445df36 100644 (file)
@@ -136,19 +136,21 @@ public class ITCaseSvcLogicGraphExecutor {
             Properties svcprops = new Properties();
             svcprops.load(propStr);
 
-            SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops);
 
 
-            assertNotNull(store);
-
 
             SvcLogicParser parser = new SvcLogicParser();
 
             // Loop through executor tests
-            SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProviderImpl();
-
+            SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProvider() {
+                @Override
+                public Properties getProperties() {
+                    return svcprops;
+                }
+            };
             SvcLogicServiceImpl svc = new SvcLogicServiceImpl(resourceProvider);
-
+            SvcLogicStore store = svc.getStore();
+            assertNotNull(store);
             for (String nodeType : BUILTIN_NODES.keySet()) {
 
                 LOG.info("SLI - registering node executor for node type {}", nodeType);
@@ -203,7 +205,17 @@ public class ITCaseSvcLogicGraphExecutor {
                     assertNotNull(graphs);
 
                     // Load grqphs into db to support call node
-                    parser.load(testCaseUrl.getPath(), store);
+                    SvcLogicParser.load(testCaseUrl.getPath(), store);
+                    SvcLogicParser.activate("neutron", "canCreateNetwork", "1.0.0", "sync", store);
+                    SvcLogicParser.activate("neutron", "switchTester", "1.0.0", "sync", store);
+                    SvcLogicParser.activate("neutron", "forRecordTester", "1.0.0", "sync", store);
+                    SvcLogicParser.activate("neutron", "whileNodeTester", "1.0.0", "sync", store);
+                    SvcLogicParser.activate("neutron", "resourceTester", "1.0.0", "sync", store);
+                    SvcLogicParser.activate("neutron", "configureTester", "1.0.0", "sync", store);
+                    SvcLogicParser.activate("neutron", "javaPluginTester", "1.0.0", "sync", store);
+                    SvcLogicParser.activate("neutron", "allNodesTester", "1.0.0", "sync", store);
+                    SvcLogicParser.activate("neutron", "networkCreated", "1.0.0", "sync", store);
+
                     for (SvcLogicGraph graph : graphs) {
                         if (graph.getRpc().equals(testCaseMethod)) {
                             Properties props = ctx.toProperties();