Escape unexpected tokens in CATALINA_OPTS
[vid.git] / vid-automation / src / main / java / vid / automation / test / test / SubInterfaceTest.java
1 package vid.automation.test.test;
2
3 import com.google.common.collect.ImmutableList;
4 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest;
5 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetRelatedInstanceGroupsByVnfId;
6 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetTenants;
7 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVNFInstancePost;
8 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet;
9 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
10 import org.openqa.selenium.WebElement;
11 import org.openqa.selenium.support.ui.Select;
12 import org.testng.Assert;
13 import org.testng.annotations.BeforeClass;
14 import org.testng.annotations.DataProvider;
15 import org.testng.annotations.Test;
16 import vid.automation.test.Constants;
17 import vid.automation.test.infra.Click;
18 import vid.automation.test.infra.FeatureTogglingTest;
19 import vid.automation.test.infra.Get;
20 import vid.automation.test.infra.SelectOption;
21 import vid.automation.test.sections.SearchExistingPage;
22 import vid.automation.test.sections.ViewEditPage;
23 import vid.automation.test.services.BulkRegistration;
24 import vid.automation.test.services.SimulatorApi;
25
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.List;
29 import java.util.stream.Collectors;
30
31 import static org.hamcrest.MatcherAssert.assertThat;
32 import static org.hamcrest.Matchers.equalTo;
33 import static org.hamcrest.Matchers.is;
34 import static org.testng.AssertJUnit.assertEquals;
35 import static org.testng.AssertJUnit.assertNull;
36 import static vid.automation.test.infra.Features.FLAG_COLLECTION_RESOURCE_SUPPORT;
37 import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;
38
39 @FeatureTogglingTest(FLAG_COLLECTION_RESOURCE_SUPPORT)
40 public class SubInterfaceTest extends CreateInstanceDialogBaseTest {
41
42     private final ViewEditPage viewEditPage = new ViewEditPage();
43     private final String ecompNamingFalseInstanceId = "dc3a893e-0104-4ef6-abfe-6c2932294a3e";
44     private final String ecompNamingTrueInstanceId = "dc3a893e-0104-4ef6-abfe-6c2932294a3f";
45
46     @BeforeClass
47     protected void registerToSimulator() {
48         SimulatorApi.clearAll();
49         BulkRegistration.createNewServiceInstance("USP VOICE");
50
51         BulkRegistration.searchExistingVFServiceWithVFCInstanceGroupInstance("Created");
52         SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.APPEND
53                 , "add_subinterface/get_sdc_catalog_services_vid-test-333.json"
54                 , "add_subinterface/aai_get_services.json"
55                 , "add_subinterface/aai_get_subscribers.json"
56                 , "add_subinterface/aai_get_aic_zones.json"
57         );
58
59         final PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest presetAAIGetInstanceGroupsByCloudRegion1 = new PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest("e433710f-9217-458d-a79d-1c7aff376d89", "mtn6", "untraaa");
60         final PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest presetAAIGetInstanceGroupsByCloudRegion2 = new PresetAAIGetInstanceGroupsByCloudRegionInvalidRequest("e433710f-9217-458d-a79d-1c7aff376d89", "AAIAIC25", "untraaa");
61
62         SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
63                     new PresetMSOCreateVNFInstancePost(ecompNamingTrueInstanceId, "6bce7302-70bd-4057-b48e-8d5b99e686ca"),
64                     new PresetMSOCreateVNFInstancePost(ecompNamingFalseInstanceId, "6bce7302-70bd-4057-b48e-8d5b99e686cb"),
65                     new PresetAAIGetTenants(),
66                     presetAAIGetInstanceGroupsByCloudRegion1,
67                     presetAAIGetInstanceGroupsByCloudRegion2,
68                     new PresetMSOOrchestrationRequestGet("IN_PROGRESS"),
69                     new PresetMSOOrchestrationRequestGet("COMPLETE")
70                 ),
71                 APPEND);
72
73         final PresetAAIGetRelatedInstanceGroupsByVnfId getRelatedInstanceGroupsByVnfId = new PresetAAIGetRelatedInstanceGroupsByVnfId("c015cc0f-0f37-4488-aabf-53795fd93cd3");
74         SimulatorApi.registerExpectationFromPreset(getRelatedInstanceGroupsByVnfId, APPEND);
75
76     }
77
78     @DataProvider
79     private Object[][] getServices() {
80         return new Object[][]{{ecompNamingTrueInstanceId, true}, {ecompNamingFalseInstanceId, false}};
81     }
82
83     @Test(dataProvider = "getServices")
84     public void createSubInterface_validPopupDataAndUIEcompNamingTrue(String serviceUuid, boolean ecompNamingEnabled) {
85         SearchExistingPage searchExistingPage = new SearchExistingPage();
86
87         searchExistingPage.goOutFromIframe();
88         goToExistingInstanceById(serviceUuid);
89
90         String vnfName = "vDBE 0";
91         Assert.assertNotNull(Get.byClassAndText("instanceGroupTreeNode","instance group name"));
92         GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID, 60);
93         GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.VNF_OPTION_TEST_ID_PREFIX + vnfName, 60);
94
95         GeneralUIUtils.ultimateWait();
96
97         searchExistingPage.goToIframe();
98
99         WebElement instanceNameInput = GeneralUIUtils.getInputElement(Constants.INSTANCE_NAME_SELECT_TESTS_ID);
100         if (ecompNamingEnabled) {
101             assertNull(instanceNameInput);
102         } else {
103             instanceNameInput.sendKeys("New Name");
104         }
105         SelectOption.byTestIdAndVisibleText("VIRTUAL USP", Constants.ViewEdit.PRODUCT_FAMILY_SELECT_TESTS_ID);
106         SelectOption.byTestIdAndVisibleText("AAIAIC25", Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID);
107         SelectOption.byTestIdAndVisibleText("USP-SIP-IC-24335-T-01", Constants.ViewEdit.TENANT_SELECT_TESTS_ID);
108         SelectOption.byTestIdAndVisibleText("UUUAIAAI-YYY1", Constants.ViewEdit.AIC_ZONE_TEST_ID);
109         SelectOption.byTestIdAndVisibleText("plat1", Constants.OwningEntity.PLATFORM_SELECT_TEST_ID);
110         SelectOption.byTestIdAndVisibleText("ecomp", Constants.OwningEntity.LOB_SELECT_TEST_ID);
111         SelectOption.byTestIdAndVisibleText("Rollback", Constants.SUPPRESS_ROLLBACK_SELECT_TESTS_ID);
112
113
114         checkModelItemLabelAndValue(Constants.VlanTagging.MODEL_ITEM_LABEL_SERVICE_INSTANCENAME, "Service Instance Name",
115                 Constants.VlanTagging.MODEL_ITEM_VALUE_SERVICE_INSTANCENAME, "vid-test-444");
116         checkModelItemLabelAndValue(Constants.VlanTagging.MODEL_ITEM_LABEL_MODEL_INVARIANT_UUID, "Model Invariant UUID",
117                 Constants.VlanTagging.MODEL_ITEM_VALUE_MODEL_INVARIANT_UUID, "fcdf49ce-6f0b-4ca2-b676-a484e650e734");
118         checkModelItemLabelAndValue(Constants.VlanTagging.MODEL_ITEM_LABEL_MODEL_VERSION, "Model Version",
119                 Constants.VlanTagging.MODEL_ITEM_VALUE_MODEL_VERSION, "0.2");
120         checkModelItemLabelAndValue(Constants.VlanTagging.MODEL_ITEM_LABEL_MODEL_UUID, "Model UUID",
121                 Constants.VlanTagging.MODEL_ITEM_VALUE_MODEL_UUID, "61535073-2e50-4141-9000-f66fea69b433");
122         checkModelItemLabelAndValue(Constants.VlanTagging.MODEL_ITEM_LABEL_CUSTOMIZATION_UUID, "Model Customization UUID",
123                 Constants.VlanTagging.MODEL_ITEM_VALUE_CUSTOMIZATION_UUID, "882e5dcb-ba9f-4766-8cde-e326638107db");
124
125         assertEquals(Get.multipleElementsByTestId(Constants.VlanTagging.MODEL_ITEM_LABEL_GROUP_NAME).stream()
126                 .map(WebElement::getText).collect(Collectors.toList()), Arrays.asList("Group Name", "Group Name"));
127
128
129         List<String> rightSideGroupsNames = //Will be used here AND in step 2 to check against the left side of the page
130                 Get.multipleElementsByTestId(Constants.VlanTagging.MODEL_ITEM_VALUE_GROUP_NAME).stream()
131                         .map(WebElement::getText).collect(Collectors.toList());
132
133         assertEquals(rightSideGroupsNames, Arrays.asList("untr_group", "oam_group"));
134
135         assertEquals(Get.multipleElementsByTestId(Constants.VlanTagging.MODEL_ITEM_LABEL_NETWORK_COLLECTION_FUNCTION)
136                         .stream().map(WebElement::getText).collect(Collectors.toList()),
137                 Arrays.asList("Network Collection Function", "Network Collection Function"));
138
139         assertEquals(Get.multipleElementsByTestId(Constants.VlanTagging.MODEL_ITEM_VALUE_NETWORK_COLLECTION_FUNCTION)
140                         .stream().map(WebElement::getText).collect(Collectors.toList()),
141                 Arrays.asList("untraaa", "untraaa"));
142
143         assertEquals(Get.multipleElementsByTestId(Constants.VlanTagging.MODEL_ITEM_LABEL_INSTANCE_GROUP_FUNCTION)
144                         .stream().map(WebElement::getText).collect(Collectors.toList()),
145                 Arrays.asList("VFC Instance Group Function", "VFC Instance Group Function"));
146
147         assertEquals(Get.multipleElementsByTestId(Constants.VlanTagging.MODEL_ITEM_VALUE_INSTANCE_GROUP_FUNCTION)
148                         .stream().map(WebElement::getText).collect(Collectors.toList()),
149                 Arrays.asList("", ""));
150
151         assertEquals(Get.multipleElementsByTestId(Constants.VlanTagging.MODEL_ITEM_LABEL_PARENT_PORT_ROLE).stream()
152                         .map(WebElement::getText).collect(Collectors.toList()),
153                 Arrays.asList("Parent Port Role", "Parent Port Role"));
154
155         assertEquals(Get.multipleElementsByTestId(Constants.VlanTagging.MODEL_ITEM_VALUE_PARENT_PORT_ROLE).stream()
156                         .map(WebElement::getText).collect(Collectors.toList()),
157                 Arrays.asList("untr", "untr"));
158
159         assertEquals(Get.multipleElementsByTestId(Constants.VlanTagging.MODEL_ITEM_LABEL_SUBINTERFACE_ROLE).stream()
160                         .map(WebElement::getText).collect(Collectors.toList()),
161                 Arrays.asList("Sub Interface Role", "Sub Interface Role"));
162
163         assertEquals(Get.multipleElementsByTestId(Constants.VlanTagging.MODEL_ITEM_VALUE_SUBINTERFACE_ROLE).stream()
164                         .map(WebElement::getText).collect(Collectors.toList()),
165                 Arrays.asList("untr", "untr"));
166
167         Click.byTestId(Constants.ConfigurationCreation.NEXT_BUTTON_TEST_ID);
168
169         compareTwoGroups(Get.multipleElementsByTestId("groupLabel"), rightSideGroupsNames);
170
171         List<WebElement> leftSideGroups = Get.multipleElementsByTestId("groupTestId");
172
173         GeneralUIUtils.ultimateWait();
174
175         for (WebElement element : leftSideGroups) {
176             (new Select(element)).selectByIndex(1);
177         }
178
179         Click.byTestId(Constants.ConfigurationCreation.NEXT_BUTTON_TEST_ID);
180         searchExistingPage.goOutFromIframe();
181         assertSuccessfulServiceInstanceCreation();
182         viewEditPage.clickCommitCloseButton();
183     }
184
185     private void compareTwoGroups(List<WebElement> leftSideGroups, List<String> rightSideGroupsNames) {
186         assertEquals(leftSideGroups.size(), rightSideGroupsNames.size());
187
188         //converting list of web elements to list of strings
189         ArrayList<String> leftSideGroupsNames = new ArrayList<>();
190         for (WebElement element : leftSideGroups) {
191             leftSideGroupsNames.add(element.getText());
192         }
193         assertEquals(leftSideGroupsNames, rightSideGroupsNames);
194     }
195
196     private void checkModelItemLabelAndValue(String labelId, String labelValue, String textID, String textValue) {
197         assertThat(Get.byTestId(labelId).getText(), is(equalTo(labelValue)));
198         assertThat(Get.byTestId(textID).getText(), is(equalTo(textValue)));
199     }
200 }