import java.util.Map;
import org.junit.Assert;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TestName;
import org.onap.appc.seqgen.dgplugin.SequenceGeneratorPlugin;
import org.onap.appc.seqgen.dgplugin.impl.SequenceGeneratorPluginImpl;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import com.att.eelf.configuration.EELFManager;
public class TestSequenceGeneratorPlugin {
+ @Rule
+ public final TestName thisTestName = new TestName();
private static final EELFLogger logger = EELFManager.getInstance().getLogger(TestSequenceGeneratorPlugin.class);
private SequenceGeneratorPlugin seqImpl;
@Test
public void testGenerateSequenceStart() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/start.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceWODependencyInfo()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/start-withoutDependency.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceSingleVM()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/start-singleVM-.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceNoStrategy() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/no-strategy.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceStop() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/stop.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceWrongNumber() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/wrongnumber.json");
Map<String,String> params = new HashMap<>();
String errorCode = context.getAttribute("error-code");
String errorMessage = context.getAttribute("error-message");
- logger.debug("errorCode = " + errorCode);
+ logger.info("errorCode = " + errorCode);
Assert.assertEquals(errorCode,"401");
Assert.assertEquals(errorMessage,"Error generating sequence Invalid Number for Wait Time 6a");
}
@Test
public void testGenerateSequenceCyclic() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/cyclic.json");
Map<String,String> params = new HashMap<>();
String errorCode = context.getAttribute("error-code");
String errorMessage = context.getAttribute("error-message");
- logger.debug("errorCode = " + errorCode);
+ logger.info("errorCode = " + errorCode);
Assert.assertEquals(errorCode,"401");
Assert.assertEquals(errorMessage,"Error generating sequence There seems to be no Root/Independent node for Vnfc dependencies");
}
@Test
public void testGenerateSequenceWrongAction() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/wrongaction.json");
Map<String,String> params = new HashMap<>();
String errorCode = context.getAttribute("error-code");
String errorMessage = context.getAttribute("error-message");
- logger.debug("errorCode = " + errorCode);
+ logger.info("errorCode = " + errorCode);
Assert.assertEquals(errorCode,"401");
Assert.assertEquals(errorMessage,"Error generating sequence Invalid Action start");
}
@Test
public void testGenerateSequenceMissingRequestInfo() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/missingrequestinfo.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceStopSingleVM() throws URISyntaxException, IOException{
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/stop-singleVM.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceStopSingleVmPerVnfc() throws URISyntaxException, IOException{
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/stop-singleVmPerVnfc.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceRestartNoDep() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/restartNodep.json");
Map<String,String> params = new HashMap<>();
SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
plugin.generateSequence(params,context);
- String outputJSON = context.getAttribute("output");
- String actualOutput = readOutput("/output/restart-NoDep.json");
+ String actualOutput = context.getAttribute("output");
+ String outputJSON = readOutput("/output/restart-NoDep.json");
outputJSON.trim();
Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
}
@Test
public void testGenerateSequenceRestartNoDepSingleVM() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/NoDep-SingleVM.json");
Map<String,String> params = new HashMap<>();
SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
plugin.generateSequence(params,context);
- String outputJSON = context.getAttribute("output");
- String actualOutput = readOutput("/output/restart-Nodep-SingleVM.json");
+ String actualOutput = context.getAttribute("output");
+ String outputJSON = readOutput("/output/restart-Nodep-SingleVM.json");
Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
}
@Test
public void testGenerateSequenceStartSingleVmPerVnfc() throws URISyntaxException, IOException{
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/start-singleVmPerVnfc-.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceVnfcNotPresentInInventory() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/CheckVNfcInInventory.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceCheckMandatoryVnfc() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/CheckMandatoryVnfc.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceCheckMissingDependencyInfo() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/MissingDependencyInfo.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceExtraVnfcInDependency() throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/WrongDependencyModel.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceStartWithVmStartCaps()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/StartWithVmStartCaps.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceRestartWithVmRestartCaps()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/RestartWithVmRestartCaps.json");
Map<String,String> params = new HashMap<>();
SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
plugin.generateSequence(params,context);
- String outputJSON = context.getAttribute("output");
- String actualOutput = readOutput("/output/RestartWithVmRestartCaps.json");
+ String actualOutput = context.getAttribute("output");
+ String outputJSON = readOutput("/output/RestartWithVmRestartCaps.json");
Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
}
@Test
public void testGenerateSequenceStopWithVmStopCaps()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/StopWithVmStopCaps.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceStartWithoutAnyCaps()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/StartWithoutAnyCaps.json");
Map<String,String> params = new HashMap<>();
@Test
public void testGenerateSequenceRestartWithoutAnyCaps()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/RestartWithoutAnyCaps.json");
Map<String,String> params = new HashMap<>();
SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
plugin.generateSequence(params,context);
- String outputJSON = context.getAttribute("output");
- String actualOutput = readOutput("/output/RestartWithoutAnyCaps.json");
+ String actualOutput = context.getAttribute("output");
+ String outputJSON = readOutput("/output/RestartWithoutAnyCaps.json");
Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
}
@Test
public void testGenerateSequenceStopWithoutAnyCaps()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/StopWithoutAnyCaps.json");
Map<String,String> params = new HashMap<>();
SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
plugin.generateSequence(params,context);
- String outputJSON = context.getAttribute("output");
- String actualOutput = readOutput("/output/StopWithoutAnyCaps.json");
+ String actualOutput = context.getAttribute("output");
+ String outputJSON = readOutput("/output/StopWithoutAnyCaps.json");
Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
}
+
@Test
public void testGenerateSequenceStartWithoutVmStartCaps()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/StartWithoutVmStartCaps.json");
Map<String,String> params = new HashMap<>();
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);
+ String actualOutput = context.getAttribute("output");
+ Assert.assertEquals(null, actualOutput);
}
@Test
public void testGenerateSequenceRestartWithoutVmRestartCaps()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/RestartWithoutVmRestartCaps.json");
Map<String,String> params = new HashMap<>();
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);
+ String actualOutput = context.getAttribute("output");
+ Assert.assertEquals(null, actualOutput);
}
@Test
public void testGenerateSequenceStopWithoutVmStopCaps()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
String inputJSON = readInput("/input/StopWithoutVmStopCaps.json");
Map<String,String> params = new HashMap<>();
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);
+ String actualOutput = context.getAttribute("output");
+ Assert.assertEquals(null, actualOutput);
+ }
+
+ @Test
+ public void testGenerateSequenceStartWithEmptyVmCaps()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
+ String inputJSON = readInput("/input/StartWithEmptyVmCaps.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 testGenerateSequenceRestartWithEmptyVmCaps()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
+ String inputJSON = readInput("/input/RestartWithEmptyVmCaps.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/RestartWithoutAnyCaps.json");
+ Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
+ }
+
+ @Test
+ public void testGenerateSequenceStopWithEmptyVmCaps()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
+ String inputJSON = readInput("/input/StopWithEmptyVmCaps.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/StopWithoutAnyCaps.json");
+ Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
+ }
+
+ @Test
+ public void testGenerateSequenceStartWithVmStartCapsAndMissingVnfcInfo()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
+ String inputJSON = readInput("/input/StartWithVmStartCapsAndMissingVnfcInfo.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/StartWithVmStartCapsAndMissingVnfcInfo.json");
+ Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
+ }
+
+ @Test
+ public void testGenerateSequenceStopWithVmStopCapsAndMissingVnfcInfo()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
+ String inputJSON = readInput("/input/StopWithVmStopCapsAndMissingVnfcInfo.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/StopWithVmStopCapsAndMissingVnfcInfo.json");
+ Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
+ }
+
+ @Test
+ public void testGenerateSequenceRestartWithVmRestartCapsAndMissingVnfcInfo()throws URISyntaxException, IOException {
+ logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
+
+ String inputJSON = readInput("/input/RestartWithVmRestartCapsAndMissingVnfcInfo.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/RestartWithVmRestartCapsAndMissingVnfcInfo.json");
+ Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
}
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("[");