From c751a9532c263b542f7f420071c545844fa56dc7 Mon Sep 17 00:00:00 2001 From: Lori Keighron Date: Mon, 11 Feb 2019 17:21:37 -0500 Subject: Check vm-capabilites on vnf-level OS requests New per-vm capabilities checking is introduced for vnf-level OpenStack actions Additional changes per initial review. Additional changes in TestVnfc.java per second review. Change-Id: Idd1d834df076c1e525f596b788b69ed63ba9e66b Issue-ID: APPC-1380 Signed-off-by: Lori Keighron --- .../flow/controller/node/FlowSequenceGenerator.java | 4 ++++ .../controller/node/FlowSequenceGeneratorTest.java | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'appc-config') diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowSequenceGenerator.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowSequenceGenerator.java index db5791305..276301ed3 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowSequenceGenerator.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowSequenceGenerator.java @@ -131,6 +131,10 @@ class FlowSequenceGenerator { flowSequence = output.toString(); log.info("MultistepSequenceGenerator-Output: " + flowSequence); + if (!flowSequence.contains("transactions")) { + throw new Exception("No transactions were generated for this request"); + } + } else if (sequenceType.equalsIgnoreCase(EXTERNAL)) { //String input = collectInputParams(localContext); // flowSequnce = ""; //get it from the External interface calling the Rest End point - TBD diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowSequenceGeneratorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowSequenceGeneratorTest.java index 533de5840..1846a0922 100644 --- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowSequenceGeneratorTest.java +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowSequenceGeneratorTest.java @@ -166,12 +166,28 @@ public class FlowSequenceGeneratorTest { when(ctx.getAttribute(VNF_ID)).thenReturn("some-vnf-id"); Map map = new HashMap<>(); - map.put("restResponse", "{'output':{'dummy-json-object':'some-param'}}".replaceAll("'", "\"")); + map.put("restResponse", "{'output':{'transactions':[{'transaction-id':'1','payload':''}]}}".replaceAll("'", "\"")); when(restExecutor.execute(any(Transaction.class), eq(localCtx))).thenReturn(map); String flowSequence = flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx); - Assert.assertEquals("{'dummy-json-object':'some-param'}".replaceAll("'", "\""), flowSequence); + //Assert.assertEquals("{'dummy-json-object':'some-param'}".replaceAll("'", "\""), flowSequence); + Assert.assertEquals("{'transactions':[{'transaction-id':'1','payload':''}]}".replaceAll("'", "\""), flowSequence); + } + + @Test + public void sequence_type_is_runtime_but_no_transactions_generated() throws Exception { + when(localCtx.getAttribute(SEQUENCE_TYPE)).thenReturn(RUNTIME); + when(ctx.getAttribute(VNF_TYPE)).thenReturn("some-vnf-type"); + when(ctx.getAttribute(VNF_ID)).thenReturn("some-vnf-id"); + + Map map = new HashMap<>(); + // {"status":{"code":450,"message":"Request is not supported"}} + map.put("restResponse", "{'output':{'status':{'code':450,'message':'Request is not supported'}}}".replaceAll("'", "\"")); + when(restExecutor.execute(any(Transaction.class), eq(localCtx))).thenReturn(map); + expectedException.expectMessage("No transactions were generated for this request"); + + String flowSequence = flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx); } @Test -- cgit 1.2.3-korg