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