2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.appc.seqgen;
24 import java.io.IOException;
25 import java.net.URISyntaxException;
26 import java.nio.file.Files;
27 import java.nio.file.Paths;
28 import java.util.HashMap;
31 import org.junit.Assert;
32 import org.junit.Rule;
33 import org.junit.Test;
34 import org.junit.rules.TestName;
35 import org.onap.appc.seqgen.dgplugin.SequenceGeneratorPlugin;
36 import org.onap.appc.seqgen.dgplugin.impl.SequenceGeneratorPluginImpl;
37 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
39 import com.att.eelf.configuration.EELFLogger;
40 import com.att.eelf.configuration.EELFManager;
42 public class TestSequenceGeneratorPlugin {
44 public final TestName thisTestName = new TestName();
46 private static final EELFLogger logger = EELFManager.getInstance().getLogger(TestSequenceGeneratorPlugin.class);
47 private SequenceGeneratorPlugin seqImpl;
50 public void testGenerateSequenceStart() throws URISyntaxException, IOException {
51 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
53 String inputJSON = readInput("/input/start.json");
55 Map<String,String> params = new HashMap<>();
56 SvcLogicContext context = new SvcLogicContext();
57 context.setAttribute("inputJSON",inputJSON);
59 seqImpl = new SequenceGeneratorPluginImpl();
60 seqImpl.generateSequence(params,context);
62 String outputJSON = context.getAttribute("output");
63 String actualOutput = readOutput("/output/Start2.json");
64 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
68 public void testGenerateSequenceWODependencyInfo()throws URISyntaxException, IOException {
69 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
71 String inputJSON = readInput("/input/start-withoutDependency.json");
73 Map<String,String> params = new HashMap<>();
74 SvcLogicContext context = new SvcLogicContext();
75 context.setAttribute("inputJSON",inputJSON);
77 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
78 plugin.generateSequence(params,context);
80 String outputJSON = context.getAttribute("output");
81 String actualOutput = readOutput("/output/start-withoutDependency.json");
82 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
86 public void testGenerateSequenceSingleVM()throws URISyntaxException, IOException {
87 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
89 String inputJSON = readInput("/input/start-singleVM-.json");
91 Map<String,String> params = new HashMap<>();
92 SvcLogicContext context = new SvcLogicContext();
93 context.setAttribute("inputJSON",inputJSON);
95 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
96 plugin.generateSequence(params,context);
98 String outputJSON = context.getAttribute("output");
99 String actualOutput = readOutput("/output/start-singleVM-.json");
100 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
104 public void testGenerateSequenceNoStrategy() throws URISyntaxException, IOException {
105 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
107 String inputJSON = readInput("/input/no-strategy.json");
109 Map<String,String> params = new HashMap<>();
110 SvcLogicContext context = new SvcLogicContext();
111 context.setAttribute("inputJSON",inputJSON);
113 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
114 plugin.generateSequence(params,context);
116 String outputJSON = context.getAttribute("output");
117 String actualOutput = readOutput("/output/Start2.json");
119 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
123 public void testGenerateSequenceStop() throws URISyntaxException, IOException {
124 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
126 String inputJSON = readInput("/input/stop.json");
128 Map<String,String> params = new HashMap<>();
129 SvcLogicContext context = new SvcLogicContext();
130 context.setAttribute("inputJSON",inputJSON);
132 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
133 plugin.generateSequence(params,context);
135 String outputJSON = context.getAttribute("output");
136 String actualOutput = readOutput("/output/Output-stop.json");
138 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
142 public void testGenerateSequenceWrongNumber() throws URISyntaxException, IOException {
143 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
145 String inputJSON = readInput("/input/wrongnumber.json");
147 Map<String,String> params = new HashMap<>();
148 SvcLogicContext context = new SvcLogicContext();
149 context.setAttribute("inputJSON",inputJSON);
151 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
152 plugin.generateSequence(params,context);
154 String errorCode = context.getAttribute("error-code");
155 String errorMessage = context.getAttribute("error-message");
156 logger.info("errorCode = " + errorCode);
157 Assert.assertEquals(errorCode,"401");
158 Assert.assertEquals(errorMessage,"Error generating sequence Invalid Number for Wait Time 6a");
163 public void testGenerateSequenceCyclic() throws URISyntaxException, IOException {
164 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
166 String inputJSON = readInput("/input/cyclic.json");
168 Map<String,String> params = new HashMap<>();
169 SvcLogicContext context = new SvcLogicContext();
170 context.setAttribute("inputJSON",inputJSON);
172 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
173 plugin.generateSequence(params,context);
175 String errorCode = context.getAttribute("error-code");
176 String errorMessage = context.getAttribute("error-message");
177 logger.info("errorCode = " + errorCode);
178 Assert.assertEquals(errorCode,"401");
179 Assert.assertEquals(errorMessage,"Error generating sequence There seems to be no Root/Independent node for Vnfc dependencies");
183 public void testGenerateSequenceWrongAction() throws URISyntaxException, IOException {
184 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
186 String inputJSON = readInput("/input/wrongaction.json");
188 Map<String,String> params = new HashMap<>();
189 SvcLogicContext context = new SvcLogicContext();
190 context.setAttribute("inputJSON",inputJSON);
192 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
193 plugin.generateSequence(params,context);
195 String errorCode = context.getAttribute("error-code");
196 String errorMessage = context.getAttribute("error-message");
197 logger.info("errorCode = " + errorCode);
198 Assert.assertEquals(errorCode,"401");
199 Assert.assertEquals(errorMessage,"Error generating sequence Invalid Action start");
204 public void testGenerateSequenceMissingRequestInfo() throws URISyntaxException, IOException {
205 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
207 String inputJSON = readInput("/input/missingrequestinfo.json");
209 Map<String,String> params = new HashMap<>();
210 SvcLogicContext context = new SvcLogicContext();
211 context.setAttribute("inputJSON",inputJSON);
213 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
214 plugin.generateSequence(params,context);
216 String errorCode = context.getAttribute("error-code");
217 String errorMessage = context.getAttribute("error-message");
218 logger.debug("errorCode = " + errorCode);
219 Assert.assertEquals(errorCode,"401");
220 Assert.assertEquals(errorMessage,"Error generating sequence Request info is not provided in the input");
224 public void testGenerateSequenceStopSingleVM() throws URISyntaxException, IOException{
225 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
227 String inputJSON = readInput("/input/stop-singleVM.json");
229 Map<String,String> params = new HashMap<>();
230 SvcLogicContext context = new SvcLogicContext();
231 context.setAttribute("inputJSON",inputJSON);
233 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
234 plugin.generateSequence(params,context);
236 String outputJSON = context.getAttribute("output");
237 String actualOutput = readOutput("/output/stop-singleVM.json");
238 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
242 public void testGenerateSequenceStopSingleVmPerVnfc() throws URISyntaxException, IOException{
243 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
245 String inputJSON = readInput("/input/stop-singleVmPerVnfc.json");
247 Map<String,String> params = new HashMap<>();
248 SvcLogicContext context = new SvcLogicContext();
249 context.setAttribute("inputJSON",inputJSON);
251 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
252 plugin.generateSequence(params,context);
254 String outputJSON = context.getAttribute("output");
255 String actualOutput = readOutput("/output/stop-singleVmPerVnfc.json");
256 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
260 public void testGenerateSequenceRestartNoDep() throws URISyntaxException, IOException {
261 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
263 String inputJSON = readInput("/input/restartNodep.json");
265 Map<String,String> params = new HashMap<>();
266 SvcLogicContext context = new SvcLogicContext();
267 context.setAttribute("inputJSON",inputJSON);
269 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
270 plugin.generateSequence(params,context);
272 String actualOutput = context.getAttribute("output");
273 String outputJSON = readOutput("/output/restart-NoDep.json");
275 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
279 public void testGenerateSequenceRestartNoDepSingleVM() throws URISyntaxException, IOException {
280 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
282 String inputJSON = readInput("/input/NoDep-SingleVM.json");
284 Map<String,String> params = new HashMap<>();
285 SvcLogicContext context = new SvcLogicContext();
286 context.setAttribute("inputJSON",inputJSON);
288 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
289 plugin.generateSequence(params,context);
291 String actualOutput = context.getAttribute("output");
292 String outputJSON = readOutput("/output/restart-Nodep-SingleVM.json");
293 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
297 public void testGenerateSequenceStartSingleVmPerVnfc() throws URISyntaxException, IOException{
298 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
300 String inputJSON = readInput("/input/start-singleVmPerVnfc-.json");
302 Map<String,String> params = new HashMap<>();
303 SvcLogicContext context = new SvcLogicContext();
304 context.setAttribute("inputJSON",inputJSON);
306 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
307 plugin.generateSequence(params,context);
309 String outputJSON = context.getAttribute("output");
310 String actualOutput = readOutput("/output/start-singleVmPerVnfc.json");
311 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
315 public void testGenerateSequenceVnfcNotPresentInInventory() throws URISyntaxException, IOException {
316 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
318 String inputJSON = readInput("/input/CheckVNfcInInventory.json");
320 Map<String,String> params = new HashMap<>();
321 SvcLogicContext context = new SvcLogicContext();
322 context.setAttribute("inputJSON",inputJSON);
323 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
324 plugin.generateSequence(params,context);
326 String outputJSON = context.getAttribute("output");
327 String actualOutput = readOutput("/output/CheckVnfcInInventory.json");
329 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
333 public void testGenerateSequenceCheckMandatoryVnfc() throws URISyntaxException, IOException {
334 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
336 String inputJSON = readInput("/input/CheckMandatoryVnfc.json");
338 Map<String,String> params = new HashMap<>();
339 SvcLogicContext context = new SvcLogicContext();
340 context.setAttribute("inputJSON",inputJSON);
342 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
343 plugin.generateSequence(params,context);
345 String errorCode = context.getAttribute("error-code");
346 String errorMessage = context.getAttribute("error-message");
347 logger.debug("errorCode = " + errorCode);
348 Assert.assertEquals(errorCode,"401");
349 Assert.assertEquals(errorMessage,"Error generating sequence VMs missing for the mandatory VNFC : [smp]");
353 public void testGenerateSequenceCheckMissingDependencyInfo() throws URISyntaxException, IOException {
354 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
356 String inputJSON = readInput("/input/MissingDependencyInfo.json");
358 Map<String,String> params = new HashMap<>();
359 SvcLogicContext context = new SvcLogicContext();
360 context.setAttribute("inputJSON",inputJSON);
362 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
363 plugin.generateSequence(params,context);
365 String errorCode = context.getAttribute("error-code");
366 String errorMessage = context.getAttribute("error-message");
367 logger.debug("errorCode = " + errorCode);
368 Assert.assertEquals(errorCode,"401");
369 Assert.assertEquals(errorMessage,"Error generating sequence Dependency model is missing following vnfc type(s): [smp]");
373 public void testGenerateSequenceExtraVnfcInDependency() throws URISyntaxException, IOException {
374 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
376 String inputJSON = readInput("/input/WrongDependencyModel.json");
378 Map<String,String> params = new HashMap<>();
379 SvcLogicContext context = new SvcLogicContext();
380 context.setAttribute("inputJSON",inputJSON);
382 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
383 plugin.generateSequence(params,context);
385 String errorCode = context.getAttribute("error-code");
386 String errorMessage = context.getAttribute("error-message");
387 logger.debug("errorCode = " + errorCode);
388 Assert.assertEquals(errorCode,"401");
389 Assert.assertEquals(errorMessage,"Error generating sequence Dependency model missing vnfc type SMP");
393 public void testGenerateSequenceStartWithVmStartCaps()throws URISyntaxException, IOException {
394 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
396 String inputJSON = readInput("/input/StartWithVmStartCaps.json");
398 Map<String,String> params = new HashMap<>();
399 SvcLogicContext context = new SvcLogicContext();
400 context.setAttribute("inputJSON",inputJSON);
402 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
403 plugin.generateSequence(params,context);
405 String actualOutput = context.getAttribute("output");
406 String outputJSON = readOutput("/output/StartWithVmStartCaps.json");
407 Assert.assertEquals(outputJSON.trim(), actualOutput.trim());
411 public void testGenerateSequenceRestartWithVmRestartCaps()throws URISyntaxException, IOException {
412 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
414 String inputJSON = readInput("/input/RestartWithVmRestartCaps.json");
416 Map<String,String> params = new HashMap<>();
417 SvcLogicContext context = new SvcLogicContext();
418 context.setAttribute("inputJSON",inputJSON);
420 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
421 plugin.generateSequence(params,context);
423 String actualOutput = context.getAttribute("output");
424 String outputJSON = readOutput("/output/RestartWithVmRestartCaps.json");
425 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
429 public void testGenerateSequenceStopWithVmStopCaps()throws URISyntaxException, IOException {
430 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
432 String inputJSON = readInput("/input/StopWithVmStopCaps.json");
434 Map<String,String> params = new HashMap<>();
435 SvcLogicContext context = new SvcLogicContext();
436 context.setAttribute("inputJSON",inputJSON);
438 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
439 plugin.generateSequence(params,context);
441 String actualOutput = context.getAttribute("output");
442 String outputJSON = readOutput("/output/StopWithVmStopCaps.json");
443 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
447 public void testGenerateSequenceStartWithoutAnyCaps()throws URISyntaxException, IOException {
448 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
450 String inputJSON = readInput("/input/StartWithoutAnyCaps.json");
452 Map<String,String> params = new HashMap<>();
453 SvcLogicContext context = new SvcLogicContext();
454 context.setAttribute("inputJSON",inputJSON);
456 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
457 plugin.generateSequence(params,context);
459 String actualOutput = context.getAttribute("output");
460 String outputJSON = readOutput("/output/StartWithoutAnyCaps.json");
461 Assert.assertEquals(outputJSON.trim(), actualOutput.trim());
465 public void testGenerateSequenceRestartWithoutAnyCaps()throws URISyntaxException, IOException {
466 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
468 String inputJSON = readInput("/input/RestartWithoutAnyCaps.json");
470 Map<String,String> params = new HashMap<>();
471 SvcLogicContext context = new SvcLogicContext();
472 context.setAttribute("inputJSON",inputJSON);
474 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
475 plugin.generateSequence(params,context);
477 String actualOutput = context.getAttribute("output");
478 String outputJSON = readOutput("/output/RestartWithoutAnyCaps.json");
479 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
483 public void testGenerateSequenceStopWithoutAnyCaps()throws URISyntaxException, IOException {
484 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
486 String inputJSON = readInput("/input/StopWithoutAnyCaps.json");
488 Map<String,String> params = new HashMap<>();
489 SvcLogicContext context = new SvcLogicContext();
490 context.setAttribute("inputJSON",inputJSON);
492 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
493 plugin.generateSequence(params,context);
495 String actualOutput = context.getAttribute("output");
496 String outputJSON = readOutput("/output/StopWithoutAnyCaps.json");
497 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
501 public void testGenerateSequenceStartWithoutVmStartCaps()throws URISyntaxException, IOException {
502 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
504 String inputJSON = readInput("/input/StartWithoutVmStartCaps.json");
506 Map<String,String> params = new HashMap<>();
507 SvcLogicContext context = new SvcLogicContext();
508 context.setAttribute("inputJSON",inputJSON);
510 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
511 plugin.generateSequence(params,context);
513 String actualOutput = context.getAttribute("output");
514 Assert.assertEquals(null, actualOutput);
518 public void testGenerateSequenceRestartWithoutVmRestartCaps()throws URISyntaxException, IOException {
519 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
521 String inputJSON = readInput("/input/RestartWithoutVmRestartCaps.json");
523 Map<String,String> params = new HashMap<>();
524 SvcLogicContext context = new SvcLogicContext();
525 context.setAttribute("inputJSON",inputJSON);
527 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
528 plugin.generateSequence(params,context);
530 String actualOutput = context.getAttribute("output");
531 Assert.assertEquals(null, actualOutput);
535 public void testGenerateSequenceStopWithoutVmStopCaps()throws URISyntaxException, IOException {
536 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
538 String inputJSON = readInput("/input/StopWithoutVmStopCaps.json");
540 Map<String,String> params = new HashMap<>();
541 SvcLogicContext context = new SvcLogicContext();
542 context.setAttribute("inputJSON",inputJSON);
544 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
545 plugin.generateSequence(params,context);
547 String actualOutput = context.getAttribute("output");
548 Assert.assertEquals(null, actualOutput);
552 public void testGenerateSequenceStartWithEmptyVmCaps()throws URISyntaxException, IOException {
553 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
555 String inputJSON = readInput("/input/StartWithEmptyVmCaps.json");
557 Map<String,String> params = new HashMap<>();
558 SvcLogicContext context = new SvcLogicContext();
559 context.setAttribute("inputJSON",inputJSON);
561 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
562 plugin.generateSequence(params,context);
564 String actualOutput = context.getAttribute("output");
565 String outputJSON = readOutput("/output/StartWithoutAnyCaps.json");
566 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
570 public void testGenerateSequenceRestartWithEmptyVmCaps()throws URISyntaxException, IOException {
571 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
573 String inputJSON = readInput("/input/RestartWithEmptyVmCaps.json");
575 Map<String,String> params = new HashMap<>();
576 SvcLogicContext context = new SvcLogicContext();
577 context.setAttribute("inputJSON",inputJSON);
579 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
580 plugin.generateSequence(params,context);
582 String actualOutput = context.getAttribute("output");
583 String outputJSON = readOutput("/output/RestartWithoutAnyCaps.json");
584 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
588 public void testGenerateSequenceStopWithEmptyVmCaps()throws URISyntaxException, IOException {
589 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
591 String inputJSON = readInput("/input/StopWithEmptyVmCaps.json");
593 Map<String,String> params = new HashMap<>();
594 SvcLogicContext context = new SvcLogicContext();
595 context.setAttribute("inputJSON",inputJSON);
597 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
598 plugin.generateSequence(params,context);
600 String actualOutput = context.getAttribute("output");
601 String outputJSON = readOutput("/output/StopWithoutAnyCaps.json");
602 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
606 public void testGenerateSequenceStartWithVmStartCapsAndMissingVnfcInfo()throws URISyntaxException, IOException {
607 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
609 String inputJSON = readInput("/input/StartWithVmStartCapsAndMissingVnfcInfo.json");
611 Map<String,String> params = new HashMap<>();
612 SvcLogicContext context = new SvcLogicContext();
613 context.setAttribute("inputJSON",inputJSON);
615 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
616 plugin.generateSequence(params,context);
618 String actualOutput = context.getAttribute("output");
619 String outputJSON = readOutput("/output/StartWithVmStartCapsAndMissingVnfcInfo.json");
620 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
624 public void testGenerateSequenceStopWithVmStopCapsAndMissingVnfcInfo()throws URISyntaxException, IOException {
625 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
627 String inputJSON = readInput("/input/StopWithVmStopCapsAndMissingVnfcInfo.json");
629 Map<String,String> params = new HashMap<>();
630 SvcLogicContext context = new SvcLogicContext();
631 context.setAttribute("inputJSON",inputJSON);
633 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
634 plugin.generateSequence(params,context);
636 String actualOutput = context.getAttribute("output");
637 String outputJSON = readOutput("/output/StopWithVmStopCapsAndMissingVnfcInfo.json");
638 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
642 public void testGenerateSequenceRestartWithVmRestartCapsAndMissingVnfcInfo()throws URISyntaxException, IOException {
643 logger.info("****** Running test: " + thisTestName.getMethodName() + " ******");
645 String inputJSON = readInput("/input/RestartWithVmRestartCapsAndMissingVnfcInfo.json");
647 Map<String,String> params = new HashMap<>();
648 SvcLogicContext context = new SvcLogicContext();
649 context.setAttribute("inputJSON",inputJSON);
651 SequenceGeneratorPlugin plugin = new SequenceGeneratorPluginImpl();
652 plugin.generateSequence(params,context);
654 String actualOutput = context.getAttribute("output");
655 String outputJSON = readOutput("/output/RestartWithVmRestartCapsAndMissingVnfcInfo.json");
656 Assert.assertEquals(outputJSON.trim(),actualOutput.trim());
659 private String readInput(String inputFile) throws URISyntaxException, IOException {
660 return new String(Files.readAllBytes(Paths.get(this.getClass().getResource(inputFile).toURI())), "UTF-8");
663 private String readOutput(String outputFile) throws IOException,URISyntaxException {
664 String output = new String(Files.readAllBytes(Paths.get(this.getClass().getResource(outputFile).toURI())), "UTF-8");
665 int start=output.indexOf("[");
666 return output.substring(start,output.length());