Skip to content

Commit efee2e5

Browse files
author
elchananarb
committed
Update TestScan.java
1 parent 03bdb5c commit efee2e5

1 file changed

Lines changed: 46 additions & 24 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/TestScan.java

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,54 @@ public void testScanButtonsDisabledWhenMissingProjectOrBranch() throws TimeoutEx
4545

4646
@Test
4747
public void testScanProjectDoesNotMatch() throws TimeoutException {
48-
// Used to wait for scan to finish
49-
SWTBotPreferences.TIMEOUT = 300000; // 5minutes
50-
51-
testSuccessfulConnection(false);
48+
// Set SWTBot timeout to 5 minutes to wait for slow operations
49+
SWTBotPreferences.TIMEOUT = 300000; // 5 minutes
5250

53-
addCheckmarxPlugin(true);
54-
55-
preventWidgetWasNullInCIEnvironment();
56-
57-
_bot.comboBox(2).setText("9a9c75a5-2fb1-460c-80f7-f902790422b0");
58-
_bot.comboBox(2).pressShortcut(Keystrokes.LF);
59-
60-
waitUntilBranchComboIsEnabled();
61-
62-
_bot.waitUntil(startScanButtonEnabled);
63-
64-
SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get();
65-
startBtn.click();
66-
67-
SWTBotShell shell = _bot.shell(PluginConstants.CX_PROJECT_MISMATCH);
68-
shell.activate();
69-
70-
_bot.button(BTN_NO).click();
71-
72-
SWTBotPreferences.TIMEOUT = 5000;
51+
// Ensure successful connection to the server
52+
testSuccessfulConnection(false);
53+
54+
// Add the Checkmarx plugin to the environment
55+
addCheckmarxPlugin(true);
56+
57+
// Handle potential widget null issues in CI environment
58+
preventWidgetWasNullInCIEnvironment();
59+
60+
// Set the project ID in the combo box
61+
_bot.comboBox(2).setText("9a9c75a5-2fb1-460c-80f7-f902790422b0");
62+
_bot.comboBox(2).pressShortcut(Keystrokes.LF);
63+
64+
// Wait until the branch combo box is enabled
65+
waitUntilBranchComboIsEnabled();
66+
67+
// Wait until the Start Scan button is enabled
68+
_bot.waitUntil(startScanButtonEnabled);
69+
70+
// Add a 30-second delay
71+
try {
72+
Thread.sleep(30000); // 30 seconds
73+
} catch (InterruptedException e) {
74+
e.printStackTrace(); // Handle interruption
75+
}
76+
77+
// Find and click the Start Scan button
78+
SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN)
79+
.getToolbarButtons().stream()
80+
.filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN))
81+
.findFirst()
82+
.orElseThrow(() -> new RuntimeException("Start Scan button not found"));
83+
startBtn.click();
84+
85+
// Wait for and activate the project mismatch dialog
86+
SWTBotShell shell = _bot.shell(PluginConstants.CX_PROJECT_MISMATCH);
87+
shell.activate();
88+
89+
// Click the "No" button in the dialog
90+
_bot.button(BTN_NO).click();
91+
92+
// Reset SWTBot timeout to 5 seconds
93+
SWTBotPreferences.TIMEOUT = 5000;
7394
}
95+
7496

7597
@Test
7698
public void testCancelScan() throws TimeoutException {

0 commit comments

Comments
 (0)