1 package vid.automation.test.test;
3 import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.PRESET_SOME_LEGACY_REGION_TO_ATT_AIC;
4 import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet.COMPLETE;
5 import static org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys.SERVICE_NAME;
6 import static org.onap.vid.api.TestUtils.generateRandomAlphaNumeric;
7 import static vid.automation.test.Constants.BrowseASDC.NewServicePopup.SET_BUTTON;
8 import static vid.automation.test.Constants.DrawingBoard.CONTEXT_MENU_BUTTON_HEADER;
9 import static vid.automation.test.Constants.DrawingBoard.CONTEXT_MENU_HEADER_EDIT_ITEM;
10 import static vid.automation.test.Constants.DrawingBoard.DEPLOY_BUTTON;
11 import static vid.automation.test.infra.Features.FLAG_2004_INSTANTIATION_TEMPLATES_POPUP;
12 import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;
13 import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET;
14 import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets;
16 import com.google.common.collect.ImmutableList;
17 import com.google.common.collect.ImmutableMap;
18 import java.util.List;
19 import org.onap.sdc.ci.tests.datatypes.UserCredentials;
20 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
21 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstanceAlacarte;
22 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet;
23 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOServiceInstanceGen2WithNames.Keys;
24 import org.onap.vid.api.AsyncInstantiationBase;
25 import org.testng.annotations.AfterClass;
26 import org.testng.annotations.BeforeClass;
27 import org.testng.annotations.Test;
28 import vid.automation.test.infra.Click;
29 import vid.automation.test.infra.FeatureTogglingTest;
30 import vid.automation.test.infra.Get;
31 import vid.automation.test.infra.Input;
32 import vid.automation.test.infra.ModelInfo;
33 import vid.automation.test.sections.DrawingBoardPage;
34 import vid.automation.test.sections.SideMenu;
35 import vid.automation.test.sections.VidBasePage;
36 import vid.automation.test.services.AsyncJobsService;
38 public class TemplateInstantiationTest extends ModernUITestBase {
40 private AsyncInstantiationBase asyncInstantiationBase;
43 protected void setUp() {
44 AsyncJobsService asyncJobsService = new AsyncJobsService();
45 asyncJobsService.dropAllAsyncJobs();
46 asyncInstantiationBase = new AsyncInstantiationBase();
47 asyncInstantiationBase.init();
48 UserCredentials userCredentials = getUserCredentials();
49 //login for API test (needed besides selenium test via browser)
50 asyncInstantiationBase.login(userCredentials);
54 protected void tearDown() {
55 AsyncJobsService asyncJobsService = new AsyncJobsService();
56 asyncJobsService.muteAllAsyncJobs();
60 In this test we create an simple aLaCarte service via api,
61 Then browse SDC -> search for same model uuid -> deploy ->
62 template popup is opened -> select the service -> click load template ->
63 drawing board is opened -> edit service instance name -> deploy ->
64 instantiation status is opened -> wait for service to completed.
66 @FeatureTogglingTest(FLAG_2004_INSTANTIATION_TEMPLATES_POPUP)
68 public void instantiateALaCarteServiceFromTemplateTest() {
70 final ModelInfo modelInfo = ModelInfo.aLaCarteServiceCreationNewUI;
71 String templateInstanceName = "template"+generateRandomAlphaNumeric(10);
72 String requestorID = getUserCredentials().getUserId();
73 String serviceRequestId = uuid();
74 String serviceInstanceId = uuid();
76 //prepare presets for first instantiation (template), and rest of scenario till deploy
77 prepareServicePreset(modelInfo, true);
78 registerExpectationFromPresets(
80 new PresetMSOCreateServiceInstanceAlacarte(
81 ImmutableMap.of(Keys.SERVICE_NAME, templateInstanceName),
82 serviceRequestId, serviceInstanceId,
83 requestorID, modelInfo),
84 PRESET_SOME_LEGACY_REGION_TO_ATT_AIC,
85 new PresetMSOOrchestrationRequestGet(COMPLETE, serviceRequestId)
90 //create service instance via API
91 final List<String> jobsIds = asyncInstantiationBase.createBulkOfInstances(false, 1,
92 ImmutableMap.of(SERVICE_NAME, templateInstanceName), "asyncInstantiation/vidRequestCreateALaCarteForTemplate.json");
93 asyncInstantiationBase.waitForJobsToSuccessfullyCompleted(1, jobsIds);
95 String newInstanceName = "template"+generateRandomAlphaNumeric(10);
96 String serviceRequestId2 = uuid();
97 String serviceInstanceId2 = uuid();
99 //load template and and edit service instance name
100 browseSdcAndClickDeploy(modelInfo);
101 selectTemplateByNameAndLoadTemplate(templateInstanceName);
102 VidBasePage.goToIframe();
103 editServiceInstanceName(newInstanceName);
105 //prepare presets for second service instance deploy
106 registerExpectationFromPresets(
108 new PresetMSOCreateServiceInstanceAlacarte(
109 ImmutableMap.of(Keys.SERVICE_NAME, newInstanceName),
110 serviceRequestId2, serviceInstanceId2,
111 requestorID, modelInfo),
112 PRESET_SOME_LEGACY_REGION_TO_ATT_AIC,
113 new PresetMSOOrchestrationRequestGet(COMPLETE, serviceRequestId2)
118 //deploy the service and wait for completion
119 Click.byTestId(DEPLOY_BUTTON);
120 VidBasePage.goToIframe();
121 new DrawingBoardPage().verifyServiceCompletedOnTime(newInstanceName, "service deployed from template");
124 private void browseSdcAndClickDeploy(ModelInfo modelInfo) {
125 SideMenu.navigateToBrowseASDCPage();
126 GeneralUIUtils.ultimateWait();
127 loadTemplatesPopupOnBrowseASDCPage(modelInfo.modelVersionId);
130 private void selectTemplateByNameAndLoadTemplate(String templateInstanceName) {
131 Click.byText(templateInstanceName);
132 Click.byTestId("LoadTemplateButton");
135 private void editServiceInstanceName(String newInstanceName) {
136 GeneralUIUtils.getClickableButtonBy(Get.getXpathForDataTestId(CONTEXT_MENU_BUTTON_HEADER), 60).click();
137 Click.byTestId(CONTEXT_MENU_HEADER_EDIT_ITEM);
138 GeneralUIUtils.ultimateWait();
139 Input.replaceText(newInstanceName, "instanceName");
140 Click.byTestId(SET_BUTTON);