1 package vid.automation.test.test;
3 import static org.hamcrest.MatcherAssert.assertThat;
4 import static org.testng.Assert.assertEquals;
5 import static org.testng.Assert.assertFalse;
6 import static vid.automation.test.infra.Features.FLAG_5G_IN_NEW_INSTANTIATION_UI;
7 import static vid.automation.test.infra.ModelInfo.aLaCarteForBrowseSdc;
8 import static vid.automation.test.infra.ModelInfo.aLaCarteServiceCreationTest;
9 import static vid.automation.test.infra.ModelInfo.instantiationTypeAlacarte_vidNotionsInstantiationUIByUUID;
10 import static vid.automation.test.infra.ModelInfo.macroForBrowseSdc;
12 import com.google.common.collect.ImmutableList;
13 import java.util.List;
14 import org.apache.logging.log4j.LogManager;
15 import org.apache.logging.log4j.Logger;
16 import org.hamcrest.Matchers;
17 import org.onap.sdc.ci.tests.datatypes.UserCredentials;
18 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
19 import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
20 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetServicesGet;
21 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
22 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIServiceDesignAndCreationPut;
23 import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
24 import org.openqa.selenium.By;
25 import org.openqa.selenium.WebElement;
26 import org.testng.Assert;
27 import org.testng.annotations.BeforeClass;
28 import org.testng.annotations.BeforeMethod;
29 import org.testng.annotations.DataProvider;
30 import org.testng.annotations.Test;
31 import vid.automation.test.Constants;
32 import vid.automation.test.infra.Click;
33 import vid.automation.test.infra.Exists;
34 import vid.automation.test.infra.FeatureTogglingTest;
35 import vid.automation.test.infra.Features;
36 import vid.automation.test.infra.Get;
37 import vid.automation.test.infra.ModelInfo;
38 import vid.automation.test.infra.SelectOption;
39 import vid.automation.test.model.Service;
40 import vid.automation.test.model.User;
41 import vid.automation.test.sections.BrowseASDCPage;
42 import vid.automation.test.sections.DeployMacroDialogBase;
43 import vid.automation.test.sections.DeployMacroDialogOld;
44 import vid.automation.test.sections.SideMenu;
45 import vid.automation.test.sections.ViewEditPage;
46 import vid.automation.test.services.ServicesService;
47 import vid.automation.test.services.SimulatorApi;
50 public class BrowseASDCTest extends CreateInstanceDialogBaseTest {
51 private final String invariantUUIDAlacarte = aLaCarteForBrowseSdc.modelInvariantId;
52 private final String invariantUUIDMacro = macroForBrowseSdc.modelInvariantId;
53 private final String instantiationTypeNameAlacarte = "a la carte";
54 private final String instantiationTypeNameMacro = "macro";
55 private final String oldMacro = "old macro";
56 private final String newAlacarte = "new a la carte";
57 public static final String modelInvariantUUID1 = "aeababbc-010b-4a60-8df7-e64c07389466";
58 public static final String modelInvariantUUID2 = "aa2f8e9c-9e47-4b15-a95c-4a9385599abc";
59 public static final String modelInvariantUUID3 = "d849c57d-b6fe-4843-8349-4ab8bbb08d71";
60 public static final String modelUuid = "a8dcd72d-d44d-44f2-aa85-53aa9ca99cba";
62 private ServicesService servicesService = new ServicesService();
64 private final Logger logger = LogManager.getLogger(BrowseASDCTest.class);
67 public void beforeClass() {
68 resetGetServicesCache();
72 public void resetSdcModelCaches() {
73 invalidateSdcModelsCache();
77 protected UserCredentials getUserCredentials() {
78 User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL);
79 return new UserCredentials(user.credentials.userId, user.credentials.password, Constants.Users.EMANUEL_EMANUEL, "", "");
82 @Test(groups = {"shouldBeMigratedToWorkWithSimulator"})
83 public void testPNFOnCreatePopup() {
84 Service service = servicesService.getService("f39389e4-2a9c-4085-8ac3-04aea9c651be");
85 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
86 SideMenu.navigateToBrowseASDCPage();
87 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
88 assertThatServiceCreationDialogIsVisible();
89 validatePNFCreationDialog(service, "Emanuel", "pnf");
92 private void validatePNFCreationDialog(Service service, String serviceType, String serviceRole) {
93 assertServiceMetadata(serviceType, Constants.SERVICE_TYPE);
94 assertServiceMetadata(serviceRole, Constants.SERVICE_ROLE);
95 validateServiceCreationDialog(service);
99 // public void clearSimulator() {
100 // SimulatorApi.clearAll();
103 @Test(groups = {"shouldBeMigratedToWorkWithSimulator"})
104 private void testPNFMacroInstantation() throws Exception {
105 User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL);
106 relogin(user.credentials);
108 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
109 SideMenu.navigateToBrowseASDCPage();
110 browseASDCPage.clickDeployServiceButtonByServiceUUID("f39389e4-2a9c-4085-8ac3-04aea9c651be");
111 assertThatServiceCreationDialogIsVisible();
112 assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS);
113 browseASDCPage.selectSubscriberById("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
114 browseASDCPage.selectProductFamily("ebc3bc3d-62fd-4a3f-a037-f619df4ff034");
115 GeneralUIUtils.ultimateWait();
117 browseASDCPage.selectServiceTypeByName("Emanuel");
118 GeneralUIUtils.ultimateWait();
119 browseASDCPage.selectLcpRegion("hvf16");
121 browseASDCPage.selectTenant("a259ae7b7c3f493cb3d91f95a7c18149");
122 assertAllIsPermitted(Constants.BrowseASDC.AIC_OPTION_CLASS);
123 browseASDCPage.selectAicZone("NFT1");
125 Click.onFirstSelectOptionById(Constants.OwningEntity.PROJECT_SELECT_TEST_ID);
126 Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID);
128 browseASDCPage.clickConfirmButton();
130 assertSuccessfulServiceInstanceCreation();
132 browseASDCPage.clickCloseButton();
134 ViewEditPage viewEditPage = new ViewEditPage();
135 viewEditPage.clickActivateButton();
139 private void browseServiceModel_deployServiceALaCarteByBackendInput_creationPopupIsALaCarte() throws Exception {
140 // model uuid should be of macro
141 deployServiceAndAssertInstantiationType(
142 "csar15782222_instantiationTypeAlacarte_invariantUUIDMacro.zip",
144 instantiationTypeNameAlacarte
149 @FeatureTogglingTest(FLAG_5G_IN_NEW_INSTANTIATION_UI)
150 private void browseServiceModel_deployServiceALaCarteByBackendInputHintNewUI_creationPopupIsAngular2() throws Exception {
151 deployServiceAndAssertInstantiationType(
152 instantiationTypeAlacarte_vidNotionsInstantiationUIByUUID,
158 private void browseServiceModel_deployServiceALaCarteBecauseNotOnMACRO_SERVICESConfig_creationPopupIsALaCarte() throws Exception {
159 deployServiceAndAssertInstantiationType(
160 "csar15782222_instantiationTypeEmpty_invariantUUIDAlacarte.zip",
161 invariantUUIDAlacarte,
162 instantiationTypeNameAlacarte
167 private void browseServiceModel_deployServiceMacroByBackendInput_creationPopupIsMacro() throws Exception {
168 deployServiceAndAssertInstantiationType(
169 "csar15782222_instantiationTypeMacro_invariantUUIDAlacarte_withoutNetworks.zip",
170 invariantUUIDAlacarte,
171 instantiationTypeNameMacro
176 private void browseServiceModel_deployServiceMacroByMACRO_SERVICESConfig_creationPopupIsOldMacro() throws Exception {
177 deployServiceAndAssertInstantiationType(
178 "csar15782222_invariantUUIDMacro.zip",
186 private void browseServiceModel_deployServiceMacroWithPnf_creationPopupIsOldMacro() throws Exception {
187 deployServiceAndAssertInstantiationType(
188 "csar15782222_instantiationTypeMacroWithPnf.zip",
196 private void browseServiceModel_deployServiceMacroWithCR_creationPopupIsOldMacro() throws Exception {
197 deployServiceAndAssertInstantiationType(
198 "csar15782222_instantiationTypeMacroWithCR.zip",
206 private void browseServiceModel_deployServiceMacroWithNetwork_creationPopupIsMacroByFF() throws Exception {
207 String macroInstantiationAccordingFF = Features.FLAG_ASYNC_INSTANTIATION.isActive() && Features.FLAG_NETWORK_TO_ASYNC_INSTANTIATION.isActive() ? instantiationTypeNameMacro : oldMacro;
208 deployServiceAndAssertInstantiationType(
209 "csar15782222_instantiationTypeMacroWithNetwork.zip",
211 macroInstantiationAccordingFF
216 private void deployServiceAndAssertInstantiationType(String modelZipFileName, String modelInvariantId, String expectedInstantiationType) throws Exception {
217 deployServiceAndAssertInstantiationType(new ModelInfo("4d71990b-d8ad-4510-ac61-496288d9078e", modelInvariantId, modelZipFileName), expectedInstantiationType);
220 private void deployServiceAndAssertInstantiationType(ModelInfo modelInfo, String expectedInstantiationType) throws Exception {
222 registerExpectationForLegacyServiceDeployment(modelInfo, "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
223 User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL);
224 relogin(user.credentials);
226 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
227 SideMenu.navigateToBrowseASDCPage();
229 GeneralUIUtils.ultimateWait();
230 browseASDCPage.clickDeployServiceButtonByServiceUUID(modelInfo.modelVersionId);
231 DeployMacroDialogBase macroDialog = null;
232 if (expectedInstantiationType.equals(instantiationTypeNameAlacarte)) {
233 GeneralUIUtils.ultimateWait();
234 browseASDCPage.clickCancelButtonByTestID();
236 macroDialog = expectedInstantiationType.equals(oldMacro) ? new DeployMacroDialogOld() : getMacroDialog();
237 macroDialog.assertTitle();
238 macroDialog.closeDialog();
243 private void testServiceInstantiationAlaCarte() throws Exception {
244 User user = usersService.getUser(Constants.Users.EMANUEL_EMANUEL);
245 relogin(user.credentials);
247 registerExpectationForLegacyServiceDeployment(aLaCarteServiceCreationTest, "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
249 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
250 SideMenu.navigateToBrowseASDCPage();
252 Service service = new Service(
254 aLaCarteServiceCreationTest.modelVersionId,
255 aLaCarteServiceCreationTest.modelInvariantId,
259 "PASQUALE vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM",
263 logger.info("Expected service model properties: "+service.toString());
264 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
265 validateServiceCreationDialog(service);
267 browseASDCPage.setInstanceName(browseASDCPage.generateInstanceName());
269 assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS);
270 browseASDCPage.selectSubscriberById("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
272 String serviceType = "Emanuel";
273 GeneralUIUtils.findAndWaitByText(serviceType, 30);
275 assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS);
276 browseASDCPage.selectServiceTypeByName(serviceType);
278 SelectOption.byTestIdAndVisibleText("yyy1", Constants.OwningEntity.PROJECT_SELECT_TEST_ID);
279 SelectOption.byTestIdAndVisibleText("aaa1", Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID);
281 browseASDCPage.selectSuppressRollback("false");
283 browseASDCPage.clickConfirmButton();
285 assertSuccessfulServiceInstanceCreation();
288 private static final String serviceName = "CONTRAIL30_L2NODHCP";
289 private static final String modelInvariantId = "5b607929-6088-4614-97ef-cac817508e0e";
290 private static final String serviceUuid = "797a6c41-0f80-4d35-a288-3920c4e06baa";
294 public static Object[][] filterTexts() {
295 return new Object[][]{{serviceName},{modelInvariantId},{serviceUuid}};
298 @Test(dataProvider = "filterTexts")
299 public void testFilterOptionsInBrowseSdc(String filterText){
300 BrowseASDCPage browseAsdcPage = registerSimulatorAndGoToBrowseSDC();
301 GeneralUIUtils.ultimateWait();
302 assertThat(browseAsdcPage.countCurrentRowsInTable(),(Matchers.greaterThan(1)));
303 browseAsdcPage.fillFilterText(filterText);
304 Assert.assertEquals(browseAsdcPage.countCurrentRowsInTable(),1);
305 Assert.assertTrue(Exists.byTestId("deploy-" + serviceUuid));
306 browseAsdcPage.fillFilterText("");
311 private void testCategoryParamsDropdownsExistsInCreationDialog() throws Exception {
312 BrowseASDCPage browseASDCPage = registerSimulatorAndGoToBrowseSDC();
313 Service service = servicesService.getService("2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd");
314 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
315 DeployMacroDialogBase deployMacroDialog = getMacroDialog();
316 deployMacroDialog.assertDialogExists();
317 deployMacroDialog.clickProjectSelect();
318 deployMacroDialog.clickOwningEntitySelect();
321 private BrowseASDCPage registerSimulatorAndGoToBrowseSDC() {
322 SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET,
323 "ecompportal_getSessionSlotCheckInterval.json",
324 "browseASDC/aai_get_services.json",
325 "browseASDC/get_sdc_catalog_services_2f80c596.json"
327 SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
328 new PresetAAIGetSubscribersGet(),
329 new PresetAAIServiceDesignAndCreationPut()
331 SimulatorApi.RegistrationStrategy.APPEND);
332 SideMenu.navigateToBrowseASDCPage();
333 return new BrowseASDCPage();
336 @Test(groups = {"shouldBeMigratedToWorkWithSimulator"})
337 private void testOwningEntityRequiredAndProjectOptional() throws Exception {
338 User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA);
339 relogin(user.credentials);
341 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
342 SideMenu.navigateToBrowseASDCPage();
344 Service service = servicesService.getService("c079d859-4d81-4add-a9c3-94551f96e2b0");
346 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
347 validateServiceCreationDialog(service);
349 browseASDCPage.setInstanceName(browseASDCPage.generateInstanceName());
351 assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS);
352 browseASDCPage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89");
354 String serviceType = "TYLER SILVIA";
355 GeneralUIUtils.findAndWaitByText(serviceType, 30);
357 assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS);
358 browseASDCPage.selectServiceTypeByName(serviceType);
360 browseASDCPage.clickConfirmButton();
362 GeneralUIUtils.findAndWaitByText("Missing data", 5);
364 Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID);
366 browseASDCPage.clickConfirmButton();
367 assertSuccessfulServiceInstanceCreation();
370 @Test(groups = {"shouldBeMigratedToWorkWithSimulator"})
371 protected void testLineOfBusinessOptionalAndPlatformRequired() throws Exception {
373 User user = usersService.getUser(Constants.Users.SILVIA_ROBBINS_TYLER_SILVIA);
374 relogin(user.credentials);
376 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
377 SideMenu.navigateToBrowseASDCPage();
379 Service service = servicesService.getService("c079d859-4d81-4add-a9c3-94551f96e2b0");
381 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
382 validateServiceCreationDialog(service);
384 browseASDCPage.setInstanceName(browseASDCPage.generateInstanceName());
386 assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS);
387 browseASDCPage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89");
389 String serviceType = "TYLER SILVIA";
390 GeneralUIUtils.findAndWaitByText(serviceType, 30);
392 assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS);
393 browseASDCPage.selectServiceTypeByName(serviceType);
395 Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID);
397 browseASDCPage.clickConfirmButton();
398 assertSuccessfulServiceInstanceCreation();
400 browseASDCPage.clickCloseButton();
401 GeneralUIUtils.ultimateWait();
404 ViewEditPage viewEditPage = new ViewEditPage();
406 viewEditPage.selectNodeInstanceToAdd("VID-RODERICK-05-15-17 0");
407 viewEditPage.generateAndSetInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX);
408 viewEditPage.selectProductFamily("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
409 viewEditPage.selectLcpRegion("JANET25", "AIC");
410 viewEditPage.selectTenant("092eb9e8e4b7412e8787dd091bc58e86");
411 viewEditPage.setLegacyRegion("llkjhlkjhlkjh");
413 browseASDCPage.clickConfirmButton();
415 GeneralUIUtils.findAndWaitByText("Missing data", 5);
417 Click.onFirstSelectOptionById(Constants.OwningEntity.PLATFORM_SELECT_TEST_ID);
419 viewEditPage.clickConfirmButton();
420 assertSuccessfulVNFCreation();
423 private void prepareSimulatorWithServiceModelListBeforeBrowseASDCService(){
424 SimulatorApi.clearAll();
426 ImmutableList<BasePreset> presets = ImmutableList.of(
427 new PresetGetSessionSlotCheckIntervalGet(),
428 new PresetAAIGetSubscribersGet(),
429 new PresetAAIServiceDesignAndCreationPut(),
430 new PresetAAIGetServicesGet());
432 SimulatorApi.registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
436 private void browseSDCServiceModelListCheckAAIResponse(){
437 prepareSimulatorWithServiceModelListBeforeBrowseASDCService();
438 SideMenu.navigateToBrowseASDCPage();
439 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
440 browseASDCPage.fillFilterText("CheckAAIResponse");
441 GeneralUIUtils.ultimateWait();
443 WebElement sdcTableElement = Get.byId("sdcModelsTable");
444 List<WebElement> sdcModelList = sdcTableElement.findElements(By.className("sdcServiceModel"));
446 WebElement sdcFirstModel = sdcModelList.get(0);
447 WebElement sdcSecondModel = sdcModelList.get(1);
448 WebElement sdcThirdModel = sdcModelList.get(2);
451 By uuid = By.className("uuid");
452 assertEquals(modelUuid, sdcFirstModel.findElement(uuid).getText());
453 assertEquals("1dae721c-a1ef-435f-b811-760c23f467bf" , sdcSecondModel.findElement(uuid).getText());
454 assertEquals("29236d45-e790-4c17-a115-1533cc09b7b1" , sdcThirdModel.findElement(uuid).getText());
456 //Check invariantUUID
457 By invariantUUID = By.className("invariantUUID");
458 assertEquals(modelInvariantUUID1, sdcFirstModel.findElement(invariantUUID).getText());
459 assertEquals(modelInvariantUUID2, sdcSecondModel.findElement(invariantUUID).getText());
460 assertEquals(modelInvariantUUID3, sdcThirdModel.findElement(invariantUUID).getText());
463 By name = By.className("name");
464 assertEquals("CheckAAIResponse_AAAvIRC_mm779p_Service" , sdcFirstModel.findElement(name).getText());
465 assertEquals("CheckAAIResponse_BBBvIRC_mm779p_Service" , sdcSecondModel.findElement(name).getText());
466 assertEquals("CheckAAIResponse_CCCvIRC_mm779p_Service" , sdcThirdModel.findElement(name).getText());
468 //Check distribution Status
469 By distributionStatus = By.className("distributionStatus");
470 assertEquals("DISTRIBUTION_COMPLETE_OK" , sdcFirstModel.findElement(distributionStatus).getText());
471 assertEquals("", sdcSecondModel.findElement(distributionStatus).getText());
472 assertEquals("DISTRIBUTION_COMPLETE_ERROR" , sdcThirdModel.findElement(distributionStatus).getText());
474 //Check another fields
475 assertEquals("service" , sdcFirstModel.findElement(By.className("category")).getText());
476 assertEquals("1.0" , sdcFirstModel.findElement(By.className("version")).getText());
480 public void browseSdcModel_getEmptyList_noModelsMessageIsShown() {
481 resetGetServicesCache();
482 SimulatorApi.clearAll();
483 SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
484 new PresetAAIServiceDesignAndCreationPut(true),
485 new PresetAAIGetSubscribersGet()), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
486 SideMenu.navigateToBrowseASDCPage();
487 GeneralUIUtils.ultimateWait();
488 WebElement serviceModelsTbody = Get.byXpath("//table[@data-tests-id='serviceModelsTable']/tbody");
489 assertFalse(Exists.tagNameInAnotherElement(serviceModelsTbody, "tr"), "Table should be empty on empty results");
490 resetGetServicesCache();