0a8fe432b03401936e2b1e54766b01d50d021ee5
[sdc.git] /
1 package org.openecomp.sdc.enrichment.impl.tosca;
2
3 import org.openecomp.sdc.datatypes.error.ErrorMessage;
4 import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
5 import org.testng.annotations.AfterClass;
6 import org.testng.annotations.BeforeClass;
7 import org.testng.annotations.BeforeMethod;
8 import org.testng.annotations.Test;
9
10 import java.io.IOException;
11 import java.util.List;
12 import java.util.Map;
13
14 public class PortMirroringEnricherTest extends BaseToscaEnrichmentTest {
15
16   private PortMirroringEnricher portMirroringEnricher;
17
18   @BeforeMethod(alwaysRun = true)
19   public void init() throws IOException {
20     portMirroringEnricher = new PortMirroringEnricher();
21   }
22
23   @Test
24   public void testEnrichNoPorts() throws Exception {
25     outputFilesPath = "/mock/enrichPortMirroring/noPorts/out/";
26     ToscaServiceModel toscaServiceModel =
27         loadToscaServiceModel("/mock/enrichPortMirroring/noPorts/in/",
28             "/mock/toscaGlobalServiceTemplates/",
29             "MainServiceTemplate.yaml");
30     Map<String, List<ErrorMessage>> errors =
31         portMirroringEnricher.enrich(toscaServiceModel);
32
33     compareActualAndExpectedModel(toscaServiceModel);
34   }
35
36   @Test
37   public void testEnrichSingleSubstitutionSamePortType() throws Exception {
38     outputFilesPath = "/mock/enrichPortMirroring/singleSubstitution/samePortType/out/";
39     ToscaServiceModel toscaServiceModel =
40         loadToscaServiceModel("/mock/enrichPortMirroring/singleSubstitution/samePortType/in",
41             "/mock/toscaGlobalServiceTemplates/",
42             "MainServiceTemplate.yaml");
43     Map<String, List<ErrorMessage>> errors =
44         portMirroringEnricher.enrich(toscaServiceModel);
45
46     compareActualAndExpectedModel(toscaServiceModel);
47   }
48
49   @Test
50   public void testEnrichSingleSubstitutionDiffPortType() throws Exception {
51     outputFilesPath = "/mock/enrichPortMirroring/singleSubstitution/diffPortType/out/";
52     ToscaServiceModel toscaServiceModel =
53         loadToscaServiceModel("/mock/enrichPortMirroring/singleSubstitution/diffPortType/in",
54             "/mock/toscaGlobalServiceTemplates/",
55             "MainServiceTemplate.yaml");
56     Map<String, List<ErrorMessage>> errors =
57         portMirroringEnricher.enrich(toscaServiceModel);
58
59     compareActualAndExpectedModel(toscaServiceModel);
60   }
61
62   @Test
63   public void testEnrichScalingInstance() throws Exception {
64     outputFilesPath = "/mock/enrichPortMirroring/scalingInstance/out/";
65     ToscaServiceModel toscaServiceModel =
66         loadToscaServiceModel("/mock/enrichPortMirroring/scalingInstance/in",
67             "/mock/toscaGlobalServiceTemplates/",
68             "MainServiceTemplate.yaml");
69     Map<String, List<ErrorMessage>> errors =
70         portMirroringEnricher.enrich(toscaServiceModel);
71
72     compareActualAndExpectedModel(toscaServiceModel);
73   }
74
75   @Test
76   public void testEnrichCatalogInstance() throws Exception {
77     outputFilesPath = "/mock/enrichPortMirroring/catalogInstance/out/";
78     ToscaServiceModel toscaServiceModel =
79         loadToscaServiceModel("/mock/enrichPortMirroring/catalogInstance/in",
80             "/mock/toscaGlobalServiceTemplates/",
81             "MainServiceTemplate.yaml");
82     Map<String, List<ErrorMessage>> errors =
83         portMirroringEnricher.enrich(toscaServiceModel);
84
85     compareActualAndExpectedModel(toscaServiceModel);
86   }
87
88   @Test
89   public void testEnrichNestedOneLevel() throws Exception {
90     outputFilesPath = "/mock/enrichPortMirroring/nested/oneLevel/out/";
91     ToscaServiceModel toscaServiceModel =
92         loadToscaServiceModel("/mock/enrichPortMirroring/nested/oneLevel/in",
93             "/mock/toscaGlobalServiceTemplates/",
94             "MainServiceTemplate.yaml");
95     Map<String, List<ErrorMessage>> errors =
96         portMirroringEnricher.enrich(toscaServiceModel);
97
98     compareActualAndExpectedModel(toscaServiceModel);
99   }
100
101   @Test
102   public void testEnrichNestedMultiLevel() throws Exception {
103     outputFilesPath = "/mock/enrichPortMirroring/nested/multiLevel/out/";
104     ToscaServiceModel toscaServiceModel =
105         loadToscaServiceModel("/mock/enrichPortMirroring/nested/multiLevel/in",
106             "/mock/toscaGlobalServiceTemplates/",
107             "MainServiceTemplate.yaml");
108     Map<String, List<ErrorMessage>> errors =
109         portMirroringEnricher.enrich(toscaServiceModel);
110
111     compareActualAndExpectedModel(toscaServiceModel);
112   }
113
114 }