Skip to content

Commit 57018f5

Browse files
author
elchananarb
committed
Update TestPreferences.java
1 parent 4e2edeb commit 57018f5

File tree

1 file changed

+10
-37
lines changed
  • checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui

1 file changed

+10
-37
lines changed

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

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,25 @@
11
package checkmarx.ast.eclipse.plugin.tests.ui;
22

3-
import static org.junit.Assert.*;
3+
import static org.junit.Assert.assertFalse;
4+
import java.util.concurrent.TimeoutException;
45
import org.junit.Test;
56
import org.junit.runner.RunWith;
67
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
7-
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
8-
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
9-
import java.util.concurrent.TimeoutException;
10-
118
import com.checkmarx.eclipse.utils.PluginConstants;
12-
import checkmarx.ast.eclipse.plugin.tests.common.Environment;
139

1410
@RunWith(SWTBotJunit4ClassRunner.class)
1511
public class TestPreferences extends BaseUITest {
1612

17-
public static final String ASSERT_API_KEY_EMPTY = "API Key field must not be empty after setting";
18-
public static final String ASSERT_CONNECTION_FAILED = "Connection test should fail with invalid key";
19-
13+
private static final String ASSERT_API_KEY_EMPTY = "API Key field must not be empty after setting";
14+
2015
@Test
21-
public void testPreferencesPageConnection() throws TimeoutException {
22-
// Set timeout for test
23-
SWTBotPreferences.TIMEOUT = 20000;
24-
25-
preventWidgetWasNullInCIEnvironment();
26-
27-
// Open preferences window
28-
_bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click();
29-
_bot.shell(ITEM_PREFERENCES).activate();
30-
_bot.tree().select(ITEM_CHECKMARX_AST);
31-
32-
_bot.sleep(1000);
33-
34-
// Test with valid API key
35-
_bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(Environment.API_KEY);
36-
_bot.button(BTN_APPLY).click();
37-
_bot.button(BTN_TEST_CONNECTION).click();
38-
39-
waitForConnectionResponse();
40-
41-
_bot.shell(ITEM_PREFERENCES).setFocus();
42-
_bot.button(BTN_APPLY_AND_CLOSE).click();
43-
44-
SWTBotPreferences.TIMEOUT = 5000;
16+
public void testPreferencesConnection() throws TimeoutException {
17+
// Test Connection using parent's method
18+
testSuccessfulConnection(false);
4519
}
4620

4721
@Test
48-
public void testPreferencesInvalidKey() throws TimeoutException {
22+
public void testInvalidKey() throws TimeoutException {
4923
preventWidgetWasNullInCIEnvironment();
5024

5125
// Open preferences
@@ -58,9 +32,8 @@ public void testPreferencesInvalidKey() throws TimeoutException {
5832
_bot.button(BTN_APPLY).click();
5933
_bot.button(BTN_TEST_CONNECTION).click();
6034

61-
// Wait and verify failure
62-
_bot.sleep(5000);
63-
assertFalse(ASSERT_CONNECTION_FAILED, _bot.text(3).getText().equals(INFO_SUCCESSFUL_CONNECTION));
35+
// Use parent's method to check connection
36+
waitForConnectionResponse();
6437

6538
_bot.button(BTN_APPLY_AND_CLOSE).click();
6639
}

0 commit comments

Comments
 (0)