Skip to content

Commit bf7d9c8

Browse files
author
elchananarb
committed
revert
1 parent 730826a commit bf7d9c8

1 file changed

Lines changed: 62 additions & 71 deletions

File tree

  • checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui

checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/BaseUITest.java

Lines changed: 62 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,47 @@
2323
public abstract class BaseUITest {
2424

2525
private static final String INFO_SUCCESSFUL_CONNECTION = "Successfully authenticated to Checkmarx One server!";
26-
26+
2727
protected static final String ASSERT_FILTER_ACTIONS_IN_TOOLBAR = "All filter actions must be in the tool bar";
28-
28+
2929
protected static final String TAB_WINDOW = "Window";
30-
30+
3131
protected static final String ITEM_SHOW_VIEW = "Show View";
3232
protected static final String ITEM_PREFERENCES = "Preferences";
3333
protected static final String ITEM_OTHER = "Other...";
3434
protected static final String ITEM_CHECKMARX = "Checkmarx";
3535
protected static final String ITEM_CHECKMARX_AST = "Checkmarx One";
3636
protected static final String ITEM_CHECKMARX_AST_SCAN = "Checkmarx One Scan";
37-
38-
protected static final String LABEL_CX_TEST_SCAN = "Scan Id:";
39-
37+
38+
protected static final String LABEL_SCAN_ID = "Scan Id:";
39+
4040
protected static final String BTN_OPEN = "Open";
4141
protected static final String BTN_APPLY = "Apply";
4242
protected static final String BTN_TEST_CONNECTION = "Test Connection";
4343
protected static final String BTN_OK = "OK";
4444
protected static final String BTN_APPLY_AND_CLOSE = "Apply and Close";
45-
45+
4646
protected static final String SHELL_AUTHENTICATION = "Authentication";
47-
47+
4848
protected static final String VIEW_CHECKMARX_AST_SCAN = "Checkmarx One Scan";
49-
49+
5050
protected static SWTWorkbenchBot _bot;
5151
private static boolean eclipseProjectExist = false;
52-
52+
5353
protected static boolean _cxSettingsDefined = false;
54-
54+
5555
@BeforeClass
5656
public static void beforeClass() throws Exception {
5757
// Needed to set CI environment keyboard layout
58-
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
58+
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
5959

6060
// Used to decrease tests velocity
6161
SWTBotPreferences.PLAYBACK_DELAY = 100;
62-
63-
SWTBotPreferences.TIMEOUT = 8000;
62+
63+
SWTBotPreferences.TIMEOUT = 15000;
6464

6565
_bot = new SWTWorkbenchBot();
66-
66+
6767
if(!eclipseProjectExist) {
6868
createEclipseProject();
6969
eclipseProjectExist = true;
@@ -73,17 +73,17 @@ public static void beforeClass() throws Exception {
7373
@After
7474
public void tearDown() throws Exception {
7575
}
76-
76+
7777
@AfterClass
7878
public static void sleep() {
7979
_bot.sleep(2000);
8080
}
81-
82-
81+
82+
8383
protected static void sleep(long millis) {
8484
_bot.sleep(millis);
8585
}
86-
86+
8787
/**
8888
* Used to get the workbench focus back and avoid "widget was null" error message in the CI environment
8989
*/
@@ -94,14 +94,14 @@ public void run() {
9494
}
9595
});
9696
}
97-
97+
9898
/**
9999
* Set up checkmarx plugin
100-
*
100+
*
101101
* -> Set credentials
102102
* -> Test connection
103103
* -> Add checkmarx plugin
104-
*
104+
*
105105
* @throws TimeoutException
106106
*/
107107
protected void setUpCheckmarxPlugin(boolean ignoreWrongScanValidation) throws TimeoutException {
@@ -110,9 +110,9 @@ protected void setUpCheckmarxPlugin(boolean ignoreWrongScanValidation) throws Ti
110110

111111
// Add Checkmarx One Plugin
112112
addCheckmarxPlugin(true);
113-
113+
114114
preventWidgetWasNullInCIEnvironment();
115-
115+
116116
if(!ignoreWrongScanValidation) {
117117
// Test incorrect Scan ID format
118118
_bot.comboBox(2).setText("invalid-scan-id");
@@ -123,34 +123,34 @@ protected void setUpCheckmarxPlugin(boolean ignoreWrongScanValidation) throws Ti
123123
assertEquals("The tree must contain one row with an error message", _bot.tree(1).rowCount(), 1);
124124
assertEquals("An incorrect scanId format message must be displayed", PluginConstants.TREE_INVALID_SCAN_ID_FORMAT, _bot.tree(1).cell(0, 0));
125125
}
126-
126+
127127
// clear the view before getting the scan id
128128
_bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.TOOLBAR_ACTION_CLEAR_RESULTS).click();
129-
129+
130130
sleep(1000);
131-
131+
132132
// type a valid and existing Scan ID
133133
typeValidScanID();
134134

135-
assertEquals("The tree must contain one row", _bot.tree().rowCount(), 1);
135+
assertEquals("The tree must contain one row", _bot.tree().rowCount(), 1);
136136
boolean retrievingOrRetrievedResults = _bot.tree(1).cell(0, 0).contains(Environment.SCAN_ID);
137137
assertTrue("The plugin should have or should be retrieving results", retrievingOrRetrievedResults);
138138

139139
waitWhileTreeNodeEqualsTo(String.format(PluginConstants.RETRIEVING_RESULTS_FOR_SCAN, Environment.SCAN_ID));
140-
140+
141141
assertTrue("The plugin should retrieve results", _bot.tree(1).cell(0, 0).startsWith(Environment.SCAN_ID));
142142
}
143143

