1- // package checkmarx.ast.eclipse.plugin.tests.ui;
1+ package checkmarx .ast .eclipse .plugin .tests .ui ;
22
3- // import static org.junit.Assert.assertFalse;
3+ import static org .junit .Assert .assertFalse ;
44
5- // import java.util.concurrent.TimeoutException;
5+ import java .util .concurrent .TimeoutException ;
66
7- // import org.eclipse.swtbot.swt.finder.SWTBot;
8- // import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
9- // import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
10- // import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
11- // import org.eclipse.swtbot.swt.finder.waits.ICondition;
12- // import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
13- // import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
14- // import org.junit.Test;
15- // import org.junit.runner.RunWith;
7+ import org .eclipse .swtbot .swt .finder .SWTBot ;
8+ import org .eclipse .swtbot .swt .finder .junit .SWTBotJunit4ClassRunner ;
9+ import org .eclipse .swtbot .swt .finder .keyboard .Keystrokes ;
10+ import org .eclipse .swtbot .swt .finder .utils .SWTBotPreferences ;
11+ import org .eclipse .swtbot .swt .finder .waits .ICondition ;
12+ import org .eclipse .swtbot .swt .finder .widgets .SWTBotShell ;
13+ import org .eclipse .swtbot .swt .finder .widgets .SWTBotToolbarButton ;
14+ import org .junit .Test ;
15+ import org .junit .runner .RunWith ;
1616
17- // import com.checkmarx.eclipse.utils.PluginConstants;
17+ import com .checkmarx .eclipse .utils .PluginConstants ;
1818
19- // import checkmarx.ast.eclipse.plugin.tests.common.Environment;
19+ import checkmarx .ast .eclipse .plugin .tests .common .Environment ;
2020
21- // @RunWith(SWTBotJunit4ClassRunner.class)
22- // public class TestScan extends BaseUITest {
21+ @ RunWith (SWTBotJunit4ClassRunner .class )
22+ public class TestScan extends BaseUITest {
2323
24- // public static final String ASSERT_START_SCAN_DISABLED = "Start scan must be disabled since there is no project or branch selected.";
25- // public static final String ASSERT_CANCEL_SCAN_DISABLED = "Cancel scan must be disabled since there is no project or branch selected and no running scan.";
26- // public static final String BTN_YES = "Yes";
27- // public static final String BTN_NO = "No";
24+ public static final String ASSERT_START_SCAN_DISABLED = "Start scan must be disabled since there is no project or branch selected." ;
25+ public static final String ASSERT_CANCEL_SCAN_DISABLED = "Cancel scan must be disabled since there is no project or branch selected and no running scan." ;
26+ public static final String BTN_YES = "Yes" ;
27+ public static final String BTN_NO = "No" ;
2828
29- // @Test
30- // public void testScanButtonsDisabledWhenMissingProjectOrBranch() throws TimeoutException {
31- // // Test Connection
32- // testSuccessfulConnection(false);
29+ @ Test
30+ public void testScanButtonsDisabledWhenMissingProjectOrBranch () throws TimeoutException {
31+ // Test Connection
32+ testSuccessfulConnection (false );
3333
34- // // Add Checkmarx One Plugin
35- // addCheckmarxPlugin(true);
34+ // Add Checkmarx One Plugin
35+ addCheckmarxPlugin (true );
3636
37- // // clear the view before getting the scan id
38- // _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.TOOLBAR_ACTION_CLEAR_RESULTS).click();
37+ // clear the view before getting the scan id
38+ _bot .viewByTitle (VIEW_CHECKMARX_AST_SCAN ).viewMenu ().menu (PluginConstants .TOOLBAR_ACTION_CLEAR_RESULTS ).click ();
3939
40- // SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get();
41- // assertFalse(ASSERT_START_SCAN_DISABLED, startBtn.isEnabled());
42- // SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get();
43- // assertFalse(ASSERT_CANCEL_SCAN_DISABLED, cancelBtn.isEnabled());
44- // }
40+ SWTBotToolbarButton startBtn = _bot .viewByTitle (VIEW_CHECKMARX_AST_SCAN ).getToolbarButtons ().stream ().filter (btn -> btn .getToolTipText ().equals (PluginConstants .CX_START_SCAN )).findFirst ().get ();
41+ assertFalse (ASSERT_START_SCAN_DISABLED , startBtn .isEnabled ());
42+ SWTBotToolbarButton cancelBtn = _bot .viewByTitle (VIEW_CHECKMARX_AST_SCAN ).getToolbarButtons ().stream ().filter (btn -> btn .getToolTipText ().equals (PluginConstants .CX_CANCEL_RUNNING_SCAN )).findFirst ().get ();
43+ assertFalse (ASSERT_CANCEL_SCAN_DISABLED , cancelBtn .isEnabled ());
44+ }
4545
46- // @Test
47- // public void testScanProjectDoesNotMatch() throws TimeoutException {
48- // // Used to wait for scan to finish
49- // SWTBotPreferences.TIMEOUT = 300000; // 5minutes
46+ @ Test
47+ public void testScanProjectDoesNotMatch () throws TimeoutException {
48+ // Used to wait for scan to finish
49+ SWTBotPreferences .TIMEOUT = 300000 ; // 5minutes
5050
51- // testSuccessfulConnection(false);
51+ testSuccessfulConnection (false );
5252
53- // addCheckmarxPlugin(true);
53+ addCheckmarxPlugin (true );
5454
55- // preventWidgetWasNullInCIEnvironment();
55+ preventWidgetWasNullInCIEnvironment ();
5656
57- // _bot.comboBox(2).setText(Environment.SCAN_ID_PROJECT_DOES_NOT_MATCH);
58- // _bot.comboBox(2).pressShortcut(Keystrokes.LF);
57+ _bot .comboBox (2 ).setText (Environment .SCAN_ID_PROJECT_DOES_NOT_MATCH );
58+ _bot .comboBox (2 ).pressShortcut (Keystrokes .LF );
5959
60- // waitUntilBranchComboIsEnabled();
60+ waitUntilBranchComboIsEnabled ();
6161
62- // _bot.waitUntil(startScanButtonEnabled);
62+ _bot .waitUntil (startScanButtonEnabled );
6363
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();
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 ();
6666
67- // SWTBotShell shell = _bot.shell(PluginConstants.CX_PROJECT_MISMATCH);
68- // shell.activate();
67+ SWTBotShell shell = _bot .shell (PluginConstants .CX_PROJECT_MISMATCH );
68+ shell .activate ();
6969
70- // _bot.button(BTN_NO).click();
70+ _bot .button (BTN_NO ).click ();
7171
72- // SWTBotPreferences.TIMEOUT = 5000;
73- // }
72+ SWTBotPreferences .TIMEOUT = 5000 ;
73+ }
7474
75- // @Test
76- // public void testCancelScan() throws TimeoutException {
77- // // Used to wait for scan to finish
78- // SWTBotPreferences.TIMEOUT = 300000; // 5minutes
75+ @ Test
76+ public void testCancelScan () throws TimeoutException {
77+ // Used to wait for scan to finish
78+ SWTBotPreferences .TIMEOUT = 300000 ; // 5minutes
7979
80- // testSuccessfulConnection(false);
80+ testSuccessfulConnection (false );
8181
82- // addCheckmarxPlugin(true);
82+ addCheckmarxPlugin (true );
8383
84- // preventWidgetWasNullInCIEnvironment();
84+ preventWidgetWasNullInCIEnvironment ();
8585
86- // _bot.comboBox(2).setText(Environment.SCAN_ID);
87- // _bot.comboBox(2).pressShortcut(Keystrokes.LF);
86+ _bot .comboBox (2 ).setText (Environment .SCAN_ID );
87+ _bot .comboBox (2 ).pressShortcut (Keystrokes .LF );
8888
89- // waitUntilBranchComboIsEnabled();
89+ waitUntilBranchComboIsEnabled ();
9090
91- // SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get();
92- // startBtn.click();
91+ SWTBotToolbarButton startBtn = _bot .viewByTitle (VIEW_CHECKMARX_AST_SCAN ).getToolbarButtons ().stream ().filter (btn -> btn .getToolTipText ().equals (PluginConstants .CX_START_SCAN )).findFirst ().get ();
92+ startBtn .click ();
9393
94- // SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get();
95- // _bot.waitUntil(cancelScanButtonEnabled);
96- // cancelBtn.click();
94+ SWTBotToolbarButton cancelBtn = _bot .viewByTitle (VIEW_CHECKMARX_AST_SCAN ).getToolbarButtons ().stream ().filter (btn -> btn .getToolTipText ().equals (PluginConstants .CX_CANCEL_RUNNING_SCAN )).findFirst ().get ();
95+ _bot .waitUntil (cancelScanButtonEnabled );
96+ cancelBtn .click ();
9797
98- // _bot.waitUntil(startScanButtonEnabled);
98+ _bot .waitUntil (startScanButtonEnabled );
9999
100- // SWTBotPreferences.TIMEOUT = 5000;
101- // }
100+ SWTBotPreferences .TIMEOUT = 5000 ;
101+ }
102102
103- // @Test
104- // public void testRunScan() throws TimeoutException {
105- // // Used to wait for scan to finish
106- // SWTBotPreferences.TIMEOUT = 300000; // 5minutes
103+ @ Test
104+ public void testRunScan () throws TimeoutException {
105+ // Used to wait for scan to finish
106+ SWTBotPreferences .TIMEOUT = 300000 ; // 5minutes
107107
108- // testSuccessfulConnection(false);
108+ testSuccessfulConnection (false );
109109
110- // addCheckmarxPlugin(true);
110+ addCheckmarxPlugin (true );
111111
112- // preventWidgetWasNullInCIEnvironment();
112+ preventWidgetWasNullInCIEnvironment ();
113113
114- // _bot.comboBox(2).setText(Environment.SCAN_ID);
115- // _bot.comboBox(2).pressShortcut(Keystrokes.LF);
114+ _bot .comboBox (2 ).setText (Environment .SCAN_ID );
115+ _bot .comboBox (2 ).pressShortcut (Keystrokes .LF );
116116
117- // waitUntilBranchComboIsEnabled();
117+ waitUntilBranchComboIsEnabled ();
118118
119- // sleep(10000);
119+ sleep (10000 );
120120
121- // SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get();
122- // startBtn.click();
121+ SWTBotToolbarButton startBtn = _bot .viewByTitle (VIEW_CHECKMARX_AST_SCAN ).getToolbarButtons ().stream ().filter (btn -> btn .getToolTipText ().equals (PluginConstants .CX_START_SCAN )).findFirst ().get ();
122+ startBtn .click ();
123123
124- // _bot.waitUntil(startScanButtonEnabled);
124+ _bot .waitUntil (startScanButtonEnabled );
125125
126- // SWTBotPreferences.TIMEOUT = 5000;
127- // }
126+ SWTBotPreferences .TIMEOUT = 5000 ;
127+ }
128128
129- // private static final ICondition startScanButtonEnabled = new ICondition() {
130- // @Override
131- // public boolean test() throws Exception {
132- // SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get();
133- // return startBtn.isEnabled();
134- // }
135-
136- // @Override
137- // public String getFailureMessage() {
138- // return "Start scan button must be enabled";
139- // }
129+ private static final ICondition startScanButtonEnabled = new ICondition () {
130+ @ Override
131+ public boolean test () throws Exception {
132+ SWTBotToolbarButton startBtn = _bot .viewByTitle (VIEW_CHECKMARX_AST_SCAN ).getToolbarButtons ().stream ().filter (btn -> btn .getToolTipText ().equals (PluginConstants .CX_START_SCAN )).findFirst ().get ();
133+ return startBtn .isEnabled ();
134+ }
135+
136+ @ Override
137+ public String getFailureMessage () {
138+ return "Start scan button must be enabled" ;
139+ }
140140
141- // @Override
142- // public void init(SWTBot bot) {
141+ @ Override
142+ public void init (SWTBot bot ) {
143143
144- // }
145- // };
144+ }
145+ };
146146
147- // private static final ICondition cancelScanButtonEnabled = new ICondition() {
148- // @Override
149- // public boolean test() throws Exception {
150- // SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get();
151- // return cancelBtn.isEnabled();
152- // }
153-
154- // @Override
155- // public String getFailureMessage() {
156- // return "Cancel scan button must be enabled";
157- // }
147+ private static final ICondition cancelScanButtonEnabled = new ICondition () {
148+ @ Override
149+ public boolean test () throws Exception {
150+ SWTBotToolbarButton cancelBtn = _bot .viewByTitle (VIEW_CHECKMARX_AST_SCAN ).getToolbarButtons ().stream ().filter (btn -> btn .getToolTipText ().equals (PluginConstants .CX_CANCEL_RUNNING_SCAN )).findFirst ().get ();
151+ return cancelBtn .isEnabled ();
152+ }
153+
154+ @ Override
155+ public String getFailureMessage () {
156+ return "Cancel scan button must be enabled" ;
157+ }
158158
159- // @Override
160- // public void init(SWTBot bot) {
159+ @ Override
160+ public void init (SWTBot bot ) {
161161
162- // }
163- // };
164- // }
162+ }
163+ };
164+ }
0 commit comments