summaryrefslogtreecommitdiffstats
path: root/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap
diff options
context:
space:
mode:
authorLori Keighron <lk2924@att.com>2019-02-11 17:21:37 -0500
committerTakamune Cho <takamune.cho@att.com>2019-02-14 16:28:17 +0000
commitc751a9532c263b542f7f420071c545844fa56dc7 (patch)
tree3336fee3eef71604bf9b4e7740446e6dec094c3a /appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap
parent796ca12ab0fba32db8b4a0dff4cc4e972652c35d (diff)
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 <lk2924@att.com>
Diffstat (limited to 'appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap')
-rw-r--r--appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/TestSequenceGeneratorPlugin.java193
-rw-r--r--appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/objects/SequenceGeneratorInputBuilderTest.java5
2 files changed, 166 insertions, 32 deletions
diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/TestSequenceGeneratorPlugin.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/TestSequenceGeneratorPlugin.java
index addd81a4b..5fddce12b 100644
--- a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/TestSequenceGeneratorPlugin.java
+++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/TestSequenceGeneratorPlugin.java
@@ -21,22 +21,21 @@
package org.onap.appc.seqgen;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
-import org.onap.appc.seqgen.dbservices.SequenceGeneratorDBServices;
import org.onap.appc.seqgen.dgplugin.SequenceGeneratorPlugin;
import org.onap.appc.seqgen.dgplugin.impl.SequenceGeneratorPluginImpl;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import static org.mockito.Mockito.mock;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
public class TestSequenceGeneratorPlugin {
@@ -243,7 +242,7 @@ public class TestSequenceGeneratorPlugin {
plugin.generateSequence(params,context);
String outputJSON = context.getAttribute("output");
- String actualOutput = readInput("/output/restart-NoDep.json");
+ String actualOutput = readOutput("/output/restart-NoDep.json");
outputJSON.trim();
Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
}
@@ -260,7 +259,7 @@ public class TestSequenceGeneratorPlugin {
plugin.generateSequence(params,context);
String outputJSON = context.getAttribute("output");
- String actualOutput = readInput("/output/restart-Nodep-SingleVM.json");
+ String actualOutput = readOutput("/output/restart-Nodep-SingleVM.json");
Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
}
@@ -350,26 +349,162 @@ public class TestSequenceGeneratorPlugin {
Assert.assertEquals(errorMessage,"Error generating sequence Dependency model missing vnfc type SMP");
}
- private String readInput(String inputFile) throws URISyntaxException, IOException {
- File file = new File(this.getClass().getResource(inputFile).toURI());
+ @Test
+ public void testGenerateSequenceStartWithVmStartCaps()throws URISyntaxException, IOException {
+ String inputJSON = readInput("/input/StartWithVmStartCaps.json");
- byte[] bFile = new byte[(int) file.length()];
- FileInputStream fileInputStream = new FileInputStream(file);
- fileInputStream.read(bFile);
- fileInputStream.close();
- return new String(bFile);
+ Map<String,String> params = new HashMap<>();
+ SvcLogicContext context = new SvcLogicContext();
+ context.setAttribute("inputJSON",inputJSON);
+
+ SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
+ plugin.generateSequence(params,context);
+
+ String actualOutput = context.getAttribute("output");
+ String outputJSON = readOutput("/output/StartWithVmStartCaps.json");
+ Assert.assertEquals(outputJSON.trim(), actualOutput.trim());
}
- private String readOutput(String outputFile) throws IOException,URISyntaxException {
- File file = new File(this.getClass().getResource(outputFile).toURI());
+
+ @Test
+ public void testGenerateSequenceRestartWithVmRestartCaps()throws URISyntaxException, IOException {
+ String inputJSON = readInput("/input/RestartWithVmRestartCaps.json");
+
+ Map<String,String> params = new HashMap<>();
+ SvcLogicContext context = new SvcLogicContext();
+ context.setAttribute("inputJSON",inputJSON);
+
+ SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
+ plugin.generateSequence(params,context);
- byte[] bFile = new byte[(int) file.length()];
- FileInputStream fileInputStream = new FileInputStream(file);
- fileInputStream.read(bFile);
- fileInputStream.close();
- String output=new String(bFile);
+ String outputJSON = context.getAttribute("output");
+ String actualOutput = readOutput("/output/RestartWithVmRestartCaps.json");
+ Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
+ }
+
+ @Test
+ public void testGenerateSequenceStopWithVmStopCaps()throws URISyntaxException, IOException {
+ String inputJSON = readInput("/input/StopWithVmStopCaps.json");
+
+ Map<String,String> params = new HashMap<>();
+ SvcLogicContext context = new SvcLogicContext();
+ context.setAttribute("inputJSON",inputJSON);
+
+ SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
+ plugin.generateSequence(params,context);
+
+ String actualOutput = context.getAttribute("output");
+ String outputJSON = readOutput("/output/StopWithVmStopCaps.json");
+ Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
+ }
+
+ @Test
+ public void testGenerateSequenceStartWithoutAnyCaps()throws URISyntaxException, IOException {
+ String inputJSON = readInput("/input/StartWithoutAnyCaps.json");
+
+ Map<String,String> params = new HashMap<>();
+ SvcLogicContext context = new SvcLogicContext();
+ context.setAttribute("inputJSON",inputJSON);
+
+ SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
+ plugin.generateSequence(params,context);
+
+ String actualOutput = context.getAttribute("output");
+ String outputJSON = readOutput("/output/StartWithoutAnyCaps.json");
+ Assert.assertEquals(outputJSON.trim(), actualOutput.trim());
+ }
+
+ @Test
+ public void testGenerateSequenceRestartWithoutAnyCaps()throws URISyntaxException, IOException {
+ String inputJSON = readInput("/input/RestartWithoutAnyCaps.json");
+
+ Map<String,String> params = new HashMap<>();
+ SvcLogicContext context = new SvcLogicContext();
+ context.setAttribute("inputJSON",inputJSON);
+
+ SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
+ plugin.generateSequence(params,context);
+
+ String outputJSON = context.getAttribute("output");
+ String actualOutput = readOutput("/output/RestartWithoutAnyCaps.json");
+ Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
+ }
+
+ @Test
+ public void testGenerateSequenceStopWithoutAnyCaps()throws URISyntaxException, IOException {
+ String inputJSON = readInput("/input/StopWithoutAnyCaps.json");
+
+ Map<String,String> params = new HashMap<>();
+ SvcLogicContext context = new SvcLogicContext();
+ context.setAttribute("inputJSON",inputJSON);
+
+ SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
+ plugin.generateSequence(params,context);
+
+ String outputJSON = context.getAttribute("output");
+ String actualOutput = readOutput("/output/StopWithoutAnyCaps.json");
+ Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
+ }
+ @Test
+ public void testGenerateSequenceStartWithoutVmStartCaps()throws URISyntaxException, IOException {
+ String inputJSON = readInput("/input/StartWithoutVmStartCaps.json");
+
+ Map<String,String> params = new HashMap<>();
+ SvcLogicContext context = new SvcLogicContext();
+ context.setAttribute("inputJSON",inputJSON);
+
+ SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
+ plugin.generateSequence(params,context);
+
+ String errorCode = context.getAttribute("error-code");
+ String errorMessage = context.getAttribute("error-message");
+ logger.debug("errorCode = " + errorCode);
+ Assert.assertEquals("450", errorCode);
+ Assert.assertEquals("Request is not supported", errorMessage);
+ }
+
+ @Test
+ public void testGenerateSequenceRestartWithoutVmRestartCaps()throws URISyntaxException, IOException {
+ String inputJSON = readInput("/input/RestartWithoutVmRestartCaps.json");
+
+ Map<String,String> params = new HashMap<>();
+ SvcLogicContext context = new SvcLogicContext();
+ context.setAttribute("inputJSON",inputJSON);
+
+ SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
+ plugin.generateSequence(params,context);
+
+ String errorCode = context.getAttribute("error-code");
+ String errorMessage = context.getAttribute("error-message");
+ logger.debug("errorCode = " + errorCode);
+ Assert.assertEquals("450", errorCode);
+ Assert.assertEquals("Request is not supported", errorMessage);
+ }
+
+ @Test
+ public void testGenerateSequenceStopWithoutVmStopCaps()throws URISyntaxException, IOException {
+ String inputJSON = readInput("/input/StopWithoutVmStopCaps.json");
+
+ Map<String,String> params = new HashMap<>();
+ SvcLogicContext context = new SvcLogicContext();
+ context.setAttribute("inputJSON",inputJSON);
+
+ SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
+ plugin.generateSequence(params,context);
+
+ String errorCode = context.getAttribute("error-code");
+ String errorMessage = context.getAttribute("error-message");
+ logger.debug("errorCode = " + errorCode);
+ Assert.assertEquals("450", errorCode);
+ Assert.assertEquals("Request is not supported", errorMessage);
+ }
+
+ private String readInput(String inputFile) throws URISyntaxException, IOException {
+ return new String(Files.readAllBytes(Paths.get(this.getClass().getResource(inputFile).toURI())), "UTF-8");
+ }
+
+ private String readOutput(String outputFile) throws IOException,URISyntaxException {
+ String output = new String(Files.readAllBytes(Paths.get(this.getClass().getResource(outputFile).toURI())), "UTF-8");
int start=output.indexOf("[");
return output.substring(start,output.length());
-
}
}
-
diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/objects/SequenceGeneratorInputBuilderTest.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/objects/SequenceGeneratorInputBuilderTest.java
index 0809930ca..8719125d8 100644
--- a/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/objects/SequenceGeneratorInputBuilderTest.java
+++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/test/java/org/onap/appc/seqgen/objects/SequenceGeneratorInputBuilderTest.java
@@ -54,9 +54,8 @@ public class SequenceGeneratorInputBuilderTest {
@Test
public void testCapability()
{
- String level= "testLevel";
- List<String> capabilities= new ArrayList<>();
- assertTrue(sequenceGeneratorInputBuilder.capability(level, capabilities) instanceof SequenceGeneratorInputBuilder);
+ CapabilityModel capabilities= new CapabilityModel();
+ assertTrue(sequenceGeneratorInputBuilder.capabilityModel(capabilities) instanceof SequenceGeneratorInputBuilder);
}