1 package vid.automation.test.test;
3 import com.google.common.collect.ImmutableList;
4 import org.glassfish.jersey.uri.internal.JerseyUriBuilder;
5 import org.hamcrest.Matchers;
6 import org.opencomp.simulator.presetGenerator.presets.BasePresets.BasePreset;
7 import org.opencomp.simulator.presetGenerator.presets.aai.PresetAAIGetServiceModelList;
8 import org.opencomp.simulator.presetGenerator.presets.aai.PresetAAIGetServicesGet;
9 import org.opencomp.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
10 import org.opencomp.simulator.presetGenerator.presets.aai.PresetAAIServiceDesignAndCreationPut;
11 import org.opencomp.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet;
12 import org.openecomp.sdc.ci.tests.datatypes.UserCredentials;
13 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
14 import org.openqa.selenium.By;
15 import org.openqa.selenium.WebElement;
16 import org.springframework.http.client.ClientHttpRequestInterceptor;
17 import org.springframework.web.client.RestTemplate;
18 import org.testng.Assert;
19 import org.testng.annotations.BeforeClass;
20 import org.testng.annotations.BeforeMethod;
21 import org.testng.annotations.DataProvider;
22 import org.testng.annotations.Test;
23 import vid.automation.test.Constants;
24 import vid.automation.test.infra.*;
25 import vid.automation.test.model.Service;
26 import vid.automation.test.model.User;
27 import vid.automation.test.sections.*;
28 import vid.automation.test.services.ServicesService;
29 import vid.automation.test.services.SimulatorApi;
30 import vid.automation.test.utils.CookieAndJsonHttpHeadersInterceptor;
33 import java.net.URISyntaxException;
34 import java.util.List;
36 import static java.util.Collections.singletonList;
37 import static org.hamcrest.MatcherAssert.assertThat;
38 import static org.testng.Assert.assertEquals;
39 import static org.testng.Assert.assertFalse;
42 public class BrowseASDCTest extends CreateInstanceDialogBaseTest {
43 private final String invariantUUIDAlacarte = "a8dcd72d-d44d-44f2-aa85-53aa9ca99cba";
44 private final String invariantUUIDMacro = "d27e42cf-087e-4d31-88ac-6c4b7585f800";
45 private final String instantiationTypeNameAlacarte = "a la carte";
46 private final String instantiationTypeNameMacro = "macro";
47 private final String oldMacro = "old macro";
48 private String modelInvariantUUID1 = "aeababbc-010b-4a60-8df7-e64c07389466";
49 private String modelInvariantUUID2 = "aa2f8e9c-9e47-4b15-a95c-4a9385599abc";
50 private String modelInvariantUUID3 = "d849c57d-b6fe-4843-8349-4ab8bbb08d71";
51 private String modelUuid = "a8dcd72d-d44d-44f2-aa85-53aa9ca99cba";
52 protected final RestTemplate restTemplate = new RestTemplate();
54 private ServicesService servicesService = new ServicesService();
56 protected final URI uri;
58 public BrowseASDCTest() throws URISyntaxException {
59 this.envUrI = new URI(System.getProperty("ENV_URL"));
60 this.uri = new JerseyUriBuilder().host(envUrI.getHost()).port(envUrI.getPort()).scheme("http").path("vid").build();
65 UserCredentials userCredentials = getUserCredentials();
66 final List<ClientHttpRequestInterceptor> interceptors = singletonList(new CookieAndJsonHttpHeadersInterceptor(uri, userCredentials));
67 restTemplate.setInterceptors(interceptors);
71 public void invalidateTheCacheSelenium() {
72 if (Features.FLAG_SERVICE_MODEL_CACHE.isActive()) {
73 restTemplate.postForObject(uri + "/rest/models/reset", "", Object.class);
78 protected UserCredentials getUserCredentials() {
79 User user = usersService.getUser(Constants.Users.MOBILITY_MOBILITY);
80 return new UserCredentials(user.credentials.userId, user.credentials.password, Constants.Users.MOBILITY_MOBILITY, "", "");
83 @Test(groups = {"shouldBeMigratedToWorkWithSimulator"})
84 public void testPNFOnCreatePopup() {
85 Service service = servicesService.getService("f39389e4-2a9c-4085-8ac3-04aea9c651be");
86 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
87 SideMenu.navigateToBrowseASDCPage();
88 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
89 assertThatServiceCreationDialogIsVisible();
90 validatePNFCreationDialog(service, "Mobility", "pnf");
93 private void validatePNFCreationDialog(Service service, String serviceType, String serviceRole) {
94 assertServiceMetadata(serviceType, Constants.SERVICE_TYPE);
95 assertServiceMetadata(serviceRole, Constants.SERVICE_ROLE);
96 validateServiceCreationDialog(service);
100 // public void clearSimulator() {
101 // SimulatorApi.clearAll();
104 @Test(groups = {"shouldBeMigratedToWorkWithSimulator"})
105 private void testPNFMacroInstantation() throws Exception {
106 User user = usersService.getUser(Constants.Users.MOBILITY_MOBILITY);
107 relogin(user.credentials);
109 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
110 SideMenu.navigateToBrowseASDCPage();
111 browseASDCPage.clickDeployServiceButtonByServiceUUID("f39389e4-2a9c-4085-8ac3-04aea9c651be");
112 assertThatServiceCreationDialogIsVisible();
113 assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS);
114 browseASDCPage.selectSubscriberById("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
115 browseASDCPage.selectProductFamily("ebc3bc3d-62fd-4a3f-a037-f619df4ff034");
116 GeneralUIUtils.ultimateWait();
118 browseASDCPage.selectServiceTypeByName("Mobility");
119 GeneralUIUtils.ultimateWait();
120 browseASDCPage.selectLcpRegion("mtn16");
122 browseASDCPage.selectTenant("a259ae7b7c3f493cb3d91f95a7c18149");
123 assertAllIsPermitted(Constants.BrowseASDC.AIC_OPTION_CLASS);
124 browseASDCPage.selectAicZone("NFT1");
126 Click.onFirstSelectOptionById(Constants.OwningEntity.PROJECT_SELECT_TEST_ID);
127 Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID);
129 browseASDCPage.clickConfirmButton();
131 assertSuccessfulServiceInstanceCreation();
133 browseASDCPage.clickCloseButton();
135 ViewEditPage viewEditPage = new ViewEditPage();
136 viewEditPage.clickActivateButton();
140 // private void browseServiceModel_deployServiceUnexpectedDeploymentMode_creationPopupIsMacro() throws Exception {
141 // deployServiceAndAssertInstantiationType(
143 // "a8dcd72d-d44d-44f2-aa85-53aa9ca99cba",
149 private void browseServiceModel_deployServiceALaCarteByBackendInput_creationPopupIsALaCarte() throws Exception {
150 // model uuid should be of macro
151 deployServiceAndAssertInstantiationType(
152 "csar15782222_instantiationTypeAlacarte_invariantUUIDMacro.zip",
154 instantiationTypeNameAlacarte
159 private void browseServiceModel_deployServiceALaCarteBecauseNotOnMACRO_SERVICESConfig_creationPopupIsALaCarte() throws Exception {
160 deployServiceAndAssertInstantiationType(
161 "csar15782222_instantiationTypeEmpty_invariantUUIDAlacarte.zip",
162 invariantUUIDAlacarte,
163 instantiationTypeNameAlacarte
168 private void browseServiceModel_deployServiceMacroByBackendInput_creationPopupIsMacro() throws Exception {
169 deployServiceAndAssertInstantiationType(
170 "csar15782222_instantiationTypeMacro_invariantUUIDAlacarte.zip",
171 invariantUUIDAlacarte,
172 instantiationTypeNameMacro
177 private void browseServiceModel_deployServiceMacroByMACRO_SERVICESConfig_creationPopupIsOldMacro() throws Exception {
178 deployServiceAndAssertInstantiationType(
179 "csar15782222_invariantUUIDMacro.zip",
187 private void browseServiceModel_deployServiceMacroWithPnf_creationPopupIsOldMacro() throws Exception {
188 deployServiceAndAssertInstantiationType(
189 "csar15782222_instantiationTypeMacroWithPnf.zip",
197 private void browseServiceModel_deployServiceMacroWithCR_creationPopupIsOldMacro() throws Exception {
198 deployServiceAndAssertInstantiationType(
199 "csar15782222_instantiationTypeMacroWithCR.zip",
207 private void browseServiceModel_deployServiceMacroWithNetwork_creationPopupIsMacroByFF() throws Exception {
208 String macroInstantiationAccordingFF = Features.FLAG_ASYNC_INSTANTIATION.isActive() && Features.FLAG_NETWORK_TO_ASYNC_INSTANTIATION.isActive() ? instantiationTypeNameMacro : oldMacro;
209 deployServiceAndAssertInstantiationType(
210 "csar15782222_instantiationTypeMacroWithNetwork.zip",
212 macroInstantiationAccordingFF
217 private void deployServiceAndAssertInstantiationType(String modelZipFileName, String modelInvariantId, String expectedInstantiationType) throws Exception {
218 String modelVersionId = "4d71990b-d8ad-4510-ac61-496288d9078e";
220 registerExpectationForLegacyServiceDeployment(modelVersionId, modelInvariantId, modelZipFileName, null);
221 User user = usersService.getUser(Constants.Users.MOBILITY_MOBILITY);
222 relogin(user.credentials);
224 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
225 SideMenu.navigateToBrowseASDCPage();
227 GeneralUIUtils.ultimateWait();
228 browseASDCPage.clickDeployServiceButtonByServiceUUID(modelVersionId);
229 DeployMacroDialogBase macroDialog = null;
230 if (expectedInstantiationType.equals(instantiationTypeNameAlacarte)) {
231 GeneralUIUtils.ultimateWait();
232 browseASDCPage.clickCancelButtonByTestID();
234 macroDialog = expectedInstantiationType.equals(oldMacro) ? new DeployMacroDialogOld() : getMacroDialog();
235 macroDialog.assertTitle();
236 macroDialog.closeDialog();
241 private void testServiceInstantiationAlaCarte() throws Exception {
242 User user = usersService.getUser(Constants.Users.MOBILITY_MOBILITY);
243 relogin(user.credentials);
245 String zipFileName = "serviceCreationTest.zip";
246 String modelVersionId = "aa2f8e9c-9e47-4b15-a95c-4a9385599abc"; //uuid of model. must be same as in serviceCreationTest.zip
247 String modelInvariantId = invariantUUIDAlacarte; //must be same as in serviceCreationTest.zip
249 registerExpectationForLegacyServiceDeployment(modelVersionId, modelInvariantId, zipFileName, null);
251 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
252 SideMenu.navigateToBrowseASDCPage();
254 Service service = new Service(
261 "ADIOD vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM",
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 = "Mobility";
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 SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.APPEND,
301 "ecompportal_getSessionSlotCheckInterval.json",
302 "browseASDC/aai_get_services.json",
303 "browseASDC/get_aai_get_subscribers.json",
304 "browseASDC/get_sdc_catalog_services_2f80c596.json",
305 "browseASDC/service_design_and_creation.json");
306 SideMenu.navigateToBrowseASDCPage();
307 BrowseASDCPage browseAsdcPage = new BrowseASDCPage();
308 GeneralUIUtils.ultimateWait();
309 assertThat(browseAsdcPage.countCurrentRowsInTable(),(Matchers.greaterThan(1)));
310 browseAsdcPage.fillFilterText(filterText);
311 Assert.assertEquals(browseAsdcPage.countCurrentRowsInTable(),1);
312 Assert.assertTrue(Exists.byTestId("deploy-" + serviceUuid));
313 browseAsdcPage.fillFilterText("");
318 private void testCategoryParamsDropdownsExistsInCreationDialog() throws Exception {
319 SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.APPEND,
320 "ecompportal_getSessionSlotCheckInterval.json",
321 "browseASDC/aai_get_services.json",
322 "browseASDC/get_aai_get_subscribers.json",
323 "browseASDC/get_sdc_catalog_services_2f80c596.json",
324 "browseASDC/service_design_and_creation.json");
325 User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP);
326 relogin(user.credentials);
327 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
328 SideMenu.navigateToBrowseASDCPage();
329 Service service = servicesService.getService("2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd");
330 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
331 DeployMacroDialogBase deployMacroDialog = getMacroDialog();
332 deployMacroDialog.assertDialogExists();
333 deployMacroDialog.clickProjectSelect();
334 deployMacroDialog.clickOwningEntitySelect();
337 @Test(groups = {"shouldBeMigratedToWorkWithSimulator"})
338 private void testOwningEntityRequiredAndProjectOptional() throws Exception {
339 User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP);
340 relogin(user.credentials);
342 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
343 SideMenu.navigateToBrowseASDCPage();
345 Service service = servicesService.getService("c079d859-4d81-4add-a9c3-94551f96e2b0");
347 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
348 validateServiceCreationDialog(service);
350 browseASDCPage.setInstanceName(browseASDCPage.generateInstanceName());
352 assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS);
353 browseASDCPage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89");
355 String serviceType = "VIRTUAL USP";
356 GeneralUIUtils.findAndWaitByText(serviceType, 30);
358 assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS);
359 browseASDCPage.selectServiceTypeByName(serviceType);
361 browseASDCPage.clickConfirmButton();
363 GeneralUIUtils.findAndWaitByText("Missing data", 5);
365 Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID);
367 browseASDCPage.clickConfirmButton();
368 assertSuccessfulServiceInstanceCreation();
371 @Test(groups = {"shouldBeMigratedToWorkWithSimulator"})
372 protected void testLineOfBusinessOptionalAndPlatformRequired() throws Exception {
374 User user = usersService.getUser(Constants.Users.USP_VOICE_VIRTUAL_USP);
375 relogin(user.credentials);
377 BrowseASDCPage browseASDCPage = new BrowseASDCPage();
378 SideMenu.navigateToBrowseASDCPage();
380 Service service = servicesService.getService("c079d859-4d81-4add-a9c3-94551f96e2b0");
382 browseASDCPage.clickDeployServiceButtonByServiceUUID(service.uuid);
383 validateServiceCreationDialog(service);
385 browseASDCPage.setInstanceName(browseASDCPage.generateInstanceName());
387 assertDropdownPermittedItemsByLabel(user.subscriberNames, Constants.CreateNewInstance.SUBSCRIBER_NAME_OPTION_CLASS);
388 browseASDCPage.selectSubscriberById("e433710f-9217-458d-a79d-1c7aff376d89");
390 String serviceType = "VIRTUAL USP";
391 GeneralUIUtils.findAndWaitByText(serviceType, 30);
393 assertDropdownPermittedItemsByValue(user.serviceTypes, Constants.CreateNewInstance.SERVICE_TYPE_OPTION_CLASS);
394 browseASDCPage.selectServiceTypeByName(serviceType);
396 Click.onFirstSelectOptionById(Constants.OwningEntity.OWNING_ENTITY_SELECT_TEST_ID);
398 browseASDCPage.clickConfirmButton();
399 assertSuccessfulServiceInstanceCreation();
401 browseASDCPage.clickCloseButton();
402 GeneralUIUtils.ultimateWait();
405 ViewEditPage viewEditPage = new ViewEditPage();
407 viewEditPage.selectNodeInstanceToAdd("VID-PCRF-05-15-17 0");
408 viewEditPage.generateAndSetInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX);
409 viewEditPage.selectProductFamily("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
410 viewEditPage.selectLCPRegion("AAIAIC25");
411 viewEditPage.selectTenant("092eb9e8e4b7412e8787dd091bc58e86");
412 viewEditPage.setLegacyRegion("llkjhlkjhlkjh");
414 browseASDCPage.clickConfirmButton();
416 GeneralUIUtils.findAndWaitByText("Missing data", 5);
418 Click.onFirstSelectOptionById(Constants.OwningEntity.PLATFORM_SELECT_TEST_ID);
420 viewEditPage.clickConfirmButton();
421 assertSuccessfulVNFCreation();
424 private void prepareSimulatorWithServiceModelListBeforeBrowseASDCService(){
425 SimulatorApi.clearAll();
427 ImmutableList<BasePreset> presets = ImmutableList.of(
428 new PresetGetSessionSlotCheckIntervalGet(),
429 new PresetAAIGetSubscribersGet(),
430 new PresetAAIGetServiceModelList(modelUuid, modelInvariantUUID1, modelInvariantUUID2, modelInvariantUUID3),
431 new PresetAAIGetServicesGet());
433 SimulatorApi.registerExpectationFromPresets(presets, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
437 private void browseSDCServiceModelListCheckAAIResponse(){
438 prepareSimulatorWithServiceModelListBeforeBrowseASDCService();
439 SideMenu.navigateToBrowseASDCPage();
440 GeneralUIUtils.ultimateWait();
442 WebElement sdcTableElement = Get.byId("sdcModelsTable");
443 List<WebElement> sdcModelList = sdcTableElement.findElements(By.className("sdcServiceModel"));
445 WebElement sdcFirstModel = sdcModelList.get(0);
446 WebElement sdcSecondModel = sdcModelList.get(1);
447 WebElement sdcThirdModel = sdcModelList.get(2);
450 By uuid = By.className("uuid");
451 assertEquals(modelUuid, sdcFirstModel.findElement(uuid).getText());
452 assertEquals("1dae721c-a1ef-435f-b811-760c23f467bf" , sdcSecondModel.findElement(uuid).getText());
453 assertEquals("29236d45-e790-4c17-a115-1533cc09b7b1" , sdcThirdModel.findElement(uuid).getText());
455 //Check invariantUUID
456 By invariantUUID = By.className("invariantUUID");
457 assertEquals(modelInvariantUUID1, sdcFirstModel.findElement(invariantUUID).getText());
458 assertEquals(modelInvariantUUID2, sdcSecondModel.findElement(invariantUUID).getText());
459 assertEquals(modelInvariantUUID3, sdcThirdModel.findElement(invariantUUID).getText());
462 By name = By.className("name");
463 assertEquals("AAAvIRC_mm779p_Service" , sdcFirstModel.findElement(name).getText());
464 assertEquals("BBBvIRC_mm779p_Service" , sdcSecondModel.findElement(name).getText());
465 assertEquals("CCCvIRC_mm779p_Service" , sdcThirdModel.findElement(name).getText());
467 //Check distribution Status
468 By distributionStatus = By.className("distributionStatus");
469 assertEquals("DISTRIBUTION_COMPLETE_OK" , sdcFirstModel.findElement(distributionStatus).getText());
470 assertEquals("", sdcSecondModel.findElement(distributionStatus).getText());
471 assertEquals("DISTRIBUTION_COMPLETE_ERROR" , sdcThirdModel.findElement(distributionStatus).getText());
473 //Check another fields
474 assertEquals("service" , sdcFirstModel.findElement(By.className("category")).getText());
475 assertEquals("1.0" , sdcFirstModel.findElement(By.className("version")).getText());
478 public void browseSdcModel_getEmptyList_noModelsMessageIsShown() throws Exception {
479 SimulatorApi.clearAll();
480 SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
481 new PresetAAIServiceDesignAndCreationPut(true),
482 new PresetAAIGetSubscribersGet()), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET);
483 SideMenu.navigateToBrowseASDCPage();
484 GeneralUIUtils.ultimateWait();
485 WebElement serviceModelsTbody = Get.byXpath("//table[@data-tests-id='serviceModelsTable']/tbody");
486 assertFalse(Exists.tagNameInAnotherElement(serviceModelsTbody, "tr"), "Table should be empty on empty results");