Merge from ecomp 718fd196 - Integration Tests
[vid.git] / vid-automation / src / main / java / vid / automation / test / test / ALaCarteflowTest.java
1 package vid.automation.test.test;
2
3 import com.google.common.collect.ImmutableList;
4 import com.google.common.collect.ImmutableMap;
5 import org.junit.Assert;
6 import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset;
7 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
8 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVfModuleOldViewEdit;
9 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfALaCarteOldViewEdit;
10 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVolumeGroupOldViewEdit;
11 import org.onap.sdc.ci.tests.datatypes.UserCredentials;
12 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
13 import org.openqa.selenium.WebElement;
14 import org.testng.annotations.BeforeClass;
15 import org.testng.annotations.DataProvider;
16 import org.testng.annotations.Test;
17 import vid.automation.test.Constants;
18 import vid.automation.test.infra.Get;
19 import vid.automation.test.model.ServiceModel;
20 import vid.automation.test.model.User;
21 import vid.automation.test.sections.SideMenu;
22 import vid.automation.test.sections.VidBasePage;
23 import vid.automation.test.sections.ViewEditPage;
24 import vid.automation.test.services.ServicesService;
25 import vid.automation.test.services.SimulatorApi;
26
27 import java.util.List;
28 import java.util.stream.Collectors;
29
30 import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.*;
31 import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;
32
33
34 public class ALaCarteflowTest extends CreateInstanceDialogBaseTest {
35     static final String SUBSCRIBER = "Emanuel";
36     static final String SERVICE_NAME = "ggghhh";
37     static final String SERVICE_ID = "537d3eb0-b7ab-4fe8-a438-6166ab6af49b";
38     static final String VNF_ID = "0eb38f69-d96b-4d5e-b8c9-3736c292f0f7";
39     static final String DEFAULT_TEST_API_VALUE = "VNF_API";
40     public static final String SERVICE_INSTANCE_ID = "SERVICE_INSTANCE_ID";
41     public static final String A_LACARTE_FLOW_GET_ORCHESTRATION = "aLacarteFlow/get_orchestration_request_status.json";
42     public static final String ORCHESTRATION_REQUEST_ID = "orchestrationRequestId";
43     public static final String STATUS_MESSAGE = "status_message";
44     public static final String REQUEST_TYPE = "REQUEST-TYPE";
45     public static final String CREATE = "Create";
46     public static final String AAIAIC_25 = "AAIAIC25";
47     public static final String AIC = "AIC";
48     public static final String TENANT = "092eb9e8e4b7412e8787dd091bc58e86";
49     public static final String FALSE = "false";
50     public static final String NODE_INSTANCE = "VSP1710PID298109_vWINIFRED 0";
51     public static final String MODEL = "959a7ba0-89ee-4984-9af6-65d5bdda4b0e";
52     private static final String CREATE_VNF_REQUEST_ID = "dbe54591-c8ed-46d3-abc7-d3a24873dfbd";
53
54
55     @BeforeClass
56     protected void registerToSimulator() {
57         SimulatorApi.clearAll();
58         SimulatorApi.registerExpectation(APPEND,
59                 "ecompportal_getSessionSlotCheckInterval.json",
60                 "search_for_service_instance/aai_get_services.json"
61                 , "create_configuration/aai_get_tenants.json"
62                 , "sanity/get_aai_sub_details.json"
63                 , "aLacarteFlow/get_aai_search_named_query.json"
64                 , "aLacarteFlow/get_sdc_catalog_services_ggghhh.json"
65         );
66         SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.APPEND);
67     }
68
69
70     @Test(dataProvider = "msoTestApiOptions")
71     private void testAddVfModule(String msoTestApiOption, String msoTestApiValue) {
72         withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> {
73             final String REQUEST_ID = "dbe54591-c8ed-46d3-abc7-d3a24873bddd";
74             final String MODEL_UUID = "d205e01d-e5da-4e68-8c52-f95cb0607959";
75
76             String vfModuleName = viewEditPage.generateInstanceName(Constants.ViewEdit.VF_MODULE_INSTANCE_NAME_PREFIX);
77
78             SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
79                     PRESET_MDT1_TO_ATT_NC,
80                     new PresetMSOCreateVfModuleOldViewEdit(
81                             REQUEST_ID,
82                             BaseMSOPreset.DEFAULT_INSTANCE_ID,
83                             SERVICE_ID,
84                             VNF_ID,
85                             vfModuleName,
86                             msoTestApiValue,
87                             ATT_NC)),
88                     SimulatorApi.RegistrationStrategy.APPEND);
89
90
91             SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION,
92                     ImmutableMap.of(ORCHESTRATION_REQUEST_ID, REQUEST_ID, STATUS_MESSAGE, Constants.ViewEdit.VF_MODULE_CREATED_SUCCESSFULLY_TEXT,
93                             REQUEST_TYPE, CREATE), APPEND);
94             GeneralUIUtils.ultimateWait();
95             goToInstance();
96             ServiceModel serviceInstance = new ServicesService().getServiceModel(MODEL_UUID);
97             addVFModule("Vsp1710pid298109Vwinifred..mmsc_mod1_ltm..module-8", vfModuleName, AAIAIC_25, AIC,
98                     TENANT, FALSE, MDT_1, getCurrentUser().tenants, serviceInstance);
99
100         });
101     }
102
103     @Test
104     private void testTenant() throws Exception {
105         ViewEditPage viewEditPage = new ViewEditPage();
106         User user = usersService.getUser("Emanuel_with_tenant");
107         relogin(user.credentials);
108         goToInstance();
109         viewEditPage.selectNodeInstanceToAdd(NODE_INSTANCE);
110         viewEditPage.setInstanceName("New and fun instance");
111         viewEditPage.selectProductFamily("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
112         viewEditPage.selectLcpRegion("hvf6", AIC);
113         List<WebElement> tenantOptions = Get.byClass(Constants.ViewEdit.TENANT_OPTION_CLASS);
114         List<WebElement> enabledTenantOption = tenantOptions.stream().filter(webElement -> webElement.isEnabled()).collect(Collectors.toList());
115         Assert.assertTrue(enabledTenantOption.size() == 1);
116         Assert.assertTrue(enabledTenantOption.get(0).getText().equals("test-hvf6-09"));
117
118         //        SimulatorApi.registerExpectation("aLacarteFlow/get_sdc_catalog_services_ggghhh.json",APPEND);
119     }
120
121     @Test(dataProvider = "msoTestApiOptions")
122     private void testAddVnf(String msoTestApiOption, String msoTestApiValue) {
123         withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> {
124             final String MODEL_UUID = MODEL;
125             String instanceName = new VidBasePage().generateInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX);
126             SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
127                     PRESET_SOME_LEGACY_REGION_TO_ATT_AIC,
128                     new PresetMSOCreateVnfALaCarteOldViewEdit(
129                             CREATE_VNF_REQUEST_ID,
130                             SERVICE_ID,
131                             instanceName,
132                             true,
133                             msoTestApiValue)),
134                     SimulatorApi.RegistrationStrategy.APPEND);
135             SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION,
136                     ImmutableMap.of(ORCHESTRATION_REQUEST_ID, "dbe54591-c8ed-46d3-abc7-d3a24873dfbd", STATUS_MESSAGE, Constants.ViewEdit.VNF_CREATED_SUCCESSFULLY_TEXT,
137                             REQUEST_TYPE, CREATE), APPEND);
138             GeneralUIUtils.ultimateWait();
139             goToInstance();
140             ServiceModel serviceInstance = new ServicesService().getServiceModel(MODEL_UUID);
141             addVNF(NODE_INSTANCE, AAIAIC_25, AIC, TENANT,
142                     FALSE, SOME_LEGACY_REGION, "ebc3bc3d-62fd-4a3f-a037-f619df4ff034", "platform", getCurrentUser().tenants, "ONAP", serviceInstance, instanceName);
143         });
144     }
145
146     @Test(dataProvider = "msoTestApiOptions")
147     private void requiredLineOfBussiness_confirmVnfWithNoLob(String msoTestApiOption, String msoTestApiValue) throws Exception {
148         withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> {
149             goToInstance();
150             String instanceName = new VidBasePage().generateInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX);
151             SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
152                     PRESET_SOME_LEGACY_REGION_TO_ATT_AIC,
153                     new PresetMSOCreateVnfALaCarteOldViewEdit(
154                             CREATE_VNF_REQUEST_ID,
155                             SERVICE_ID,
156                             instanceName,
157                             false,
158                             msoTestApiValue)),
159                     SimulatorApi.RegistrationStrategy.APPEND);
160             SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION, ImmutableMap.of(
161                     ORCHESTRATION_REQUEST_ID, "dbe54591-c8ed-46d3-abc7-d3a24873dfbd",
162                     STATUS_MESSAGE, Constants.ViewEdit.VNF_CREATED_SUCCESSFULLY_TEXT,
163                     REQUEST_TYPE, CREATE
164             ), APPEND);
165             openAndFillVnfPopup(NODE_INSTANCE, AAIAIC_25, AIC, TENANT,
166                     FALSE, SOME_LEGACY_REGION, "ebc3bc3d-62fd-4a3f-a037-f619df4ff034", "platform", getCurrentUser().tenants, null, null, instanceName);
167             assertConfirmShowMissingDataErrorOnCurrentPopup(Constants.ViewEdit.LINE_OF_BUSINESS_TEXT);
168         });
169     }
170
171     @Test
172     private void emptyLobAfterReopenCreateVnfDialog() throws Exception {
173         final String lobToSelect = "ONAP";
174         goToInstance();
175         ViewEditPage viewEditPage = new ViewEditPage();
176         viewEditPage.selectNodeInstanceToAdd(NODE_INSTANCE);
177         GeneralUIUtils.ultimateWait();
178         viewEditPage.selectLineOfBusiness(lobToSelect);
179         viewEditPage.clickCancelButtonByTestID();
180         viewEditPage.selectNodeInstanceToAdd(NODE_INSTANCE);
181         GeneralUIUtils.ultimateWait();
182         viewEditPage.selectLineOfBusiness(lobToSelect);
183         viewEditPage.clickCancelButtonByTestID();
184     }
185
186     @Test(dataProvider = "msoTestApiOptions")
187     private void testAddVolumeGroup(String msoTestApiOption, String msoTestApiValue) throws Exception {
188         withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> {
189             final String REQUEST_ID = "dbe54591-c8ed-46d3-abc7-d3a24873bdaa";
190             final String MODEL_UUID = "13f022c4-651e-4326-b8e1-61e9a8c7a7ad";
191             String vgName = viewEditPage.generateInstanceName(Constants.ViewEdit.VOLUME_GROUP_INSTANCE_NAME_PREFIX);
192             SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
193                     PRESET_SOME_LEGACY_REGION_TO_ATT_AIC,
194                     new PresetMSOCreateVolumeGroupOldViewEdit(
195                             REQUEST_ID,
196                             BaseMSOPreset.DEFAULT_INSTANCE_ID,
197                             SERVICE_ID,
198                             VNF_ID,
199                             vgName,
200                             msoTestApiValue)),
201                     SimulatorApi.RegistrationStrategy.APPEND);
202             SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION,
203                     ImmutableMap.of(ORCHESTRATION_REQUEST_ID, REQUEST_ID, STATUS_MESSAGE, Constants.ViewEdit.VOLUME_GROUP_CREATED_SUCCESSFULLY_TEXT,
204                             REQUEST_TYPE, CREATE), SimulatorApi.RegistrationStrategy.APPEND);
205             GeneralUIUtils.ultimateWait();
206             goToInstance();
207             ServiceModel serviceInstance = new ServicesService().getServiceModel(MODEL_UUID);
208             addVolumeGroup("Vsp1710pid298109Vwinifred..mmsc_mod6_eca_oam..module-3", vgName, AAIAIC_25, AIC, TENANT,
209                     FALSE, SOME_LEGACY_REGION, getCurrentUser().tenants, serviceInstance);
210         });
211     }
212
213     private User getCurrentUser() {
214         return usersService.getUser(Constants.Users.EMANUEL_vWINIFRED);
215     }
216
217     private void goToInstance() {
218         SideMenu.navigateToSearchExistingPage();
219         goToExistingInstanceBySubscriber(SUBSCRIBER, SERVICE_NAME, SERVICE_ID);
220
221     }
222
223     @Override
224     protected UserCredentials getUserCredentials() {
225         User user = getCurrentUser();
226         return new UserCredentials(user.credentials.userId, user.credentials.password, Constants.Users.EMANUEL_vWINIFRED, "", "");
227     }
228
229     @DataProvider
230     public static Object[][] msoTestApiOptions() {
231         return new Object[][]{
232                 {"VNF_API (old)", DEFAULT_TEST_API_VALUE}
233                 , {"GR_API (new)", "GR_API"}
234         };
235     }
236
237     private void withMsoTestApiConfiguration(String msoTestApiOption, String msoTestApiValue, Runnable test) {
238         if (msoTestApiValue.equals(DEFAULT_TEST_API_VALUE)) {
239             test.run();
240         } else {
241             try {
242                 selectMsoTestApiOption(msoTestApiOption);
243                 test.run();
244             } finally {
245                 // back to default
246                 selectMsoTestApiOption("VNF_API (old)");
247             }
248         }
249     }
250
251
252 }