org.onap migration
[vid.git] / vid-automation / src / main / java / vid / automation / test / test / ChangeManagementTest.java
1 package vid.automation.test.test;
2
3
4 //import com.sun.tools.internal.jxc.ap.Const;
5
6 import com.google.common.primitives.Ints;
7 import org.json.JSONException;
8 import org.junit.Assert;
9 import org.openecomp.sdc.ci.tests.datatypes.UserCredentials;
10 import org.openqa.selenium.support.ui.Select;
11 import org.skyscreamer.jsonassert.JSONAssert;
12 import org.skyscreamer.jsonassert.JSONCompareMode;
13 import org.testng.annotations.*;
14 import vid.automation.test.Constants;
15 import vid.automation.test.infra.*;
16 import vid.automation.test.sections.ChangeManagementPage;
17 import vid.automation.test.services.SimulatorApi;
18
19 import java.sql.Connection;
20 import java.sql.DriverManager;
21 import java.sql.SQLException;
22 import java.sql.Statement;
23 import java.util.Arrays;
24 import java.util.List;
25 import java.util.stream.Collectors;
26 import java.util.stream.Stream;
27
28 import static org.hamcrest.CoreMatchers.*;
29 import static org.hamcrest.MatcherAssert.assertThat;
30 import static org.hamcrest.Matchers.greaterThan;
31 import static org.hamcrest.collection.IsEmptyCollection.empty;
32 import static org.hamcrest.core.IsNot.not;
33
34 public class ChangeManagementTest extends VidBaseTestCase {
35
36     @Test
37     public void testLeftPanelChangeManagementButton() {
38         Assert.assertTrue(Wait.byText(Constants.SideMenu.VNF_CHANGES));
39     }
40
41     @Test
42     public void testChangeManagementHeaderLine() {
43         ChangeManagementPage.openChangeManagementPage();
44         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pageHeadlineId));
45         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.headlineNewButtonId));
46         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.headlineSearchInputId));
47     }
48
49     @Test
50     public void testOpenNewChangeManagementModal() {
51         ChangeManagementPage.openNewChangeManagementModal();
52         Assert.assertTrue(Exists.modal());
53         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalSubscriberInputId));
54         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalServiceTypeInputId));
55         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFNameInputId));
56         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalVNFTypeInputId));
57         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalFromVNFVersionInputId));
58         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.newModalWorkFlowInputId));
59         Assert.assertTrue(Exists.byId(Constants.generalSubmitButtonId));
60         Assert.assertTrue(Exists.byId(Constants.generalCancelButtonId));
61         Click.byId(Constants.generalCancelButtonId);
62         Wait.modalToDisappear();
63     }
64
65     private void openAndFill1stScreen(String vnfName, String vnfTargetVersion, String workflow) {
66         String subscriberId = VNF_DATA_WITH_IN_PLACE.subscriberId;
67         String serviceType = VNF_DATA_WITH_IN_PLACE.serviceType;
68         String vnfType = VNF_DATA_WITH_IN_PLACE.vnfType;
69         String vnfSourceVersion = VNF_DATA_WITH_IN_PLACE.vnfSourceVersion;
70
71         ChangeManagementPage.openNewChangeManagementModal();
72         Wait.angularHttpRequestsLoaded();
73         ChangeManagementPage.selectSubscriberById(subscriberId);
74         Wait.angularHttpRequestsLoaded();
75         SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalServiceTypeInputId, serviceType);
76         Wait.angularHttpRequestsLoaded();
77         SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalVNFTypeInputId, vnfType);
78         Wait.angularHttpRequestsLoaded();
79         SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalFromVNFVersionInputId, vnfSourceVersion);
80         Wait.angularHttpRequestsLoaded();
81         Click.byId(Constants.ChangeManagement.newModalVNFNameInputId);
82         Click.byText(vnfName);
83         Wait.angularHttpRequestsLoaded();
84         if (vnfTargetVersion != null) {
85             SelectOption.byClassAndVisibleText(Constants.ChangeManagement.newModalTargetVersionInputsClass, vnfTargetVersion);
86             Wait.angularHttpRequestsLoaded();
87         }
88         SelectOption.byIdAndVisibleText(Constants.ChangeManagement.newModalWorkFlowInputId, workflow);
89
90     }
91
92     public void scheduleChange2ndScreen(String duration, String fallback, String concurrencyLimit, String policy) {
93
94         Wait.byText(Constants.ChangeManagement.schedulerModalNowLabel);
95         Click.byText(Constants.ChangeManagement.schedulerModalNowLabel);
96
97 //        Click.byId(Constants.ChangeManagement.schedulerModalStartDateInputId); //next month must be in the future
98 //        Click.byClass(Constants.ChangeManagement.schedulerModalNextMonthButtonClass);
99 //        Wait.byText(startDate);
100 //        Click.byText(startDate);
101 //
102 //        Click.byId(Constants.ChangeManagement.schedulerModalEndDateInputId); //next month must be in the future
103 //        Click.byClass(Constants.ChangeManagement.schedulerModalNextMonthButtonClass);
104 //        Wait.byText(endDate);
105 //        Click.byText(endDate);
106
107         SelectOption.byValue(Constants.ChangeManagement.schedulerModalHoursOption, Constants.ChangeManagement.schedulerModalTimeUnitSelectId);
108
109         Input.text(duration, Constants.ChangeManagement.schedulerModalDurationInputTestId);
110         Input.text(fallback, Constants.ChangeManagement.schedulerModalFallbackInputTestId);
111         Input.text(concurrencyLimit, Constants.ChangeManagement.schedulerModalConcurrencyLimitInputTestId);
112         Wait.angularHttpRequestsLoaded();
113         SelectOption.byIdAndVisibleText(Constants.ChangeManagement.schedulerModalPolicySelectId, policy);
114
115         Click.byText(Constants.ChangeManagement.schedulerModalScheduleButtonText);
116
117     }
118
119     static class DB_CONFIG {
120         static String url = String.format("jdbc:mariadb://%s:%d/vid_portal",
121                 System.getProperty("DB_HOST", System.getProperty("VID_HOST", "127.0.0.1" )),
122                 Integer.valueOf(System.getProperty("DB_PORT", "3306"))
123         );
124         static String username = "euser";
125         static String password = "euser";
126
127         static final int userId = 822;
128         static final int roleVFlowLogicId = 10822;
129         static final int roleMobilityId = 11822;
130         static final int vnfZrdm3amdns02test2Id = 11822;
131         static final int vnfHarrisonKrisId = 12822;
132     }
133
134     static class VNF_DATA_WITH_IN_PLACE {
135         static String subscriberId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
136         static String serviceType = "vFlowLogic";
137         static String vnfType = "vMobileDNS";
138         static String vnfSourceVersion = "1.0";
139         static String vnfName = "zrdm3amdns02test2";
140         static String vnfTargetVersion = "5.0";
141         static String workflowName = "VNF In Place Software Update";
142     }
143
144     @AfterClass
145     protected void dropUser822() {
146         System.out.println("Connecting database...");
147
148         try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) {
149             System.out.println("Database connected!");
150             Statement stmt = connection.createStatement();
151             stmt.addBatch("DELETE FROM `fn_user_role` WHERE `USER_ID` = " + DB_CONFIG.userId);
152             stmt.addBatch("DELETE FROM `fn_role` WHERE `ROLE_ID` = " + DB_CONFIG.roleVFlowLogicId);
153             stmt.addBatch("DELETE FROM `fn_role` WHERE `ROLE_ID` = " + DB_CONFIG.roleMobilityId);
154             stmt.addBatch("DELETE FROM `fn_user` WHERE `USER_ID` = " + DB_CONFIG.userId);
155             int[] executeBatch = stmt.executeBatch();
156
157             stmt = connection.createStatement();
158             stmt.addBatch("DELETE FROM `vid_vnf_workflow` WHERE `VNF_DB_ID` = " + DB_CONFIG.vnfZrdm3amdns02test2Id);
159             stmt.addBatch("DELETE FROM `vid_vnf` WHERE `VNF_DB_ID` = " + DB_CONFIG.vnfZrdm3amdns02test2Id);
160             executeBatch = stmt.executeBatch();
161
162             stmt = connection.createStatement();
163             stmt.addBatch("DELETE FROM `vid_vnf_workflow` WHERE `VNF_DB_ID` = " + DB_CONFIG.vnfHarrisonKrisId);
164             stmt.addBatch("DELETE FROM `vid_vnf` WHERE `VNF_DB_ID` = " + DB_CONFIG.vnfHarrisonKrisId);
165             executeBatch = stmt.executeBatch();
166
167         } catch (SQLException e) {
168             throw new IllegalStateException("Cannot connect the database!", e);
169         }
170     }
171
172     @BeforeClass
173     protected void registerToSimulator() {
174         SimulatorApi.registerExpectation(
175                 "changeManagement/ecompportal_getSessionSlotCheckInterval.json"
176                 , "changeManagement/get_aai_get_subscribers.json"
177                 , "changeManagement/get_aai_sub_details.json"
178                 , "changeManagement/get_scheduler_details_short.json"
179                 , "changeManagement/get_sdc_catalog_services_2f80c596.json"
180                 , "changeManagement/get_service-design-and-creation.json"
181                 , "changeManagement/get_vnf_data_by_globalid_and_service_type.json"
182                 , "changeManagement/service-design-and-creation.json"
183         );
184     }
185
186     @BeforeClass
187     protected void prepareUser822() {
188
189         dropUser822();
190
191         System.out.println("Connecting database...");
192
193         try (Connection connection = DriverManager.getConnection(DB_CONFIG.url, DB_CONFIG.username, DB_CONFIG.password)) {
194
195             System.out.println("Database connected!");
196
197             ///////////////////////////////
198             // Add user with specific roles
199             Statement stmt = connection.createStatement();
200             stmt.addBatch("INSERT INTO `fn_user` (`USER_ID`, `ORG_USER_ID`, `LOGIN_ID`, `LOGIN_PWD`) VALUES (" + DB_CONFIG.userId + ", 'Porfirio Gerhardt', '"+ DB_CONFIG.userId +"', '"+ DB_CONFIG.userId +"')");
201             stmt.addBatch("INSERT INTO `fn_role` (`ROLE_ID`, `ROLE_NAME`, `ACTIVE_YN`, `PRIORITY`) VALUES (" + DB_CONFIG.roleVFlowLogicId + ", 'PACKET CORE___vFlowLogic', 'Y', 5)");
202             stmt.addBatch("INSERT INTO `fn_role` (`ROLE_ID`, `ROLE_NAME`, `ACTIVE_YN`, `PRIORITY`) VALUES (" + DB_CONFIG.roleMobilityId + ", 'PACKET CORE___Mobility', 'Y', 5)");
203             stmt.addBatch("INSERT INTO `fn_user_role` (`USER_ID`, `ROLE_ID`, `PRIORITY`, `APP_ID`) VALUES (" + DB_CONFIG.userId + ", 16, NULL, 1)");
204             stmt.addBatch("INSERT INTO `fn_user_role` (`USER_ID`, `ROLE_ID`, `PRIORITY`, `APP_ID`) VALUES (" + DB_CONFIG.userId + ", " + DB_CONFIG.roleVFlowLogicId + ", NULL, 1)");
205             stmt.addBatch("INSERT INTO `fn_user_role` (`USER_ID`, `ROLE_ID`, `PRIORITY`, `APP_ID`) VALUES (" + DB_CONFIG.userId + ", " + DB_CONFIG.roleMobilityId + ", NULL, 1)");
206             int[] executeBatch = stmt.executeBatch();
207             assertThat(Ints.asList(executeBatch), everyItem(greaterThan(0)));
208
209             ///////////////////////////////
210             // Add 2 vnfs with some workflows
211             stmt = connection.createStatement();
212             stmt.addBatch("INSERT INTO `vid_vnf` (`VNF_DB_ID`, `VNF_APP_UUID`, `VNF_APP_INVARIANT_UUID`) " +
213                     "VALUES (" + DB_CONFIG.vnfZrdm3amdns02test2Id + ", '76e908e0-5201-44d2-a3e2-9e6128d05820', '72e465fe-71b1-4e7b-b5ed-9496118ff7a8')");
214             stmt.addBatch("INSERT INTO `vid_vnf_workflow` (`VNF_DB_ID`, `WORKFLOW_DB_ID`) VALUES (" + DB_CONFIG.vnfZrdm3amdns02test2Id + ", 2)");
215             stmt.addBatch("INSERT INTO `vid_vnf_workflow` (`VNF_DB_ID`, `WORKFLOW_DB_ID`) VALUES (" + DB_CONFIG.vnfZrdm3amdns02test2Id + ", 3)");
216             executeBatch = stmt.executeBatch();
217             assertThat(Ints.asList(executeBatch), everyItem(greaterThan(0)));
218
219             stmt = connection.createStatement();
220             stmt.addBatch("INSERT INTO `vid_vnf` (`VNF_DB_ID`, `VNF_APP_UUID`, `VNF_APP_INVARIANT_UUID`) " +
221                     "VALUES (" + DB_CONFIG.vnfHarrisonKrisId + ", '0903e1c0-8e03-4936-b5c2-260653b96413', '00beb8f9-6d39-452f-816d-c709b9cbb87d')");
222             stmt.addBatch("INSERT INTO `vid_vnf_workflow` (`VNF_DB_ID`, `WORKFLOW_DB_ID`) VALUES (" + DB_CONFIG.vnfHarrisonKrisId + ", 1)");
223             stmt.addBatch("INSERT INTO `vid_vnf_workflow` (`VNF_DB_ID`, `WORKFLOW_DB_ID`) VALUES (" + DB_CONFIG.vnfHarrisonKrisId + ", 2)");
224             executeBatch = stmt.executeBatch();
225             assertThat(Ints.asList(executeBatch), everyItem(greaterThan(0)));
226
227         } catch (SQLException e) {
228             throw new IllegalStateException("Cannot connect the database!", e);
229         }
230
231     }
232
233     @Override
234     protected UserCredentials getUserCredentials() {
235             return new UserCredentials("" + DB_CONFIG.userId, "" + DB_CONFIG.userId, "", "", "");
236     }
237
238
239     @Test
240     public void testWorkflowVNFInPlaceSoftwareUpdateNotInWorkflowsListWhenNotExpected() {
241         List<String> workflows = getListOfWorkflowsFor("Harrison Kris");
242         assertThat(workflows, not(hasItem(VNF_DATA_WITH_IN_PLACE.workflowName)));
243     }
244
245     @Test
246     public void testWorkflowVNFInPlaceSoftwareUpdateInWorkflowsListWhenExpected()  {
247         List<String> workflows = getListOfWorkflowsFor(VNF_DATA_WITH_IN_PLACE.vnfName);
248         assertThat(workflows, hasItem(VNF_DATA_WITH_IN_PLACE.workflowName));
249     }
250
251     public void openAndFill1stScreenWithWorkflowVNFInPlaceSoftwareUpdate() {
252         openAndFill1stScreen(VNF_DATA_WITH_IN_PLACE.vnfName, VNF_DATA_WITH_IN_PLACE.vnfTargetVersion, VNF_DATA_WITH_IN_PLACE.workflowName);
253     }
254
255     @AfterMethod(alwaysRun = true)
256     public void closeForm() {
257         // Tries closing left-out popups, if any
258         // If none -- catch clause will swallow the exception
259         try {
260             Click.byId(Constants.generalCancelButtonId);
261             Click.byId(Constants.generalCancelButtonId);
262             Click.byId(Constants.generalCancelButtonId);
263         } catch (Exception | Error e) {
264             // ok, stop
265         }
266         Wait.modalToDisappear();
267     }
268
269     @Test
270     public void testWorkflowVNFInPlaceSoftwareUpdateShows3Fields() {
271         openAndFill1stScreenWithWorkflowVNFInPlaceSoftwareUpdate();
272
273         List<String> idsWithoutMatchingElement =
274                 Stream.of(
275                         "operations-timeout",
276                         "existing-software-version",
277                         "new-software-version")
278                         .filter(id -> Get.byId(id) == null)
279                         .collect(Collectors.toList());
280         assertThat("all three special VNFInPlace fields should appear", idsWithoutMatchingElement, is(empty()));
281
282         assertThat(Get.byId(Constants.generalSubmitButtonId).isEnabled(), is(false));
283     }
284
285     @Test
286     public void testWorkflowVNFInPlaceSoftwareUpdate3ValidValues() {
287         openAndFill1stScreenWithWorkflowVNFInPlaceSoftwareUpdate();
288
289         final String[][] options = {
290                 {"true", "111", "222", "333"}
291                 , {"true", "14710454", "Cz-Ou0EK5eH9.gAK1", "G9bUiFX3QM8xpxF8TlZ7b5T0"}
292                 , {"true", "25316893", "fMx9V5kp.5.JGtYRhNGVTPoJ", "Jv5IieY0kTNjkfZ64bHXngR6"}
293                 , {"true", "8", "3t3MhTRqkyjB85o5NC9OacAw", "B.bJ6f7KYI6WzDMR0fyNM9r4"}
294                 , {"true", "3176", "ZlRS7tczf0cbMxQbBfyc6AP5", "1G1"}
295                 , {"true", "78058488", "n", "WkH"}
296                 , {"true", "501778", "1.d74LrJbBmcR.7bfvH.UZMX", "tFTAel7PS4RKEJeJ0b6mTeVT"}
297                 , {"true", "76639623", "m2.EhbBxRE.rJj3j6qDtMxGR", "Rgkm-EPM1K0KAWm43Ex1wwjj"}
298                 , {"true", "91244280", "zPDHRrXW65xR6GV.gVZND8C0", "mkrqFG26m7Vmv-28etQVyp04"}
299                 , {"true", "8966", "7k2sRK2qSFRVCFpEvrlbmxAL", "IlvfmWTqzpF0Jo3elpZPHXx"}
300                 , {"true", "01303495", "G26yl8B0NbLIKxu23h86QbZz", "vSou1seqCrcv9KoVbhlj4Wa4"}
301                 , {"true", "787", "ce7joKCHYowpM2PtCb53Zs2v", ".qw1oY9HKjfAF2Yt05JNgib9"}
302                 , {"true", "40116583", "-3bDEzEn.RbNnT2hWKQqf2HL", "QzlKlKZiIpc7sQ.EzO"}
303                 , {"false", "", "222", "333"}
304                 , {"false", "111", "", "333"}
305                 , {"false", "111", "222", ""}
306                 , {"false", "111a", "222", "333"}
307                 , {"false", "aaa", "222", "333"}
308                 , {"false", "111-", "222", "333"}
309 //                , {"false", " 111", "222", "333"}
310 //                , {"false", "111", "222 ", "333"}
311 //                , {"false", "111", "222", " 333"}
312                 , {"false", "111", "222", "3 33"}
313                 , {"false", "111", "22,2", "333"}
314                 , {"false", "111", "222~", "333"}
315                 , {"false", "111", "222", "333&"}
316                 , {"false", "$", "222", "333"}
317                 , {"false", "111", "@", "333"}
318                 , {"false", "111", "222", "^^^^^^"}
319         };
320
321         for (String[] option : options) {
322             fillVNFInPlace3Fields(option[1], option[2], option[3]);
323             assertThat("failed for set: " + Arrays.toString(option),
324                     Get.byId(Constants.generalSubmitButtonId).isEnabled(), is(Boolean.parseBoolean(option[0])));
325         }
326
327     }
328
329     private void fillVNFInPlace3Fields(String operationsTimeout, String existingSwVersion, String newSwVersion) {
330         Get.byId("operations-timeout").clear();
331         Get.byId("existing-software-version").clear();
332         Get.byId("new-software-version").clear();
333
334         Get.byId("operations-timeout").sendKeys(operationsTimeout);
335         Get.byId("existing-software-version").sendKeys(existingSwVersion);
336         Get.byId("new-software-version").sendKeys(newSwVersion);
337     }
338
339     private List<String> getListOfWorkflowsFor(String vnfName) {
340
341         openAndFill1stScreen(vnfName, null /*no matter*/, "Replace");
342
343         Select selectlist = new Select(Get.byId("workflow"));
344         List<String> workflows = selectlist.getOptions().stream().map(we -> we.getText()).collect(Collectors.toList());
345
346         Click.byId(Constants.generalCancelButtonId);
347
348         return workflows;
349     }
350
351     @DataProvider
352     public static Object[][] dataForUpdateWorkflowPartialWithInPlace() {
353         return new Object[][] {
354                 { "1111", "22222", "33333" }
355                 , {"8", "3t3MhTRqkyjB85o5NC9OacAw", "B.bJ6f7KYI6Wz-----DMR0.fyNM9r4"}
356                 , {"78058488", "n", "WkH"}
357         };
358     }
359
360     @Test(dataProvider = "dataForUpdateWorkflowPartialWithInPlace")
361     public void testVidToMsoCallbackDataWithInPlaceSWUpdate(String operationsTimeout, String existingSwVersion, String newSwVersion) {
362
363         openAndFill1stScreenWithWorkflowVNFInPlaceSoftwareUpdate();
364         fillVNFInPlace3Fields(operationsTimeout, existingSwVersion, newSwVersion);
365
366         String payload = "\"payload\":\"{\\\"existing-software-version\\\":\\\""+ existingSwVersion +"\\\",\\\"new-software-version\\\":\\\""+ newSwVersion +"\\\",\\\"operation-timeout\\\":\\\""+ operationsTimeout +"\\\"}\",";
367
368         assertThatVidToMsoCallbackDataIsOk(VNF_DATA_WITH_IN_PLACE.workflowName, payload);
369     }
370
371     @Test
372     public void testVidToMsoCallbackData() {
373         String workflow = "Replace";
374
375         openAndFill1stScreen(VNF_DATA_WITH_IN_PLACE.vnfName, VNF_DATA_WITH_IN_PLACE.vnfTargetVersion, workflow);
376
377         assertThatVidToMsoCallbackDataIsOk(workflow, "");
378     }
379
380     private void assertThatVidToMsoCallbackDataIsOk(String workflow, String payload) {
381         Assert.assertTrue(Get.byId(Constants.generalSubmitButtonId).isEnabled());
382         Click.byId(Constants.generalSubmitButtonId);
383
384         String vidToMsoCallbackData = Input.getValueByTestId("vidToMsoCallbackData");
385
386         String modelInvariantId = "72e465fe-71b1-4e7b-b5ed-9496118ff7a8";
387         String vnfInstanceId = "8e5e3ba1-3fe6-4d86-966e-f9f03dab4855";
388         String expected = getExpectedVidToMsoCallbackData(modelInvariantId, vnfInstanceId, VNF_DATA_WITH_IN_PLACE.vnfName, VNF_DATA_WITH_IN_PLACE.vnfTargetVersion, workflow, payload);
389
390         try {
391             JSONAssert.assertEquals("built mso request is not ok", expected, vidToMsoCallbackData, JSONCompareMode.STRICT);
392         } catch (JSONException e) {
393             throw new RuntimeException(e);
394         }
395
396         Click.byId(Constants.generalCancelButtonId);
397     }
398
399     @Test(enabled = false)
400     public void testUpdateWorkflowNow() {
401
402         String workflow = "Update";
403
404         String duration = "1";
405         String fallback = "1";
406         String concurrencyLimit = "1";
407         String policy = "SNIRO_1710.Config_MS_PlacementOptimizationPolicy_dhv_v1.1.xml";
408
409         openAndFill1stScreen(VNF_DATA_WITH_IN_PLACE.vnfName, VNF_DATA_WITH_IN_PLACE.vnfTargetVersion, workflow);
410         Assert.assertTrue(Get.byId(Constants.generalSubmitButtonId).isEnabled());
411         Click.byId(Constants.generalSubmitButtonId);
412
413         scheduleChange2ndScreen(duration, fallback, concurrencyLimit, policy);
414     }
415
416     @Test
417     public void testNewChangeManagementCreation() {
418         ChangeManagementPage.openChangeManagementPage();
419
420         //TODO: After scheduler will be ready than we will examine if the creation working fine.
421     }
422
423     @Test
424     public void testMainDashboardTable() {
425         ChangeManagementPage.openChangeManagementPage();
426         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardActiveTabId));
427         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardFinishedTabId));
428
429         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardActiveTableId));
430         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardInProgressTheadId));
431         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardPendingTheadId));
432
433         Click.byId(Constants.ChangeManagement.dashboardFinishedTabId);
434         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardFinishedTableId));
435         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.dashboardFinishedTheadId));
436         Click.byId(Constants.ChangeManagement.dashboardActiveTabId);
437     }
438
439     @Test
440     public void testMainDashboardTableContent() {
441         ChangeManagementPage.openChangeManagementPage();
442
443         //TODO: After scheduler will be ready than we will examine if the content is valid.
444     }
445
446     @Test(enabled = false)
447     public void testOpenFailedStatusModal() {
448         ChangeManagementPage.openChangeManagementPage();
449
450         if(!Exists.byClass(Constants.ChangeManagement.failedIconClass)) {
451             //TODO: Create a job which will shown with status fail.
452         }
453
454         Click.byClass(Constants.ChangeManagement.failedIconClass);
455         Wait.modalToBeDisplayed();
456         Assert.assertTrue(Exists.modal());
457         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.failedModalHeaderId));
458         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.failedModalContentId));
459         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.failedModalRetryButtonId));
460         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.failedModalRollbackButtonId));
461
462         Click.byClass(Constants.generalCloseModalButtonClass);
463         Wait.modalToDisappear();
464     }
465
466     @Test(enabled = false)
467     public void testOpenInProgressStatusModal() {
468         ChangeManagementPage.openChangeManagementPage();
469
470         if(!Exists.byClass(Constants.ChangeManagement.processIconClass)) {
471             //TODO: Create a job which will shown with status in-progress.
472         }
473
474         Click.byClass(Constants.ChangeManagement.processIconClass);
475         Wait.modalToBeDisplayed();
476         Assert.assertTrue(Exists.modal());
477         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.inProgressModalHeaderId));
478         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.inProgressModalContentId));
479         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.inProgressModalStopButtonId));
480         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.inProgressModalRollbackButtonId));
481
482         Click.byClass(Constants.generalCloseModalButtonClass);
483         Wait.modalToDisappear();
484     }
485
486     @Test(enabled = false)
487     public void testOpenAlertStatusModal() {
488         ChangeManagementPage.openChangeManagementPage();
489
490         if(!Exists.byClass(Constants.ChangeManagement.alertIconClass)) {
491             //TODO: Create a job which will shown with status alert.
492         }
493
494         Click.byClass(Constants.ChangeManagement.alertIconClass);
495         Wait.modalToBeDisplayed();
496         Assert.assertTrue(Exists.modal());
497         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.alertModalHeaderId));
498         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.alertModalContentId));
499         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.alertModalContinueButtonId));
500         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.alertModalRollbackButtonId));
501
502         Click.byClass(Constants.generalCloseModalButtonClass);
503         Wait.modalToDisappear();
504     }
505
506     @Test(enabled = false)
507     public void testOpenPendingStatusModal() {
508         ChangeManagementPage.openChangeManagementPage();
509
510         if(!Exists.byClass(Constants.ChangeManagement.pendingIconClass)) {
511             //TODO: Create a job which will shown with status pending.
512         }
513
514         Click.byClass(Constants.ChangeManagement.pendingIconClass);
515         Wait.modalToBeDisplayed();
516         Assert.assertTrue(Exists.modal());
517         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pendingModalHeaderId));
518         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pendingModalContentId));
519         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pendingModalRescheduleButtonId));
520         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pendingModalRollbackButtonId));
521
522         Click.byClass(Constants.generalCloseModalButtonClass);
523         Wait.modalToDisappear();
524     }
525
526     @Test(enabled = false)
527     public void testSuccessCancelPendingWorkflow() {
528         ChangeManagementPage.openChangeManagementPage();
529         Wait.angularHttpRequestsLoaded();
530
531         Click.byClass(Constants.ChangeManagement.cancelPendingButtonClass); //cancel pending workflow modal
532         Wait.modalToBeDisplayed();
533         Assert.assertTrue(Exists.modal());
534         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pendingModalHeaderId));
535         Assert.assertTrue(Exists.byClass(Constants.ChangeManagement.pendingModalCancelWorkflowButtonClass));
536         Click.byClass(Constants.ChangeManagement.pendingModalCancelWorkflowButtonClass);
537         Wait.angularHttpRequestsLoaded();
538
539         Wait.modalToBeDisplayed(); //success alert modal should appear
540         Assert.assertTrue(Exists.modal());
541         Assert.assertTrue(Exists.byId(Constants.ChangeManagement.alertModalHeaderId));
542         Assert.assertTrue(Exists.byClassAndText(Constants.generalModalTitleClass, "Success"));
543         Click.byClass(Constants.generalCloseModalButtonClass);
544         Wait.modalToDisappear();
545         //TODO check the workflow deleted from table/changed to deleted action
546     }
547
548     private String getExpectedVidToMsoCallbackData(String modelInvariantId, String vnfInstanceId, String vnfName, String vnfTargetVersion, String workflow, String payload) {
549         return "" +
550                 "{" +
551                 "  \"requestType\": \"" + workflow + "\"," +
552                 "  \"requestDetails\": [" +
553                 "    {" +
554                 "      \"vnfName\": \"" + vnfName + "\"," +
555                 "      \"vnfInstanceId\": \"" + vnfInstanceId + "\"," +
556                 "      \"modelInfo\": {" +
557                 "        \"modelType\": \"vnf\"," +
558                 "        \"modelInvariantId\": \"" + modelInvariantId + "\"," +
559                 "        \"modelVersionId\": \"76e908e0-5201-44d2-a3e2-9e6128d05820\"," +
560                 "        \"modelName\": \"" + vnfName + "\"," +
561                 "        \"modelVersion\": \"" + vnfTargetVersion + "\"," +
562                 "        \"modelCustomizationId\": \"c00e8fc8-af39-4da8-8c78-a7efc2fe5994\"" +
563                 "      }," +
564                 "      \"cloudConfiguration\": {" +
565                 "        \"lcpCloudRegionId\": \"mdt1\"," +
566                 "        \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" +
567                 "      }," +
568                 "      \"requestInfo\": {" +
569                 "        \"source\": \"VID\"," +
570                 "        \"suppressRollback\": false," +
571                 "        \"requestorId\": \"az2016\"" +
572                 "      }," +
573                 "      \"relatedInstanceList\": [" +
574                 "        {" +
575                 "          \"relatedInstance\": {" +
576                 "            \"instanceId\": \"97315a05-e6f3-4c47-ae7e-d850c327aa08\"," +
577                 "            \"modelInfo\": {" +
578                 "              \"modelType\": \"service\"," +
579                 "              \"modelInvariantId\": \"e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0\"," +
580                 "              \"modelVersionId\": \"76e908e0-5201-44d2-a3e2-9e6128d05820\"," +
581                 "              \"modelName\": \"action-data\"," +
582                 "              \"modelVersion\": \"1.0\"" +
583                 "            }" +
584                 "          }" +
585                 "        }" +
586                 "      ]," +
587                 "      \"requestParameters\": {" +
588                 payload +
589                 "        \"usePreload\": true" +
590                 "      }" +
591                 "    }" +
592                 "  ]" +
593                 "}";
594     }
595
596 }