1 package vid.automation.test.test;
3 import com.google.common.collect.ImmutableList;
4 import org.apache.logging.log4j.LogManager;
5 import org.apache.logging.log4j.Logger;
6 import org.hamcrest.Matchers;
7 import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
8 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetServicesGet;
9 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
10 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIServiceDesignAndCreationPut;
11 import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
12 import org.onap.sdc.ci.tests.datatypes.UserCredentials;
13 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
14 import org.openqa.selenium.By;
15 import org.openqa.selenium.WebElement;
16 import org.testng.Assert;
17 import org.testng.annotations.BeforeClass;
18 import org.testng.annotations.BeforeMethod;
19 import org.testng.annotations.DataProvider;
20 import org.testng.annotations.Test;
21 import vid.automation.test.Constants;
22 import vid.automation.test.infra.*;
23 import vid.automation.test.model.Service;
24 import vid.automation.test.model.User;
25 import vid.automation.test.sections.*;
26 import vid.automation.test.services.ServicesService;
27 import vid.automation.test.services.SimulatorApi;
29 import java.util.List;
31 import static org.hamcrest.MatcherAssert.assertThat;
32 import static org.testng.Assert.assertEquals;
33 import static org.testng.Assert.assertFalse;
34 import static vid.automation.test.infra.Features.FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI;
35 import static vid.automation.test.infra.Features.FLAG_5G_IN_NEW_INSTANTIATION_UI;
36 import static vid.automation.test.infra.ModelInfo.*;
39 public class BrowseASDCTest extends CreateInstanceDialogBaseTest {
40 private final String invariantUUIDAlacarte = aLaCarteForBrowseSdc.modelInvariantId;
41 private final String invariantUUIDMacro = macroForBrowseSdc.modelInvariantId;
42 private final String instantiationTypeNameAlacarte = "a la carte";
43 private final String instantiationTypeNameMacro = "macro";
44 private final String oldMacro = "old macro";
45 private final String newAlacarte = "new a la carte";
46 public static final String modelInvariantUUID1 = "aeababbc-010b-4a60-8df7-e64c07389466";
47 public static final String modelInvariantUUID2 = "aa2f8e9c-9e47-4b15-a95c-4a9385599abc";
48 public static final String modelInvariantUUID3 = "d849c57d-b6fe-4843-8349-4ab8bbb08d71";
49 public static final String modelUuid = "a8dcd72d-d44d-44f2-aa85-53aa9ca99cba";
51 private ServicesService servicesService = new ServicesService();
53 private final Logger logger = LogManager.getLogger(BrowseASDCTest.class);
56 public void beforeClass() {
57 resetGetServicesCache();
61 public void resetSdcModelCaches() {
62 invalidateSdcModelsCache();
66 protected UserCredentials getUserCredentials() {
67 User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL);
68 return new UserCredentials(user.credentials.userId, user.credentials.password, Constants.Users.EMANUEL_EMANUEL, "", "");
71 @Test(groups = {"shouldBeMigratedToWorkWithSimulator"})
72 public void testPNFOnCreatePopup() {
73 Service service = servicesService.getService("f39389e4-2a9c-4085-8ac3-04aea9c651be");
74 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
75 SideMenu.navigateToBrowseASDCPage();
76 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
77 assertThatServiceCreationDialogIsVisible();
78 validatePNFCreationDialog(service, "Emanuel", "pnf");
81 private void validatePNFCreationDialog(Service service, String serviceType, String serviceRole) {
82 assertServiceMetadata(serviceType, Constants.SERVICE_TYPE);
83 assertServiceMetadata(serviceRole, Constants.SERVICE_ROLE);
84 validateServiceCreationDialog(service);
88 // public void clearSimulator() {
89 // SimulatorApi.clearAll();
92 @Test(groups = {"shouldBeMigratedToWorkWithSimulator"})
93 private void testPNFMacroInstantation() throws Exception {
94 User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL);
95 relogin(user.credentials);
97 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
98 SideMenu.navigateToBrowseASDCPage();
99 browseASDCPage.clickDeployServiceButtonByServiceUUID("f39389e4-2a9c-4085-8ac3-04aea9c651be");
100 assertThatServiceCreationDialogIsVisible();
101 assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS);
102 browseASDCPage.selectSubscriberById("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
103 browseASDCPage.selectProductFamily("ebc3bc3d-62fd-4a3f-a037-f619df4ff034");
104 GeneralUIUtils.ultimateWait();
106 browseASDCPage.selectServiceTypeByName("Emanuel");
107 GeneralUIUtils.ultimateWait();
108 browseASDCPage.selectLcpRegion("hvf16");
110 browseASDCPage.selectTenant("a259ae7b7c3f493cb3d91f95a7c18149");
111 assertAllIsPermitted(Constants.BrowseASDC.AIC_OPTION_CLASS);
112 browseASDCPage.selectAicZone("NFT1");
114 Click.onFirstSelectOptionById(Constants.OwningEntity.PROJECT_SELECT_TEST_ID);
115 Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID);
117 browseASDCPage.clickConfirmButton();
119 assertSuccessfulServiceInstanceCreation();
121 browseASDCPage.clickCloseButton();
123 ViewEditPage viewEditPage = new ViewEditPage();
124 viewEditPage.clickActivateButton();
128 private void browseServiceModel_deployServiceALaCarteByBackendInput_creationPopupIsALaCarte() throws Exception {
129 // model uuid should be of macro
130 deployServiceAndAssertInstantiationType(
131 "csar15782222_instantiationTypeAlacarte_invariantUUIDMacro.zip",
133 instantiationTypeNameAlacarte
138 @FeatureTogglingTest(FLAG_5G_IN_NEW_INSTANTIATION_UI)
139 private void browseServiceModel_deployServiceALaCarteByBackendInputHintNewUI_creationPopupIsAngular2() throws Exception {
140 deployServiceAndAssertInstantiationType(
141 instantiationTypeAlacarte_vidNotionsInstantiationUIByUUID,
147 private void browseServiceModel_deployServiceALaCarteBecauseNotOnMACRO_SERVICESConfig_creationPopupIsALaCarte() throws Exception {
148 deployServiceAndAssertInstantiationType(
149 "csar15782222_instantiationTypeEmpty_invariantUUIDAlacarte.zip",
150 invariantUUIDAlacarte,
151 instantiationTypeNameAlacarte
156 private void browseServiceModel_deployServiceMacroByBackendInput_creationPopupIsMacro() throws Exception {
157 deployServiceAndAssertInstantiationType(
158 "csar15782222_instantiationTypeMacro_invariantUUIDAlacarte_withoutNetworks.zip",
159 invariantUUIDAlacarte,
160 instantiationTypeNameMacro
165 private void browseServiceModel_deployServiceMacroByMACRO_SERVICESConfig_creationPopupIsOldMacro() throws Exception {
166 deployServiceAndAssertInstantiationType(
167 "csar15782222_invariantUUIDMacro.zip",
175 private void browseServiceModel_deployServiceMacroWithPnf_creationPopupIsOldMacro() throws Exception {
176 deployServiceAndAssertInstantiationType(
177 "csar15782222_instantiationTypeMacroWithPnf.zip",
185 @FeatureTogglingTest(flagActive = false, value = FLAG_1908_TRANSPORT_SERVICE_NEW_INSTANTIATION_UI)
186 public void browseServiceModel_deployServiceMacroWithCR_creationPopupIsOldMacro() throws Exception {
187 deployServiceAndAssertInstantiationType(
188 "csar15782222_instantiationTypeMacroWithCR.zip",
196 private void browseServiceModel_deployServiceMacroWithNetwork_creationPopupIsMacroByFF() throws Exception {
197 String macroInstantiationAccordingFF = Features.FLAG_NETWORK_TO_ASYNC_INSTANTIATION.isActive() ? instantiationTypeNameMacro : oldMacro;
198 deployServiceAndAssertInstantiationType(
199 "csar15782222_instantiationTypeMacroWithNetwork.zip",
201 macroInstantiationAccordingFF
206 private void deployServiceAndAssertInstantiationType(String modelZipFileName, String modelInvariantId, String expectedInstantiationType) throws Exception {
207 deployServiceAndAssertInstantiationType(new ModelInfo("4d71990b-d8ad-4510-ac61-496288d9078e", modelInvariantId, modelZipFileName), expectedInstantiationType);
210 private void deployServiceAndAssertInstantiationType(ModelInfo modelInfo, String expectedInstantiationType) throws Exception {
212 registerExpectationForLegacyServiceDeployment(modelInfo, "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
213 User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL);
214 relogin(user.credentials);
216 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
217 SideMenu.navigateToBrowseASDCPage();
219 GeneralUIUtils.ultimateWait();
220 browseASDCPage.clickDeployServiceButtonByServiceUUID(modelInfo.modelVersionId);
221 DeployMacroDialogBase macroDialog = null;
222 if (expectedInstantiationType.equals(instantiationTypeNameAlacarte)) {
223 GeneralUIUtils.ultimateWait();
224 browseASDCPage.clickCancelButtonByTestID();
226 macroDialog = expectedInstantiationType.equals(oldMacro) ? new DeployMacroDialogOld() : getMacroDialog();
227 macroDialog.assertTitle();
228 macroDialog.closeDialog();
233 private void testServiceInstantiationAlaCarte() throws Exception {
234 User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL);
235 relogin(user.credentials);
237 registerExpectationForLegacyServiceDeployment(aLaCarteServiceCreationTest, "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
239 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
240 SideMenu.navigateToBrowseASDCPage();
242 Service service = new Service(
244 aLaCarteServiceCreationTest.modelVersionId,
245 aLaCarteServiceCreationTest.modelInvariantId,
249 "PASQUALE vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM",
253 logger.info("Expected service model properties: "+service.toString());
254 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
255 validateServiceCreationDialog(service);
257 browseASDCPage.setInstanceName(browseASDCPage.generateInstanceName());
259 assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS);
260 browseASDCPage.selectSubscriberById("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
262 String serviceType = "Emanuel";
263 GeneralUIUtils.findAndWaitByText(serviceType, 30);
265 assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS);
266 browseASDCPage.selectServiceTypeByName(serviceType);
268 SelectOption.byTestIdAndVisibleText("yyy1", Constants.OwningEntity.PROJECT_SELECT_TEST_ID);
269 SelectOption.byTestIdAndVisibleText("aaa1", Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID);
271 browseASDCPage.selectSuppressRollback("false");
273 browseASDCPage.clickConfirmButton();
275 assertSuccessfulServiceInstanceCreation();
278 private static final String serviceName = "CONTRAIL30_L2NODHCP";
279 private static final String modelInvariantId = "5b607929-6088-4614-97ef-cac817508e0e";
280 private static final String serviceUuid = "797a6c41-0f80-4d35-a288-3920c4e06baa";
284 public static Object[][] filterTexts() {
285 return new Object[][]{{serviceName},{modelInvariantId},{serviceUuid}};
288 @Test(dataProvider = "filterTexts")
289 public void testFilterOptionsInBrowseSdc(String filterText){
290 BrowseASDCPage browseAsdcPage = registerSimulatorAndGoToBrowseSDC();
291 GeneralUIUtils.ultimateWait();
292 assertThat(browseAsdcPage.countCurrentRowsInTable(),(Matchers.greaterThan(1)));
293 browseAsdcPage.fillFilterText(filterText);
294 Assert.assertEquals(browseAsdcPage.countCurrentRowsInTable(),1);
295 Assert.assertTrue(Exists.byTestId("deploy-" + serviceUuid));
296 browseAsdcPage.fillFilterText("");
301 private void testCategoryParamsDropdownsExistsInCreationDialog() throws Exception {
302 BrowseASDCPage browseASDCPage = registerSimulatorAndGoToBrowseSDC();
303 Service service = servicesService.getService("2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd");
304 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
305 DeployMacroDialogBase deployMacroDialog = getMacroDialog();
306 deployMacroDialog.assertDialogExists();
307 deployMacroDialog.clickProjectSelect();
308 deployMacroDialog.clickOwningEntitySelect();
311 private BrowseASDCPage registerSimulatorAndGoToBrowseSDC() {
312 SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET,
313 "ecompportal_getSessionSlotCheckInterval.json",
314 "browseASDC/aai_get_services.json",
315 "browseASDC/get_sdc_catalog_services_2f80c596.json"
317 SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
318 new PresetAAIGetSubscribersGet(),
319 new PresetAAIServiceDesignAndCreationPut()
321 SimulatorApi.RegistrationStrategy.APPEND);
322 SideMenu.navigateToBrowseASDCPage();
323 return new BrowseASDCPage();
326 @Test(groups = {"shouldBeMigratedToWorkWithSimulator"})
327 private void testOwningEntityRequiredAndProjectOptional() throws Exception {
328 User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA);
329 relogin(user.credentials);
331 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
332 SideMenu.navigateToBrowseASDCPage();
334 Service service = servicesService.getService("c079d859-4d81-4add-a9c3-94551f96e2b0");
336 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
337 validateServiceCreationDialog(service);
339 browseASDCPage.setInstanceName(browseASDCPage.generateInstanceName());
341 assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS);
342 browseASDCPage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89");
344 String serviceType = "TYLER SILVIA";
345 GeneralUIUtils.findAndWaitByText(serviceType, 30);
347 assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS);
348 browseASDCPage.selectServiceTypeByName(serviceType);
350 browseASDCPage.clickConfirmButton();
352 GeneralUIUtils.findAndWaitByText("Missing data", 5);
354 Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID);
356 browseASDCPage.clickConfirmButton();
357 assertSuccessfulServiceInstanceCreation();
360 @Test(groups = {"shouldBeMigratedToWorkWithSimulator"})
361 protected void testLineOfBusinessOptionalAndPlatformRequired() throws Exception {
363 User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA);
364 relogin(user.credentials);
366 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
367 SideMenu.navigateToBrowseASDCPage();
369 Service service = servicesService.getService("c079d859-4d81-4add-a9c3-94551f96e2b0");
371 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
372 validateServiceCreationDialog(service);
374 browseASDCPage.setInstanceName(browseASDCPage.generateInstanceName());
376 assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS);
377 browseASDCPage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89");
379 String serviceType = "TYLER SILVIA";
380 GeneralUIUtils.findAndWaitByText(serviceType, 30);
382 assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS);
383 browseASDCPage.selectServiceTypeByName(serviceType);
385 Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID);
387 browseASDCPage.clickConfirmButton();
388 assertSuccessfulServiceInstanceCreation();
390 browseASDCPage.clickCloseButton();
391 GeneralUIUtils.ultimateWait();
394 ViewEditPage viewEditPage = new ViewEditPage();
396 viewEditPage.selectNodeInstanceToAdd("VID-RODERICK-05-15-17 0");
397 viewEditPage.generateAndSetInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX);
398 viewEditPage.selectProductFamily("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
399 viewEditPage.selectLcpRegion("AAIAIC25", "AIC");
400 viewEditPage.selectTenant("092eb9e8e4b7412e8787dd091bc58e86");
401 viewEditPage.setLegacyRegion("llkjhlkjhlkjh");
403 browseASDCPage.clickConfirmButton();
405 GeneralUIUtils.findAndWaitByText("Missing data", 5);
407 Click.onFirstSelectOptionById(Constants.OwningEntity.PLATFORM_SELECT_TEST_ID);
409 viewEditPage.clickConfirmButton();
410 assertSuccessfulVNFCreation();
413 private void prepareSimulatorWithServiceModelListBeforeBrowseASDCService(){
414 SimulatorApi.clearAll();
416 ImmutableList<BasePreset> presets = ImmutableList.of(
417 new PresetGetSessionSlotCheckIntervalGet(),
418 new PresetAAIGetSubscribersGet(),
419 new PresetAAIServiceDesignAndCreationPut(),
420 new PresetAAIGetServicesGet());
422 SimulatorApi.registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
426 private void browseSDCServiceModelListCheckAAIResponse(){
427 prepareSimulatorWithServiceModelListBeforeBrowseASDCService();
428 SideMenu.navigateToBrowseASDCPage();
429 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
430 browseASDCPage.fillFilterText("CheckAAIResponse");
431 GeneralUIUtils.ultimateWait();
433 WebElement sdcTableElement = Get.byId("sdcModelsTable");
434 List<WebElement> sdcModelList = sdcTableElement.findElements(By.className("sdcServiceModel"));
436 WebElement sdcFirstModel = sdcModelList.get(0);
437 WebElement sdcSecondModel = sdcModelList.get(1);
438 WebElement sdcThirdModel = sdcModelList.get(2);
441 By uuid = By.className("uuid");
442 assertEquals(modelUuid, sdcFirstModel.findElement(uuid).getText());
443 assertEquals("1dae721c-a1ef-435f-b811-760c23f467bf" , sdcSecondModel.findElement(uuid).getText());
444 assertEquals("29236d45-e790-4c17-a115-1533cc09b7b1" , sdcThirdModel.findElement(uuid).getText());
446 //Check invariantUUID
447 By invariantUUID = By.className("invariantUUID");
448 assertEquals(modelInvariantUUID1, sdcFirstModel.findElement(invariantUUID).getText());
449 assertEquals(modelInvariantUUID2, sdcSecondModel.findElement(invariantUUID).getText());
450 assertEquals(modelInvariantUUID3, sdcThirdModel.findElement(invariantUUID).getText());
453 By name = By.className("name");
454 assertEquals("CheckAAIResponse_AAAvIRC_mm779p_Service" , sdcFirstModel.findElement(name).getText());
455 assertEquals("CheckAAIResponse_BBBvIRC_mm779p_Service" , sdcSecondModel.findElement(name).getText());
456 assertEquals("CheckAAIResponse_CCCvIRC_mm779p_Service" , sdcThirdModel.findElement(name).getText());
458 //Check distribution Status
459 By distributionStatus = By.className("distributionStatus");
460 assertEquals("DISTRIBUTION_COMPLETE_OK" , sdcFirstModel.findElement(distributionStatus).getText());
461 assertEquals("", sdcSecondModel.findElement(distributionStatus).getText());
462 assertEquals("DISTRIBUTION_COMPLETE_ERROR" , sdcThirdModel.findElement(distributionStatus).getText());
464 //Check another fields
465 assertEquals("service" , sdcFirstModel.findElement(By.className("category")).getText());
466 assertEquals("1.0" , sdcFirstModel.findElement(By.className("version")).getText());
470 public void browseSdcModel_getEmptyList_noModelsMessageIsShown() {
471 resetGetServicesCache();
472 SimulatorApi.clearAll();
473 SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
474 new PresetAAIServiceDesignAndCreationPut(true),
475 new PresetAAIGetSubscribersGet()), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
476 SideMenu.navigateToBrowseASDCPage();
477 GeneralUIUtils.ultimateWait();
478 WebElement serviceModelsTbody = Get.byXpath("//table[@data-tests-id='serviceModelsTable']/tbody");
479 assertFalse(Exists.tagNameInAnotherElement(serviceModelsTbody, "tr"), "Table should be empty on empty results");
480 resetGetServicesCache();