vid-automation selenium tests
[vid.git] / vid-automation / src / main / java / vid / automation / test / test / VidBaseTestCase.java
1 package vid.automation.test.test;
2
3 import com.att.automation.common.report_portal_integration.annotations.Step;
4 import com.att.automation.common.report_portal_integration.listeners.ReportPortalListener;
5 import com.att.automation.common.report_portal_integration.screenshots.WebDriverScreenshotsProvider;
6 import com.fasterxml.jackson.databind.ObjectMapper;
7 import com.google.common.collect.ImmutableList;
8 import org.apache.commons.lang3.StringUtils;
9 import org.junit.Assert;
10 import org.opencomp.simulator.presetGenerator.presets.BasePresets.BasePreset;
11 import org.opencomp.simulator.presetGenerator.presets.aai.*;
12 import org.opencomp.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
13 import org.opencomp.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceGen2;
14 import org.opencomp.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstancePost;
15 import org.opencomp.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet;
16 import org.opencomp.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet;
17 import org.opencomp.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet;
18 import org.openecomp.sdc.ci.tests.datatypes.UserCredentials;
19 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
20 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
21 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
22 import org.openqa.selenium.By;
23 import org.openqa.selenium.JavascriptExecutor;
24 import org.openqa.selenium.WebElement;
25 import org.testng.ITestContext;
26 import org.testng.annotations.BeforeMethod;
27 import org.testng.annotations.BeforeSuite;
28 import org.testng.annotations.Listeners;
29 import org.testng.annotations.Test;
30 import vid.automation.test.Constants;
31 import vid.automation.test.infra.*;
32 import vid.automation.test.model.Credentials;
33 import vid.automation.test.model.User;
34 import vid.automation.test.sections.*;
35 import vid.automation.test.services.CategoryParamsService;
36 import vid.automation.test.services.SimulatorApi;
37 import vid.automation.test.services.UsersService;
38 import vid.automation.test.utils.DB_CONFIG;
39 import vid.automation.test.utils.TestConfigurationHelper;
40
41 import java.io.File;
42 import java.lang.reflect.Method;
43 import java.sql.*;
44 import java.util.ArrayList;
45 import java.util.Arrays;
46 import java.util.List;
47 import java.util.Map;
48 import java.util.stream.Collectors;
49
50 import static org.hamcrest.core.Is.is;
51 import static org.testng.Assert.assertEquals;
52 import static org.testng.AssertJUnit.fail;
53
54 @Listeners(com.att.automation.common.report_portal_integration.listeners.ReportPortalListener.class)
55 public class VidBaseTestCase extends SetupCDTest{
56
57     protected final UsersService usersService = new UsersService();
58     protected final CategoryParamsService categoryParamsService = new CategoryParamsService();
59
60     @Override
61     protected UserCredentials getUserCredentials() {
62         ObjectMapper mapper = new ObjectMapper().enableDefaultTyping();
63         try {
64             File configFile = FileHandling.getConfigFile("credentials");
65             if(!configFile.exists()) {
66                 String basePath = System.getProperty("BASE_PATH");
67                 configFile = new File( basePath + File.separator + "conf" + File.separator + "credentials");
68             }
69             Credentials credentials = mapper.readValue(configFile, Credentials.class);
70             User user = usersService.getUser(credentials.userId);
71             return new UserCredentials(user.credentials.userId, user.credentials.password, credentials.userId, "", "");
72         } catch (Exception e) {
73             e.printStackTrace();
74             return null;
75         }
76     }
77
78     @Override
79     protected org.openecomp.sdc.ci.tests.datatypes.Configuration getEnvConfiguration() {
80
81         return TestConfigurationHelper.getEnvConfiguration();
82     }
83
84     @BeforeMethod(alwaysRun = true)
85     public void setBrowserBeforeTestIfDataProvider(Method method, ITestContext context, Object[] params) {
86         // Hack to overcome limitations of SetupCDTest.setBrowserBeforeTest(java.lang.reflect.Method, org.testng.ITestContext)
87         // that skips over dataProvided methods
88         boolean emptyDataProvider = method.getAnnotation(Test.class).dataProvider().isEmpty();
89         if (!emptyDataProvider) {
90             final String testName = method.getName();
91             final String listOfParams = Arrays.deepToString(params)
92                     .replace('[', '(')
93                     .replace(']', ')')
94                     .replaceAll("[\\\\/:*?\"<>|]", "_");
95
96             setLog(testName+listOfParams);
97         }
98     }
99
100     @BeforeSuite(alwaysRun = true)
101     public void screenShotsForReportPortal(){
102         try {
103             ReportPortalListener.setScreenShotsProvider(new WebDriverScreenshotsProvider(getDriver()));
104             System.out.println("Called to ReportPortalListener to set ScreenShotsProvider");
105         } catch (Exception e) {
106             e.printStackTrace();
107         }
108     }
109
110     @Override
111     protected void loginToLocalSimulator(UserCredentials userCredentials) {
112         LoginExternalPage.performLoginExternal(userCredentials);
113     }
114
115     static public class ModelInfo {
116         public final String modelVersionId;
117         public final String modelInvariantId;
118         public final String zipFileName;
119
120         public ModelInfo(String modelVersionId, String modelInvariantId, String zipFileName) {
121             this.modelVersionId = modelVersionId;
122             this.modelInvariantId = modelInvariantId;
123             this.zipFileName = zipFileName;
124         }
125     }
126
127     protected void registerExpectationForLegacyServiceDeployment(String modelVersionId, String modelInvariantId, String zipFileName, String subscriberId) {
128         registerExpectationForServiceDeployment(ServiceDeployment.LEGACY, ImmutableList.of(new ModelInfo(modelVersionId,modelInvariantId,zipFileName)), subscriberId);
129     }
130
131     private enum ServiceDeployment {ASYNC, LEGACY}
132
133     protected void registerExpectationForServiceDeployment(ServiceDeployment serviceDeploymentOnMsoExpectations, List<ModelInfo> modelInfoList, String subscriberId) {
134         List<BasePreset> presets = new ArrayList<>(Arrays.asList(
135                 new PresetGetSessionSlotCheckIntervalGet(),
136                 new PresetAAIGetSubscribersGet(),
137                 new PresetAAIGetServicesGet(),
138                 new PresetAAIGetSubDetailsGet(subscriberId),
139                 new PresetAAIPostNamedQueryForViewEdit("f8791436-8d55-4fde-b4d5-72dd2cf13cfb"),
140                 new PresetAAICloudRegionAndSourceFromConfigurationPut("9533-config-LB1113", "myRandomCloudRegionId"),
141                 new PresetAAIGetPortMirroringSourcePorts("9533-config-LB1113", "myRandomInterfaceId", "i'm a port", true),
142                 new PresetAAIGetNetworkZones(),
143                 new PresetAAIGetTenants(),
144                 new PresetAAIServiceDesignAndCreationPut(modelInfoList.stream().map(
145                         x-> new PresetAAIServiceDesignAndCreationPut.ServiceModelIdentifiers(x.modelVersionId, x.modelInvariantId))
146                         .collect(Collectors.toList()))
147                 ));
148
149         modelInfoList.forEach(modelInfo -> {
150             presets.add(new PresetSDCGetServiceMetadataGet(modelInfo.modelVersionId, modelInfo.modelInvariantId, modelInfo.zipFileName));
151             presets.add(new PresetSDCGetServiceToscaModelGet(modelInfo.modelVersionId, modelInfo.zipFileName));
152         });
153
154         switch (serviceDeploymentOnMsoExpectations) {
155             case ASYNC:
156                 presets.add(new PresetAAISearchNodeQueryEmptyResult());
157                 presets.add(new PresetMSOCreateServiceInstanceGen2());
158                 presets.add(new PresetMSOOrchestrationRequestGet("IN_PROGRESS"));
159                 break;
160             case LEGACY:
161                 presets.add(new PresetMSOCreateServiceInstancePost());
162                 presets.add(new PresetMSOOrchestrationRequestGet());
163                 break;
164         }
165
166         SimulatorApi.registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
167     }
168
169     protected void relogin(Credentials credentials) throws Exception {
170         // `getWindowTest().getPreviousUser()` is SetupCDTest's state of previous user used
171         if (!credentials.userId.equals(getWindowTest().getPreviousUser())) {
172             UserCredentials userCredentials = new UserCredentials(credentials.userId,
173                     credentials.password, "", "", "");
174             reloginWithNewRole(userCredentials);
175         } else {
176             System.out.println(String.format("VidBaseTestCase.relogin() " +
177                     "-> '%s' is already logged in, so skipping", credentials.userId));
178         }
179     }
180
181     /**
182      * Validates that permitted options are enabled and others are disabled.
183      *
184      * @param permittedItems           the list of permitted items.
185      * @param dropdownOptionsClassName the class name of the specific dropdown options.
186      * @return true, if all dropdown options disabled state is according to the permissions.
187      */
188     protected void assertDropdownPermittedItemsByValue(ArrayList<String> permittedItems, String dropdownOptionsClassName) {
189         assertDropdownPermittedItemsByValue(permittedItems, dropdownOptionsClassName, "value");
190     }
191
192     protected void assertDropdownPermittedItemsByLabel(ArrayList<String> permittedItems, String dropdownOptionsClassName) {
193         assertDropdownPermittedItemsByValue(permittedItems, dropdownOptionsClassName, "label");
194     }
195
196     /**
197      * Validates that permitted options are enabled and others are disabled.
198      *
199      * @param permittedItems           the list of permitted items.
200      * @param dropdownOptionsClassName the class name of the specific dropdown options.
201      * @param attribute
202      * @return true, if all dropdown options disabled state is according to the permissions.
203      */
204     private void assertDropdownPermittedItemsByValue(ArrayList<String> permittedItems, String dropdownOptionsClassName, String attribute) {
205         GeneralUIUtils.ultimateWait();
206         List<WebElement> optionsList =
207                 GeneralUIUtils.getWebElementsListBy(By.className(dropdownOptionsClassName), 30);
208         for (WebElement option :
209                 optionsList) {
210             String optionValue = option.getAttribute(attribute);
211             if ((option.isEnabled() && !permittedItems.contains(optionValue)) ||
212                     !option.isEnabled() && permittedItems.contains(optionValue)) {
213                 fail(Constants.DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE);
214             }
215         }
216     }
217
218     protected void assertAllIsPermitted(String dropdownOptionsClassName) {
219         GeneralUIUtils.ultimateWait();
220         List<WebElement> optionsList =
221                 GeneralUIUtils.getWebElementsListBy(By.className(dropdownOptionsClassName), 30);
222         for (WebElement option :
223                 optionsList) {
224             String optionValue = option.getAttribute("value");
225             if (!option.isEnabled()) {
226                 fail(Constants.DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE);
227             }
228         }
229     }
230
231     protected void assertDropdownPermittedItemsByName(ArrayList<String> permittedItems, String dropdownOptionsClassName) {
232         GeneralUIUtils.ultimateWait();
233         List<WebElement> optionsList =
234                 GeneralUIUtils.getWebElementsListBy(By.className(dropdownOptionsClassName), 30);
235         for (WebElement option :
236                 optionsList) {
237             String optionText = option.getText();
238             if ((option.isEnabled() && !permittedItems.contains(optionText)) ||
239                     !option.isEnabled() && permittedItems.contains(optionText)) {
240                 fail(Constants.DROPDOWN_PERMITTED_ASSERT_FAIL_MESSAGE);
241             }
242         }
243     }
244
245     protected void assertViewEditButtonState(String expectedButtonText, String UUID) {
246         WebElement viewEditWebElement = GeneralUIUtils.getWebElementByTestID(Constants.VIEW_EDIT_TEST_ID_PREFIX + UUID, 100);
247         Assert.assertEquals(expectedButtonText, viewEditWebElement.getText());
248         GeneralUIUtils.ultimateWait();
249     }
250
251
252     protected void addNetwork(Map<String, String> metadata,String instanceName, String name, String lcpRegion, String productFamily,String platform, String lineOfBusiness, String tenant, String suppressRollback,
253                                String legacyRegion, ArrayList<String> permittedTenants) {
254         ViewEditPage viewEditPage = new ViewEditPage();
255
256         viewEditPage.selectNetworkToAdd(name);
257         assertModelInfo(metadata, false);
258         viewEditPage.setInstanceName(instanceName);
259         viewEditPage.selectLCPRegion(lcpRegion);
260         viewEditPage.selectProductFamily(productFamily);
261         viewEditPage.selectLineOfBusiness(lineOfBusiness);
262         assertDropdownPermittedItemsByValue(permittedTenants, Constants.ViewEdit.TENANT_OPTION_CLASS);
263         viewEditPage.selectTenant(tenant);
264
265         viewEditPage.selectSuppressRollback(suppressRollback);
266         viewEditPage.selectPlatform(platform);
267         //viewEditPage.setLegacyRegion(legacyRegion);
268
269         viewEditPage.clickConfirmButton();
270         viewEditPage.assertMsoRequestModal(Constants.ViewEdit.MSO_SUCCESSFULLY_TEXT);
271         viewEditPage.clickCloseButton();
272         GeneralUIUtils.ultimateWait();
273     }
274
275     void assertSuccessfulVNFCreation() {
276         boolean byText = GeneralUIUtils.findAndWaitByText(Constants.ViewEdit.VNF_CREATED_SUCCESSFULLY_TEXT, 100);
277         Assert.assertTrue(Constants.ViewEdit.VNF_CREATION_FAILED_MESSAGE, byText);
278     }
279
280     void assertSuccessfulPNFAssociation() {
281         //TODO
282         boolean byText = GeneralUIUtils.findAndWaitByText(Constants.PnfAssociation.PNF_ASSOCIATED_SUCCESSFULLY_TEXT, 100);
283         Assert.assertTrue(Constants.PnfAssociation.PNF_ASSOCIATED_FAILED_MESSAGE, byText);
284     }
285     void assertSuccessfulVolumeGroupCreation() {
286         boolean byText = GeneralUIUtils.findAndWaitByText(Constants.ViewEdit.VOLUME_GROUP_CREATED_SUCCESSFULLY_TEXT, 100);
287         Assert.assertTrue(Constants.ViewEdit.VOLUME_GROUP_CREATION_FAILED_MESSAGE, byText);
288     }
289
290     void assertSuccessfulVFModuleCreation() {
291         boolean byText = GeneralUIUtils.findAndWaitByText(Constants.ViewEdit.VF_MODULE_CREATED_SUCCESSFULLY_TEXT, 100);
292         Assert.assertTrue(Constants.ViewEdit.VF_MODULE_CREATION_FAILED_MESSAGE, byText);
293     }
294
295     @Step("${method}: ${instanceUUID}")
296     void goToExistingInstanceById(String instanceUUID) {
297         SearchExistingPage searchExistingPage = searchExistingInstanceById(instanceUUID);
298         assertViewEditButtonState( Constants.VIEW_EDIT_BUTTON_TEXT, instanceUUID);
299
300         searchExistingPage.clickEditViewByInstanceId(instanceUUID);
301         GeneralUIUtils.ultimateWait();
302     }
303
304     void searchForExistingInstanceByIdReadonlyMode(String instanceUUID) {
305         searchExistingInstanceById(instanceUUID);
306         assertViewEditButtonState( Constants.VIEW_BUTTON_TEXT, instanceUUID);
307     }
308
309     SearchExistingPage searchExistingInstanceById(String instanceUUID){
310         SearchExistingPage searchExistingPage = new SearchExistingPage();
311         SideMenu.navigateToSearchExistingPage();
312         searchExistingPage.searchForInstanceByUuid(instanceUUID);
313         return searchExistingPage;
314     }
315
316
317     void goToExistingInstanceByIdNoWait(String instanceUUID) {
318         SearchExistingPage searchExistingPage = searchExistingInstanceById(instanceUUID);
319         searchExistingPage.clickEditViewByInstanceId(instanceUUID);
320     }
321
322     void resumeVFModule(String vfModuleName, String lcpRegion, String tenant, String legacyRegion, ArrayList<String> permittedTenants){
323         ViewEditPage viewEditPage = new ViewEditPage();
324         viewEditPage.clickResumeButton(vfModuleName);
325         viewEditPage.selectLCPRegion(lcpRegion);
326         assertDropdownPermittedItemsByValue(permittedTenants, Constants.ViewEdit.TENANT_OPTION_CLASS);
327         viewEditPage.selectTenant(tenant);
328         viewEditPage.setLegacyRegion(legacyRegion);
329         viewEditPage.clickConfirmButtonInResumeDelete();
330         assertSuccessfulVFModuleCreation();
331         viewEditPage.clickCommitCloseButton();
332         GeneralUIUtils.ultimateWait();
333     }
334
335     void goToExistingInstanceByName(String instanceName) {
336         SearchExistingPage searchExistingPage = new SearchExistingPage();
337         SideMenu.navigateToSearchExistingPage();
338         searchExistingPage.searchForInstanceByName(instanceName);
339         WebElement instanceIdRow = GeneralUIUtils.getWebElementByTestID(Constants.INSTANCE_ID_FOR_NAME_TEST_ID_PREFIX + instanceName, 30);
340         String instanceId = instanceIdRow.getText();
341         assertViewEditButtonState( Constants.VIEW_EDIT_BUTTON_TEXT, instanceId);
342         searchExistingPage.clickEditViewByInstanceId(instanceId);
343         GeneralUIUtils.ultimateWait();
344     }
345
346     String confirmFilterById(String instanceName, String instanceUUID) {
347         WebElement filter = GeneralUIUtils.getWebElementByTestID(Constants.FILTER_SUBSCRIBER_DETAILS_ID, 30);
348         filter.sendKeys(instanceUUID);
349
350         WebElement firstElement = GeneralUIUtils.getWebElementByTestID(Constants.INSTANCE_ID_FOR_NAME_TEST_ID_PREFIX + instanceName, 30);
351         String filteredId = firstElement.getText();
352         Assert.assertTrue(filteredId.equals(instanceUUID));
353         return filteredId;
354     }
355
356     void goToExistingInstanceBySubscriber(String subscriberName,String instanceName,String instanceUUID) {
357         SearchExistingPage searchExistingPage = new SearchExistingPage();
358         SideMenu.navigateToSearchExistingPage();
359         SelectOption.byIdAndVisibleText(Constants.EditExistingInstance.SELECT_SUBSCRIBER, subscriberName);
360         searchExistingPage.clickSubmitButton();
361         GeneralUIUtils.ultimateWait();
362         confirmFilterById(instanceName, instanceUUID);
363         searchExistingPage.clickEditViewByInstanceId(instanceUUID);
364         GeneralUIUtils.ultimateWait();
365     }
366
367     void selectMsoTestApiOption(String msoTestApiOption) {
368         final String id = "selectTestApi";
369         final String sectionId = "selectTestApiSection";
370
371         SideMenu.navigateToWelcomePage();
372
373         if (Exists.byId(sectionId)) {
374             final JavascriptExecutor javascriptExecutor = (JavascriptExecutor) GeneralUIUtils.getDriver();
375             javascriptExecutor.executeScript(
376                     "document.getElementById('" + sectionId + "').style.visibility = 'inherit';"
377             );
378
379             if (null == SelectOption.byIdAndVisibleText(id, msoTestApiOption)) {
380                 Assert.fail("selectMsoTestApiOptionIfPossible couldnt apply " + msoTestApiOption);
381             }
382         }
383     }
384
385     protected void assertModelInfo(Map<String, String> expectedMetadata, boolean withPrefix) {
386         Wait.angularHttpRequestsLoaded();
387         GeneralUIUtils.ultimateWait();
388         for (Map.Entry<String, String> item: expectedMetadata.entrySet()) {
389             assertMetadataItem(item.getKey(), item.getValue(), withPrefix);
390         }
391     }
392
393     protected <T> void setNewInstance_leftPane_assertModelDataCorrect(Map<String, String> modelKeyToDataTestsIdMap, String prefix, T model) {
394         modelKeyToDataTestsIdMap.forEach((fieldName, dataTestsId) -> {
395             WebElement webElement = Get.byTestId(prefix + dataTestsId);
396             assertEquals(webElement.getText(), getServiceFieldByName(fieldName, model));
397         });
398     }
399
400     protected <T> void setNewInstance_leftPane_assertModelLabelsVisibilityCorrect(Map<String, String> modelKeyToDataTestsIdMap, String prefix, T model) {
401         modelKeyToDataTestsIdMap.forEach((fieldName, dataTestsId) -> {
402             WebElement webElement = Get.byTestId(prefix + dataTestsId);
403             String field = getServiceFieldByName(fieldName, model);
404             assertEquals(webElement.isDisplayed(), !(StringUtils.isEmpty(field)) , dataTestsId + " label shouldn't appear when " + fieldName + " is empty");
405         });
406     }
407
408     private <T> String getServiceFieldByName(String name, T model) {
409         try {
410             return model.getClass().getField(name).get(model).toString();
411         } catch (IllegalAccessException | NoSuchFieldException e) {
412             throw new RuntimeException(e);
413         }
414     }
415
416     private void assertMetadataItem(String keyTestId, String value, boolean withPrefix) {
417         String elementTestId = (withPrefix ? Constants.ServiceModelInfo.INFO_TEST_ID_PREFIX:"") + keyTestId;
418         String infoItemText = GeneralUIUtils.getWebElementByTestID(elementTestId, 60).getText();
419         Assert.assertThat(String.format(Constants.ServiceModelInfo.METADETA_ERROR_MESSAGE, elementTestId),  infoItemText, is(value));
420     }
421
422     public DeployMacroDialogBase getMacroDialog(){
423         if (Features.FLAG_ASYNC_INSTANTIATION.isActive()) {
424             VidBasePage vidBasePage =new VidBasePage();
425             vidBasePage.goToIframe();
426             return new DeployMacroDialog();
427         }
428         else
429             return  new DeployMacroDialogOld();
430     }
431
432     protected void loadServicePopup(String zipFileName, String modelVersionId ) {
433         String modelInvariantId = "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0";
434         String subscriberId = "e433710f-9217-458d-a79d-1c7aff376d89";
435         registerExpectationForServiceDeployment(
436                 ServiceDeployment.ASYNC,
437                 ImmutableList.of(
438                     new ModelInfo(modelVersionId, modelInvariantId, zipFileName),
439                     new ModelInfo("f4d84bb4-a416-4b4e-997e-0059973630b9", "598e3f9e-3244-4d8f-a8e0-0e5d7a29eda9", "service-AdiodVmxVpeBvService488-csar-annotations.zip")
440                 ),
441                 subscriberId);
442         SideMenu.navigateToBrowseASDCPage();
443         GeneralUIUtils.ultimateWait();
444         loadServicePopupOnBrowseASDCPage(modelVersionId);
445     }
446
447     protected void loadServicePopupOnBrowseASDCPage(String modelVersionId ) {
448         DeployMacroDialog deployMacroDialog = new DeployMacroDialog();
449         deployMacroDialog.goOutFromIframe();
450         deployMacroDialog.clickDeployServiceButtonByServiceUUID(modelVersionId);
451         deployMacroDialog.goToIframe();
452         GeneralUIUtils.ultimateWait();
453         Wait.byText("Model version");
454     }
455
456     public void assertSetButtonDisabled(String buttonTestId) {
457         WebElement webElement = Get.byTestId(buttonTestId);
458         org.testng.Assert.assertFalse(webElement.isEnabled(), "Set button should be disabled if not all mandatory fields are field.");
459     }
460
461     public void assertSetButtonEnabled(String buttonTestId) {
462
463         WebElement webElement = Get.byTestId(buttonTestId);
464         org.testng.Assert.assertTrue(webElement.isEnabled(), "Set button should be enabled if all mandatory fields are field.");
465     }
466
467     public void assertElementDisabled(String id) {
468         WebElement webElement = Get.byId(id);
469         assert webElement != null;
470         org.testng.Assert.assertFalse(webElement.isEnabled(), "field should be disabled if the field it depends on was not selected yet.");
471     }
472
473     protected int getUserIdNumberFromDB(User user) {
474         try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) {
475             Statement stmt = connection.createStatement();
476             ResultSet userIdResultSet;
477             userIdResultSet = stmt.executeQuery("SELECT USER_ID FROM fn_user where LOGIN_ID = '" + user.credentials.userId + "'");
478             Assert.assertTrue("Exactly one user should be found", userIdResultSet.next());
479             int userId = userIdResultSet.getInt("USER_ID");
480             Assert.assertFalse("There are more than one user for id " + userId, userIdResultSet.next());
481             return userId;
482         } catch (SQLException e) {
483             throw new IllegalStateException("Cannot connect the database!", e);
484         }
485     }
486
487     protected List<Integer> getRoleIDsAssignedToUser(int userId) {
488         try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) {
489             Statement stmt = connection.createStatement();
490             ResultSet userRolesResultSet;
491             userRolesResultSet = stmt.executeQuery("SELECT ROLE_ID FROM fn_user_role where USER_ID = '" + userId + "' order by ROLE_ID");
492
493             List<Integer> userRoles = new ArrayList<Integer>();
494             while (userRolesResultSet.next()) {
495                 userRoles.add(userRolesResultSet.getInt("ROLE_ID"));
496             }
497             return userRoles;
498         } catch (SQLException e) {
499             throw new IllegalStateException("Cannot connect the database!", e);
500         }
501     }
502
503     protected void navigateToViewEditPageOfuspVoiceVidTest444(String aaiModelVersionId) {
504         VidBasePage vidBasePage = new VidBasePage();
505         SideMenu.navigateToWelcomePage();
506         vidBasePage.navigateTo("serviceModels.htm#/instantiate?" +
507                 "subscriberId=e433710f-9217-458d-a79d-1c7aff376d89&" +
508                 "subscriberName=USP%20VOICE&" +
509                 "serviceType=VIRTUAL%20USP&" +
510                 "serviceInstanceId=3f93c7cb-2fd0-4557-9514-e189b7b04f9d&" +
511                 "aaiModelVersionId=" + aaiModelVersionId + "&" +
512                 "isPermitted=true");
513         GeneralUIUtils.ultimateWait();
514     }
515 }