2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.enrichment.impl.tosca;
19 import java.io.IOException;
20 import java.util.List;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.openecomp.sdc.datatypes.error.ErrorMessage;
25 import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
27 public class PortMirroringEnricherTest extends BaseToscaEnrichmentTest {
29 private PortMirroringEnricher portMirroringEnricher;
33 portMirroringEnricher = new PortMirroringEnricher();
37 public void testEnrichNoPorts() throws Exception {
38 outputFilesPath = "/mock/enrichPortMirroring/noPorts/out/";
39 ToscaServiceModel toscaServiceModel =
40 loadToscaServiceModel("/mock/enrichPortMirroring/noPorts/in/",
41 "/mock/toscaGlobalServiceTemplates/",
42 "MainServiceTemplate.yaml");
43 Map<String, List<ErrorMessage>> errors =
44 portMirroringEnricher.enrich(toscaServiceModel);
46 compareActualAndExpectedModel(toscaServiceModel);
50 public void testEnrichSingleSubstitutionSamePortType() throws Exception {
51 outputFilesPath = "/mock/enrichPortMirroring/singleSubstitution/samePortType/out/";
52 ToscaServiceModel toscaServiceModel =
53 loadToscaServiceModel("/mock/enrichPortMirroring/singleSubstitution/samePortType/in",
54 "/mock/toscaGlobalServiceTemplates/",
55 "MainServiceTemplate.yaml");
56 Map<String, List<ErrorMessage>> errors =
57 portMirroringEnricher.enrich(toscaServiceModel);
59 compareActualAndExpectedModel(toscaServiceModel);
63 public void testEnrichSingleSubstitutionDiffPortType() throws Exception {
64 outputFilesPath = "/mock/enrichPortMirroring/singleSubstitution/diffPortType/out/";
65 ToscaServiceModel toscaServiceModel =
66 loadToscaServiceModel("/mock/enrichPortMirroring/singleSubstitution/diffPortType/in",
67 "/mock/toscaGlobalServiceTemplates/",
68 "MainServiceTemplate.yaml");
69 Map<String, List<ErrorMessage>> errors =
70 portMirroringEnricher.enrich(toscaServiceModel);
72 compareActualAndExpectedModel(toscaServiceModel);
76 public void testEnrichScalingInstance() throws Exception {
77 outputFilesPath = "/mock/enrichPortMirroring/scalingInstance/out/";
78 ToscaServiceModel toscaServiceModel =
79 loadToscaServiceModel("/mock/enrichPortMirroring/scalingInstance/in",
80 "/mock/toscaGlobalServiceTemplates/",
81 "MainServiceTemplate.yaml");
82 Map<String, List<ErrorMessage>> errors =
83 portMirroringEnricher.enrich(toscaServiceModel);
85 compareActualAndExpectedModel(toscaServiceModel);
89 public void testEnrichCatalogInstance() throws Exception {
90 outputFilesPath = "/mock/enrichPortMirroring/catalogInstance/out/";
91 ToscaServiceModel toscaServiceModel =
92 loadToscaServiceModel("/mock/enrichPortMirroring/catalogInstance/in",
93 "/mock/toscaGlobalServiceTemplates/",
94 "MainServiceTemplate.yaml");
95 Map<String, List<ErrorMessage>> errors =
96 portMirroringEnricher.enrich(toscaServiceModel);
98 compareActualAndExpectedModel(toscaServiceModel);
102 public void testEnrichNestedOneLevel() throws Exception {
103 outputFilesPath = "/mock/enrichPortMirroring/nested/oneLevel/out/";
104 ToscaServiceModel toscaServiceModel =
105 loadToscaServiceModel("/mock/enrichPortMirroring/nested/oneLevel/in",
106 "/mock/toscaGlobalServiceTemplates/",
107 "MainServiceTemplate.yaml");
108 Map<String, List<ErrorMessage>> errors =
109 portMirroringEnricher.enrich(toscaServiceModel);
111 compareActualAndExpectedModel(toscaServiceModel);
115 public void testEnrichNestedMultiLevel() throws Exception {
116 outputFilesPath = "/mock/enrichPortMirroring/nested/multiLevel/out/";
117 ToscaServiceModel toscaServiceModel =
118 loadToscaServiceModel("/mock/enrichPortMirroring/nested/multiLevel/in",
119 "/mock/toscaGlobalServiceTemplates/",
120 "MainServiceTemplate.yaml");
121 Map<String, List<ErrorMessage>> errors =
122 portMirroringEnricher.enrich(toscaServiceModel);
124 compareActualAndExpectedModel(toscaServiceModel);