144144
/**
145145
* Test successful connection
146-
*
146+
*
147147
* @throws TimeoutException
148148
*/
149149
protected void testSuccessfulConnection(boolean openFromInitialPanel) throws TimeoutException {
150150
preventWidgetWasNullInCIEnvironment();
151-
151+
152152
if(_cxSettingsDefined) return;
153-
153+
154154
if(!openFromInitialPanel) {
155155
_bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click();
156156
_bot.shell(ITEM_PREFERENCES).activate();
@@ -160,43 +160,43 @@ protected void testSuccessfulConnection(boolean openFromInitialPanel) throws Tim
160160
_bot.sleep(1000);
161161

162162
_bot.shell(ITEM_PREFERENCES).setFocus(); // Need to set focus to avoid failing in CI environment
163-
163+
164164
_bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(Environment.API_KEY);
165165

166166
_bot.button(BTN_APPLY).click();
167167
_bot.button(BTN_TEST_CONNECTION).click();
168-
168+
169169
//Do waitUntil Method to get text from text(6)
170170
waitForConnectionResponse();
171-
171+
172172
_bot.shell(ITEM_PREFERENCES).setFocus(); // Need to set focus to avoid failing in CI environment
173173
_bot.button(BTN_APPLY_AND_CLOSE).click();
174174

175175
_cxSettingsDefined = true;
176176
}
177-
177+
178178

179179
/**
180180
* Add Checkmarx plugin in the show view perspective
181-
*
182-
* @throws TimeoutException
181+
*
182+
* @throws TimeoutException
183183
*/
184184
protected void addCheckmarxPlugin(boolean waitUntilPluginEnable) throws TimeoutException {
185185
preventWidgetWasNullInCIEnvironment();
186-
186+
187187
_bot.menu(TAB_WINDOW).menu(ITEM_SHOW_VIEW).menu(ITEM_OTHER).click();
188188
_bot.shell(ITEM_SHOW_VIEW).activate();
189189
_bot.tree().expandNode(ITEM_CHECKMARX).select(ITEM_CHECKMARX_AST_SCAN);
190190
_bot.button(BTN_OPEN).click();
191-
191+
192192
if(waitUntilPluginEnable) {
193-
waitUntilBranchComboIsEnabled();
193+
waitUntilBranchComboIsEnabled();
194194
}
195195
}
196-
196+
197197
/**
198198
* Wait while tree node equals to a a specific message. Fails after 10 retries
199-
*
199+
*
200200
* @param nodeText
201201
* @throws TimeoutException
202202
*/
@@ -218,22 +218,22 @@ protected static void waitWhileTreeNodeEqualsTo(String nodeText) throws TimeoutE
218218
throw new TimeoutException("Timeout after 5000ms. Scan results should be retrieved");
219219
}
220220
}
221-
221+
222222
/**
223223
* Wait until branch combobox is enabled
224-
*
224+
*
225225
* @throws TimeoutException
226226
*/
227227
protected static void waitUntilBranchComboIsEnabled() throws TimeoutException {
228228
preventWidgetWasNullInCIEnvironment();
229-
229+
230230
boolean emptyScanId = _bot.comboBox(2).getText().isEmpty() || _bot.comboBox(2).getText().equals(PluginConstants.COMBOBOX_SCAND_ID_PLACEHOLDER);
231231
boolean projectNotSelected =_bot.comboBox(0).getText().isEmpty() || _bot.comboBox(0).getText().equals("Select a project");
232-
232+
233233
if(emptyScanId || projectNotSelected) {
234234
return;
235235
}
236-
236+
237237
int retryIdx = 0;
238238

239239
while (!_bot.comboBox(1).isEnabled()) {
@@ -250,18 +250,18 @@ protected static void waitUntilBranchComboIsEnabled() throws TimeoutException {
250250
if (retryIdx == 10) {
251251
emptyScanId = _bot.comboBox(2).getText().isEmpty() || _bot.comboBox(2).getText().equals(PluginConstants.COMBOBOX_SCAND_ID_PLACEHOLDER);
252252
projectNotSelected = _bot.comboBox(0).getText().isEmpty() || _bot.comboBox(0).getText().equals("Select a project");
253-
253+
254254
if(emptyScanId || projectNotSelected) {
255255
return;
256256
}
257-
257+
258258
throw new TimeoutException("Timeout after 5000ms. Branches' combobox must be enabled");
259259
}
260260
}
261-
261+
262262
/**
263263
* Wait while tree node equals to a a specific message. Fails after 10 retries
264-
*
264+
*
265265
* @param nodeText
266266
* @throws TimeoutException
267267
*/
@@ -280,31 +280,22 @@ protected static void waitForConnectionResponse() throws TimeoutException {
280280
throw new TimeoutException("Connection validation timeout after 10000ms.");
281281
}
282282
}
283-
283+
284284

285285
/**
286286
* Type a valid Scan ID to get results
287-
*
288-
* @throws TimeoutException
287+
*
288+
* @throws TimeoutException
289289
*/
290290
private void typeValidScanID() throws TimeoutException {
291291
preventWidgetWasNullInCIEnvironment();
292-
293-
String scanId = System.getenv("SCAN_ID");
294-
String scanId2 = System.getenv("CX_TEST_SCAN");
295-
String scanId3 = Environment.SCAN_ID;
296-
297-
if (scanId == null || scanId2 == null || scanId3 == null) {
298-
throw new IllegalArgumentException("Environment variable Environment.SCAN_ID is not set. Value: " + scanId
299-
+ "Environment variable SCAN_ID2 is not set. Value: " + scanId2 + "Environment variable SCAN_ID3 is not set. Value: " + scanId3);
300-
}
301-
292+
302293
_bot.comboBox(2).setText(Environment.SCAN_ID);
303294
_bot.comboBox(2).pressShortcut(Keystrokes.LF);
304-
295+
305296
waitUntilBranchComboIsEnabled();
306297
}
307-
298+
308299
/**
309300
* Create a eclipse project
310301
*/
@@ -314,14 +305,14 @@ private static void createEclipseProject() {
314305
shell.activate();
315306
_bot.tree().select("Project");
316307
_bot.button("Next >").click();
317-
318-
308+
309+
319310
_bot.textWithLabel("Project name:").setText("MyFirstProject");
320311
_bot.button("Finish").click();
321-
312+
322313
_bot.menu("File").menu("New").menu("File").click();
323314
_bot.textWithLabel("File name:").setText("Dockerfile");
324315
_bot.tree().select(0);
325316
_bot.button("Finish").click();
326317
}
327-
}
318+
}

0 commit comments

Comments
 (0)