1 package vid.automation.test.test;
3 import com.google.common.collect.ImmutableMap;
4 import org.junit.Assert;
5 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
6 import org.openqa.selenium.JavascriptExecutor;
7 import org.testng.annotations.AfterClass;
8 import org.testng.annotations.BeforeClass;
9 import org.testng.annotations.BeforeMethod;
10 import org.testng.annotations.Test;
11 import vid.automation.test.infra.FeatureTogglingTest;
12 import vid.automation.test.sections.InstantiationStatusPage;
13 import vid.automation.test.sections.SideMenu;
14 import vid.automation.test.services.AsyncJobsService;
16 import java.util.UUID;
18 import static vid.automation.test.infra.Features.FLAG_ASYNC_INSTANTIATION;
19 import static vid.automation.test.sections.InstantiationStatusPage.assertInstantiationStatusRow;
20 import static vid.automation.test.sections.InstantiationStatusPage.getNumberOfTableRows;
22 @FeatureTogglingTest(FLAG_ASYNC_INSTANTIATION)
23 public class InstantiationStatusTest extends VidBaseTestCase {
26 private final String serviceModelVersion = "1.0";
27 private final String subscriberId = "ac040e8a-b43a-441b-ab87-603f5b70be55";
28 private final String regionId = "my-expected-region-id";
29 private final String projectName = "a-project-name";
30 final static String owningEntityName = "expected-owningEntityName";
31 final static String subscriberName = "expected-subscriberName";
34 private String currentUUI;
37 protected void dropAllAsyncJobs() {
38 AsyncJobsService asyncJobsService = new AsyncJobsService();
39 asyncJobsService.dropAllAsyncJobs();
43 protected void muteAllAsyncJobs() {
44 AsyncJobsService asyncJobsService = new AsyncJobsService();
45 asyncJobsService.muteAllAsyncJobs();
49 protected void createJobsData() {
51 SideMenu.navigateToMacroInstantiationStatus();
54 private String addOneJob() {
55 currentUUI = UUID.randomUUID().toString();
56 final JavascriptExecutor javascriptExecutor = (JavascriptExecutor) GeneralUIUtils.getDriver();
57 Object result = javascriptExecutor.executeScript(
58 "return (function postJob(){var xhttp = new XMLHttpRequest(); " +
60 " xhttp.onreadystatechange = function() { " +
61 " return this.responseText; " +
64 " xhttp.open(\"POST\", '/vid/asyncInstantiation/bulk', false); " +
65 " xhttp.setRequestHeader(\"Content-type\", \"application/json\"); " +
67 " \"modelInfo\": { " +
68 " \"modelType\": \"service\", " +
69 " \"modelInvariantId\": \"300adb1e-9b0c-4d52-bfb5-fa5393c4eabb\", " +
70 " \"modelVersionId\": \"5c9e863f-2716-467b-8799-4a67f378dcaa\", " +
71 " \"modelName\": \"AIM_TRANSPORT_00004\", " +
72 " \"modelVersion\": \"" + serviceModelVersion + "\" " +
74 " \"owningEntityId\" : \"someID\", " +
75 " \"owningEntityName\": \"" + owningEntityName + "\", " +
76 " \"projectName\" : \"" + projectName + currentUUI + "\", " +
77 " \"globalSubscriberId\": \"" + subscriberId + "\", " +
78 " \"subscriberName\": \"" + subscriberName + "\", " +
79 " \"productFamilyId\" : \"myProductFamilyId\", " +
80 " \"instanceName\" : \"MichaelJordan\", " +
81 " \"subscriptionServiceType\" : \"mySubType\", " +
82 " \"lcpCloudRegionId\" : \"" + regionId + "\", " +
83 " \"tenantId\" : \"greatTenant\", " +
84 " \"bulkSize\": 1, " +
85 " \"isUserProvidedNaming\": \"true\", " +
89 "return JSON.parse(xhttp.responseText).entity;})()"
92 return result.toString();
96 public void testServiceInfoIsPresentedInTable() {
97 InstantiationStatusPage.clickRefreshButton();
99 assertInstantiationStatusRow(projectName + currentUUI, ImmutableMap.of(
100 "subscriberName", subscriberName,
101 "regionId", regionId,
102 "serviceModelVersion", serviceModelVersion,
103 "owningEntityName", owningEntityName
109 public void testServiceInfoDataUpdatingAfterClickRefresh() {
110 long numberOfRows = getNumberOfTableRows(60);
113 InstantiationStatusPage.clickRefreshButton();
114 int numberOfRowsAfterRefresh = getNumberOfTableRows(60);
115 Assert.assertEquals(numberOfRows + 1 , numberOfRowsAfterRefresh);