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