From 61cd8c407cbe6ff877b8f67c567e6f789edfd805 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Tue, 21 Jan 2025 14:59:01 +0200 Subject: [PATCH 01/13] Add ui test --- .../checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java new file mode 100644 index 00000000..e69de29b From 1e52d867e7c34ac6ad80be0fdafb094d288d63e3 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Tue, 21 Jan 2025 15:00:51 +0200 Subject: [PATCH 02/13] Update TestPreferences.java --- .../plugin/tests/ui/TestPreferences.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java index e69de29b..612b9e29 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java @@ -0,0 +1,65 @@ +package checkmarx.ast.eclipse.plugin.tests.ui; + +import static org.junit.Assert.*; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import com.checkmarx.eclipse.utils.PluginConstants; + +@RunWith(SWTBotJunit4ClassRunner.class) +public class TestPreferences extends BaseUITest { + + @Test + public void testPreferencesPageOpen() throws TimeoutException { + // Open preferences window + _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); + _bot.shell(ITEM_PREFERENCES).activate(); + _bot.tree().select(ITEM_CHECKMARX_AST); + + // Verify preferences page opens with correct fields + assertTrue("API Key field should be visible", + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).isVisible()); + assertTrue("Test Connection button should be visible", + _bot.button(BTN_TEST_CONNECTION).isVisible()); + } + + @Test + public void testInvalidAPIKey() throws TimeoutException { + // Open preferences window + _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); + _bot.shell(ITEM_PREFERENCES).activate(); + _bot.tree().select(ITEM_CHECKMARX_AST); + + // Try to connect with invalid API key + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText("invalid-key"); + _bot.button(BTN_TEST_CONNECTION).click(); + + // Check for appropriate error message + waitForConnectionResponse(); + assertFalse("Should show error message for invalid API key", + _bot.text(3).getText().equals(INFO_SUCCESSFUL_CONNECTION)); + } + + @Test + public void testPreferencesSave() throws TimeoutException { + // Open preferences window + _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); + _bot.shell(ITEM_PREFERENCES).activate(); + _bot.tree().select(ITEM_CHECKMARX_AST); + + // Save preferences and verify they persist + String testApiKey = "test-api-key"; + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(testApiKey); + _bot.button(BTN_APPLY).click(); + + // Reopen preferences to verify + _bot.shell(ITEM_PREFERENCES).close(); + _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); + _bot.shell(ITEM_PREFERENCES).activate(); + _bot.tree().select(ITEM_CHECKMARX_AST); + + assertEquals("API Key should persist after saving", + testApiKey, + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).getText()); + } +} \ No newline at end of file From 4e2edeb62a14fc0909d8bd7de84e444faf18b199 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Tue, 21 Jan 2025 15:16:50 +0200 Subject: [PATCH 03/13] Update TestPreferences.java --- .../plugin/tests/ui/TestPreferences.java | 68 ++++++++++--------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java index 612b9e29..76746e14 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java @@ -4,62 +4,64 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; +import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; +import java.util.concurrent.TimeoutException; + import com.checkmarx.eclipse.utils.PluginConstants; +import checkmarx.ast.eclipse.plugin.tests.common.Environment; @RunWith(SWTBotJunit4ClassRunner.class) public class TestPreferences extends BaseUITest { - @Test - public void testPreferencesPageOpen() throws TimeoutException { - // Open preferences window - _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); - _bot.shell(ITEM_PREFERENCES).activate(); - _bot.tree().select(ITEM_CHECKMARX_AST); - - // Verify preferences page opens with correct fields - assertTrue("API Key field should be visible", - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).isVisible()); - assertTrue("Test Connection button should be visible", - _bot.button(BTN_TEST_CONNECTION).isVisible()); - } + public static final String ASSERT_API_KEY_EMPTY = "API Key field must not be empty after setting"; + public static final String ASSERT_CONNECTION_FAILED = "Connection test should fail with invalid key"; @Test - public void testInvalidAPIKey() throws TimeoutException { + public void testPreferencesPageConnection() throws TimeoutException { + // Set timeout for test + SWTBotPreferences.TIMEOUT = 20000; + + preventWidgetWasNullInCIEnvironment(); + // Open preferences window _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); _bot.shell(ITEM_PREFERENCES).activate(); _bot.tree().select(ITEM_CHECKMARX_AST); - - // Try to connect with invalid API key - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText("invalid-key"); + + _bot.sleep(1000); + + // Test with valid API key + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(Environment.API_KEY); + _bot.button(BTN_APPLY).click(); _bot.button(BTN_TEST_CONNECTION).click(); - // Check for appropriate error message waitForConnectionResponse(); - assertFalse("Should show error message for invalid API key", - _bot.text(3).getText().equals(INFO_SUCCESSFUL_CONNECTION)); + + _bot.shell(ITEM_PREFERENCES).setFocus(); + _bot.button(BTN_APPLY_AND_CLOSE).click(); + + SWTBotPreferences.TIMEOUT = 5000; } @Test - public void testPreferencesSave() throws TimeoutException { - // Open preferences window + public void testPreferencesInvalidKey() throws TimeoutException { + preventWidgetWasNullInCIEnvironment(); + + // Open preferences _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); _bot.shell(ITEM_PREFERENCES).activate(); _bot.tree().select(ITEM_CHECKMARX_AST); - // Save preferences and verify they persist - String testApiKey = "test-api-key"; - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(testApiKey); + // Set invalid key and test + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText("invalid-key"); _bot.button(BTN_APPLY).click(); + _bot.button(BTN_TEST_CONNECTION).click(); - // Reopen preferences to verify - _bot.shell(ITEM_PREFERENCES).close(); - _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); - _bot.shell(ITEM_PREFERENCES).activate(); - _bot.tree().select(ITEM_CHECKMARX_AST); + // Wait and verify failure + _bot.sleep(5000); + assertFalse(ASSERT_CONNECTION_FAILED, _bot.text(3).getText().equals(INFO_SUCCESSFUL_CONNECTION)); - assertEquals("API Key should persist after saving", - testApiKey, - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).getText()); + _bot.button(BTN_APPLY_AND_CLOSE).click(); } } \ No newline at end of file From 57018f55fbda0ce96e6927d115433e7eee62767b Mon Sep 17 00:00:00 2001 From: elchananarb Date: Tue, 21 Jan 2025 15:23:16 +0200 Subject: [PATCH 04/13] Update TestPreferences.java --- .../plugin/tests/ui/TestPreferences.java | 47 ++++--------------- 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java index 76746e14..71995862 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java @@ -1,51 +1,25 @@ package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import java.util.concurrent.TimeoutException; import org.junit.Test; import org.junit.runner.RunWith; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; -import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import java.util.concurrent.TimeoutException; - import com.checkmarx.eclipse.utils.PluginConstants; -import checkmarx.ast.eclipse.plugin.tests.common.Environment; @RunWith(SWTBotJunit4ClassRunner.class) public class TestPreferences extends BaseUITest { - public static final String ASSERT_API_KEY_EMPTY = "API Key field must not be empty after setting"; - public static final String ASSERT_CONNECTION_FAILED = "Connection test should fail with invalid key"; - + private static final String ASSERT_API_KEY_EMPTY = "API Key field must not be empty after setting"; + @Test - public void testPreferencesPageConnection() throws TimeoutException { - // Set timeout for test - SWTBotPreferences.TIMEOUT = 20000; - - preventWidgetWasNullInCIEnvironment(); - - // Open preferences window - _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); - _bot.shell(ITEM_PREFERENCES).activate(); - _bot.tree().select(ITEM_CHECKMARX_AST); - - _bot.sleep(1000); - - // Test with valid API key - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(Environment.API_KEY); - _bot.button(BTN_APPLY).click(); - _bot.button(BTN_TEST_CONNECTION).click(); - - waitForConnectionResponse(); - - _bot.shell(ITEM_PREFERENCES).setFocus(); - _bot.button(BTN_APPLY_AND_CLOSE).click(); - - SWTBotPreferences.TIMEOUT = 5000; + public void testPreferencesConnection() throws TimeoutException { + // Test Connection using parent's method + testSuccessfulConnection(false); } @Test - public void testPreferencesInvalidKey() throws TimeoutException { + public void testInvalidKey() throws TimeoutException { preventWidgetWasNullInCIEnvironment(); // Open preferences @@ -58,9 +32,8 @@ public void testPreferencesInvalidKey() throws TimeoutException { _bot.button(BTN_APPLY).click(); _bot.button(BTN_TEST_CONNECTION).click(); - // Wait and verify failure - _bot.sleep(5000); - assertFalse(ASSERT_CONNECTION_FAILED, _bot.text(3).getText().equals(INFO_SUCCESSFUL_CONNECTION)); + // Use parent's method to check connection + waitForConnectionResponse(); _bot.button(BTN_APPLY_AND_CLOSE).click(); } From 46b07602cf06c9d3e56b191ceb0fe647c13f6955 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Tue, 21 Jan 2025 15:39:24 +0200 Subject: [PATCH 05/13] Update TestPreferences.java --- .../ast/eclipse/plugin/tests/ui/TestPreferences.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java index 71995862..c745c458 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java @@ -14,7 +14,6 @@ public class TestPreferences extends BaseUITest { @Test public void testPreferencesConnection() throws TimeoutException { - // Test Connection using parent's method testSuccessfulConnection(false); } @@ -22,18 +21,20 @@ public void testPreferencesConnection() throws TimeoutException { public void testInvalidKey() throws TimeoutException { preventWidgetWasNullInCIEnvironment(); - // Open preferences _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); _bot.shell(ITEM_PREFERENCES).activate(); _bot.tree().select(ITEM_CHECKMARX_AST); - // Set invalid key and test _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText("invalid-key"); _bot.button(BTN_APPLY).click(); _bot.button(BTN_TEST_CONNECTION).click(); - // Use parent's method to check connection - waitForConnectionResponse(); + // Wait for error response instead of success + _bot.sleep(5000); // Wait for response + + // Check that error message appears + assertFalse("Connection should fail with invalid key", + _bot.text(3).getText().contains("Successfully authenticated")); _bot.button(BTN_APPLY_AND_CLOSE).click(); } From 1b453ea4d48141fe51e3bda5a747df0582e06c64 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Tue, 21 Jan 2025 15:49:09 +0200 Subject: [PATCH 06/13] Update TestPreferences.java add finally --- .../plugin/tests/ui/TestPreferences.java | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java index c745c458..dcb64cee 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java @@ -19,23 +19,31 @@ public void testPreferencesConnection() throws TimeoutException { @Test public void testInvalidKey() throws TimeoutException { - preventWidgetWasNullInCIEnvironment(); - - _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); - _bot.shell(ITEM_PREFERENCES).activate(); - _bot.tree().select(ITEM_CHECKMARX_AST); - - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText("invalid-key"); - _bot.button(BTN_APPLY).click(); - _bot.button(BTN_TEST_CONNECTION).click(); - - // Wait for error response instead of success - _bot.sleep(5000); // Wait for response - - // Check that error message appears - assertFalse("Connection should fail with invalid key", - _bot.text(3).getText().contains("Successfully authenticated")); - - _bot.button(BTN_APPLY_AND_CLOSE).click(); + try { + preventWidgetWasNullInCIEnvironment(); + + _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); + _bot.shell(ITEM_PREFERENCES).activate(); + _bot.tree().select(ITEM_CHECKMARX_AST); + + // Test invalid key + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText("invalid-key"); + _bot.button(BTN_APPLY).click(); + _bot.button(BTN_TEST_CONNECTION).click(); + + _bot.sleep(5000); + + assertFalse("Connection should fail with invalid key", + _bot.text(3).getText().contains("Successfully authenticated")); + + } finally { + // Restore valid API key for next tests + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(Environment.API_KEY); + _bot.button(BTN_APPLY).click(); + _bot.button(BTN_TEST_CONNECTION).click(); + waitForConnectionResponse(); + _bot.button(BTN_APPLY_AND_CLOSE).click(); + _cxSettingsDefined = true; // Make sure flag is set for next tests + } } } \ No newline at end of file From c8e6aa7d7e8440b38f9e9d703b867488035781b0 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Tue, 21 Jan 2025 16:02:01 +0200 Subject: [PATCH 07/13] Update TestPreferences.java --- .../plugin/tests/ui/TestPreferences.java | 107 ++++++++++++------ 1 file changed, 74 insertions(+), 33 deletions(-) diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java index dcb64cee..ee17e913 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java @@ -1,49 +1,90 @@ package checkmarx.ast.eclipse.plugin.tests.ui; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + import java.util.concurrent.TimeoutException; + +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.junit.Test; import org.junit.runner.RunWith; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; + import com.checkmarx.eclipse.utils.PluginConstants; @RunWith(SWTBotJunit4ClassRunner.class) public class TestPreferences extends BaseUITest { - + private static final String ASSERT_API_KEY_EMPTY = "API Key field must not be empty after setting"; - + private static final String ASSERT_CONNECTION_FAILED = "Connection should fail with an invalid API key"; + private static final String ASSERT_CONNECTION_SUCCESS = "Connection should succeed with a valid API key"; + + @Test + public void testValidApiKeyConnection() throws TimeoutException { + preventWidgetWasNullInCIEnvironment(); + + // Open Preferences + _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); + _bot.shell(ITEM_PREFERENCES).activate(); + _bot.tree().select(ITEM_CHECKMARX_AST); + + // Set valid API key + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(Environment.API_KEY); + _bot.button(BTN_APPLY).click(); + _bot.button(BTN_TEST_CONNECTION).click(); + + // Wait for successful connection message + waitForConnectionResponse(); + + // Validate success message + assertTrue(ASSERT_CONNECTION_SUCCESS, + _bot.text(3).getText().contains("Successfully authenticated")); + + _bot.button(BTN_APPLY_AND_CLOSE).click(); + } + @Test - public void testPreferencesConnection() throws TimeoutException { - testSuccessfulConnection(false); + public void testInvalidApiKeyConnection() throws TimeoutException { + preventWidgetWasNullInCIEnvironment(); + + // Open Preferences + _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); + _bot.shell(ITEM_PREFERENCES).activate(); + _bot.tree().select(ITEM_CHECKMARX_AST); + + // Set invalid API key + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText("invalid-key"); + _bot.button(BTN_APPLY).click(); + _bot.button(BTN_TEST_CONNECTION).click(); + + // Wait for error response + _bot.sleep(5000); // Simulating waiting time for the response + + // Validate error message + assertFalse(ASSERT_CONNECTION_FAILED, + _bot.text(3).getText().contains("Successfully authenticated")); + + _bot.button(BTN_APPLY_AND_CLOSE).click(); } @Test - public void testInvalidKey() throws TimeoutException { - try { - preventWidgetWasNullInCIEnvironment(); - - _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); - _bot.shell(ITEM_PREFERENCES).activate(); - _bot.tree().select(ITEM_CHECKMARX_AST); - - // Test invalid key - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText("invalid-key"); - _bot.button(BTN_APPLY).click(); - _bot.button(BTN_TEST_CONNECTION).click(); - - _bot.sleep(5000); - - assertFalse("Connection should fail with invalid key", - _bot.text(3).getText().contains("Successfully authenticated")); - - } finally { - // Restore valid API key for next tests - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(Environment.API_KEY); - _bot.button(BTN_APPLY).click(); - _bot.button(BTN_TEST_CONNECTION).click(); - waitForConnectionResponse(); - _bot.button(BTN_APPLY_AND_CLOSE).click(); - _cxSettingsDefined = true; // Make sure flag is set for next tests - } + public void testApiKeyFieldNotEmpty() { + preventWidgetWasNullInCIEnvironment(); + + // Open Preferences + _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); + _bot.shell(ITEM_PREFERENCES).activate(); + _bot.tree().select(ITEM_CHECKMARX_AST); + + // Set API Key + String apiKey = "dummy-api-key"; + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(apiKey); + _bot.button(BTN_APPLY).click(); + + // Validate the API Key field is not empty + String currentKey = _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).getText(); + assertEquals(ASSERT_API_KEY_EMPTY, apiKey, currentKey); + + _bot.button(BTN_APPLY_AND_CLOSE).click(); } -} \ No newline at end of file +} From df938ca96eccf23ef0244eda486b39efdf74aed6 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Tue, 21 Jan 2025 16:09:34 +0200 Subject: [PATCH 08/13] Update TestPreferences.java --- .../plugin/tests/ui/TestPreferences.java | 84 ++++++++----------- 1 file changed, 33 insertions(+), 51 deletions(-) diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java index ee17e913..78e22b37 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java @@ -1,8 +1,7 @@ package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import java.util.concurrent.TimeoutException; @@ -13,78 +12,61 @@ import com.checkmarx.eclipse.utils.PluginConstants; @RunWith(SWTBotJunit4ClassRunner.class) -public class TestPreferences extends BaseUITest { - - private static final String ASSERT_API_KEY_EMPTY = "API Key field must not be empty after setting"; - private static final String ASSERT_CONNECTION_FAILED = "Connection should fail with an invalid API key"; - private static final String ASSERT_CONNECTION_SUCCESS = "Connection should succeed with a valid API key"; +public class ApiKeyTest extends BaseUITest { @Test public void testValidApiKeyConnection() throws TimeoutException { - preventWidgetWasNullInCIEnvironment(); - - // Open Preferences + // Open the Preferences window _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); _bot.shell(ITEM_PREFERENCES).activate(); _bot.tree().select(ITEM_CHECKMARX_AST); - - // Set valid API key - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(Environment.API_KEY); + + // Enter a valid API Key + String validApiKey = "your-valid-api-key"; // Replace with a valid API key + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(validApiKey); _bot.button(BTN_APPLY).click(); _bot.button(BTN_TEST_CONNECTION).click(); - - // Wait for successful connection message + + // Wait for a response waitForConnectionResponse(); - - // Validate success message - assertTrue(ASSERT_CONNECTION_SUCCESS, + + // Validate: the connection should succeed + assertTrue("Connection should succeed with a valid API key", _bot.text(3).getText().contains("Successfully authenticated")); - + + // Close the Preferences window _bot.button(BTN_APPLY_AND_CLOSE).click(); } @Test public void testInvalidApiKeyConnection() throws TimeoutException { - preventWidgetWasNullInCIEnvironment(); - - // Open Preferences + // Open the Preferences window _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); _bot.shell(ITEM_PREFERENCES).activate(); _bot.tree().select(ITEM_CHECKMARX_AST); - - // Set invalid API key - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText("invalid-key"); + + // Enter an invalid API Key + String invalidApiKey = "invalid-api-key"; + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(invalidApiKey); _bot.button(BTN_APPLY).click(); _bot.button(BTN_TEST_CONNECTION).click(); - - // Wait for error response - _bot.sleep(5000); // Simulating waiting time for the response - - // Validate error message - assertFalse(ASSERT_CONNECTION_FAILED, + + // Wait for a response + waitForConnectionResponse(); + + // Validate: the connection should fail + assertFalse("Connection should fail with an invalid API key", _bot.text(3).getText().contains("Successfully authenticated")); - + + // Close the Preferences window _bot.button(BTN_APPLY_AND_CLOSE).click(); } - @Test - public void testApiKeyFieldNotEmpty() { - preventWidgetWasNullInCIEnvironment(); - - // Open Preferences - _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); - _bot.shell(ITEM_PREFERENCES).activate(); - _bot.tree().select(ITEM_CHECKMARX_AST); - - // Set API Key - String apiKey = "dummy-api-key"; - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(apiKey); - _bot.button(BTN_APPLY).click(); - - // Validate the API Key field is not empty - String currentKey = _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).getText(); - assertEquals(ASSERT_API_KEY_EMPTY, apiKey, currentKey); - - _bot.button(BTN_APPLY_AND_CLOSE).click(); + private void waitForConnectionResponse() throws TimeoutException { + int retryIdx = 0; + while (!_bot.text(3).getText().contains("Successfully authenticated") && + retryIdx++ < 10) { + _bot.sleep(1000); // Wait for a short interval + } } } From ee127579bae26641b77173f56af0068f7732e398 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Tue, 21 Jan 2025 16:10:40 +0200 Subject: [PATCH 09/13] Update TestPreferences.java --- .../plugin/tests/ui/TestPreferences.java | 96 ++++++++++++++----- 1 file changed, 74 insertions(+), 22 deletions(-) diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java index 78e22b37..0fee8a67 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java @@ -1,72 +1,124 @@ package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; import java.util.concurrent.TimeoutException; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; import org.junit.Test; import org.junit.runner.RunWith; import com.checkmarx.eclipse.utils.PluginConstants; +import checkmarx.ast.eclipse.plugin.tests.common.Environment; + @RunWith(SWTBotJunit4ClassRunner.class) -public class ApiKeyTest extends BaseUITest { +public class TestPreferences extends BaseUITest { + + private static final String ASSERT_API_KEY_EMPTY = "API Key field must not be empty after setting"; + private static final String ASSERT_CONNECTION_FAILED = "Connection should fail with an invalid API key"; + private static final String ASSERT_CONNECTION_SUCCESS = "Connection should succeed with a valid API key"; @Test public void testValidApiKeyConnection() throws TimeoutException { - // Open the Preferences window + preventWidgetWasNullInCIEnvironment(); + + // Open Preferences _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); _bot.shell(ITEM_PREFERENCES).activate(); _bot.tree().select(ITEM_CHECKMARX_AST); - // Enter a valid API Key - String validApiKey = "your-valid-api-key"; // Replace with a valid API key - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(validApiKey); + // Set valid API key + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(Environment.API_KEY); _bot.button(BTN_APPLY).click(); _bot.button(BTN_TEST_CONNECTION).click(); - // Wait for a response + // Wait for successful connection message waitForConnectionResponse(); - // Validate: the connection should succeed - assertTrue("Connection should succeed with a valid API key", + // Validate success message + assertTrue(ASSERT_CONNECTION_SUCCESS, _bot.text(3).getText().contains("Successfully authenticated")); - // Close the Preferences window _bot.button(BTN_APPLY_AND_CLOSE).click(); } @Test public void testInvalidApiKeyConnection() throws TimeoutException { - // Open the Preferences window + preventWidgetWasNullInCIEnvironment(); + + // Open Preferences _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); _bot.shell(ITEM_PREFERENCES).activate(); _bot.tree().select(ITEM_CHECKMARX_AST); - // Enter an invalid API Key - String invalidApiKey = "invalid-api-key"; - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(invalidApiKey); + // Set invalid API key + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText("invalid-key"); _bot.button(BTN_APPLY).click(); _bot.button(BTN_TEST_CONNECTION).click(); - // Wait for a response - waitForConnectionResponse(); + // Wait for error response + SWTBotPreferences.TIMEOUT = 5000; // Adjusted timeout + _bot.sleep(5000); // Simulating waiting time for the response - // Validate: the connection should fail - assertFalse("Connection should fail with an invalid API key", + // Validate error message + assertFalse(ASSERT_CONNECTION_FAILED, _bot.text(3).getText().contains("Successfully authenticated")); - // Close the Preferences window + _bot.button(BTN_APPLY_AND_CLOSE).click(); + } + + @Test + public void testApiKeyFieldNotEmpty() { + preventWidgetWasNullInCIEnvironment(); + + // Open Preferences + _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); + _bot.shell(ITEM_PREFERENCES).activate(); + _bot.tree().select(ITEM_CHECKMARX_AST); + + // Set API Key + String apiKey = "dummy-api-key"; + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(apiKey); + _bot.button(BTN_APPLY).click(); + + // Validate the API Key field is not empty + String currentKey = _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).getText(); + assertEquals(ASSERT_API_KEY_EMPTY, apiKey, currentKey); + + _bot.button(BTN_APPLY_AND_CLOSE).click(); + } + + @Test + public void testEmptyApiKeyFieldAfterClear() { + preventWidgetWasNullInCIEnvironment(); + + // Open Preferences + _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); + _bot.shell(ITEM_PREFERENCES).activate(); + _bot.tree().select(ITEM_CHECKMARX_AST); + + // Clear API Key + _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(""); + _bot.button(BTN_APPLY).click(); + + // Validate the API Key field is empty + String currentKey = _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).getText(); + assertEquals("API Key field should be empty after clearing", "", currentKey); + _bot.button(BTN_APPLY_AND_CLOSE).click(); } private void waitForConnectionResponse() throws TimeoutException { int retryIdx = 0; - while (!_bot.text(3).getText().contains("Successfully authenticated") && - retryIdx++ < 10) { - _bot.sleep(1000); // Wait for a short interval + while (!_bot.text(3).getText().contains("Successfully authenticated")) { + if (retryIdx++ == 10) { + throw new TimeoutException("Connection validation timeout after 10000ms."); + } + _bot.sleep(1000); } } } From b7f56e8553e1a30016886918c09731a777a110c9 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Wed, 22 Jan 2025 10:38:16 +0200 Subject: [PATCH 10/13] v4 --- .../ui/TestProjectAndBranchSelection.java | 88 +++++++++++++++++ .../plugin/tests/ui/TestResultDetails.java | 74 ++++++++++++++ .../plugin/tests/ui/TestResultNavigation.java | 78 +++++++++++++++ .../plugin/tests/ui/TestResultsFiltering.java | 66 +++++++++++++ .../plugin/tests/ui/TestResultsSorting.java | 99 +++++++++++++++++++ .../plugin/tests/ui/TestToolbarActions.java | 70 +++++++++++++ checkmarx-ast-eclipse-plugin/.project | 11 +++ com.checkmarx.eclipse.feature/.project | 11 +++ com.checkmarx.eclipse.site/.project | 11 +++ 9 files changed, 508 insertions(+) create mode 100644 checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestProjectAndBranchSelection.java create mode 100644 checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultDetails.java create mode 100644 checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultNavigation.java create mode 100644 checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsFiltering.java create mode 100644 checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java create mode 100644 checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestToolbarActions.java diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestProjectAndBranchSelection.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestProjectAndBranchSelection.java new file mode 100644 index 00000000..4b862bc2 --- /dev/null +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestProjectAndBranchSelection.java @@ -0,0 +1,88 @@ +package checkmarx.ast.eclipse.plugin.tests.ui; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.concurrent.TimeoutException; + +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.checkmarx.eclipse.utils.PluginConstants; + +@RunWith(SWTBotJunit4ClassRunner.class) +public class TestProjectAndBranchSelection extends BaseUITest { + + private static final String ASSERT_PROJECT_COMBO_ENABLED = "Project combo should be enabled after authentication"; + private static final String ASSERT_BRANCH_COMBO_DISABLED = "Branch combo should be disabled before project selection"; + private static final String ASSERT_BRANCH_COMBO_ENABLED = "Branch combo should be enabled after project selection"; + private static final String ASSERT_PROJECT_SELECTED = "Selected project should match the expected value"; + private static final String ASSERT_BRANCH_SELECTED = "Selected branch should match the expected value"; + + @Test + public void testProjectAndBranchSelectionFlow() throws TimeoutException { + // Set up plugin with authentication + testSuccessfulConnection(false); + addCheckmarxPlugin(true); + + // Get combo boxes + SWTBotCombo projectCombo = _bot.comboBox(0); + SWTBotCombo branchCombo = _bot.comboBox(1); + + // Verify initial state + assertTrue(ASSERT_PROJECT_COMBO_ENABLED, projectCombo.isEnabled()); + assertFalse(ASSERT_BRANCH_COMBO_DISABLED, branchCombo.isEnabled()); + + // Select first project + projectCombo.setSelection(0); + sleep(2000); + + // Verify branch combo is enabled after project selection + assertTrue(ASSERT_BRANCH_COMBO_ENABLED, branchCombo.isEnabled()); + + // Select first branch + branchCombo.setSelection(0); + sleep(1000); + + // Verify selections + String selectedProject = projectCombo.getText(); + String selectedBranch = branchCombo.getText(); + + assertFalse("Project selection should not be empty", selectedProject.isEmpty()); + assertFalse("Branch selection should not be empty", selectedBranch.isEmpty()); + + // Clear project selection + projectCombo.setText(""); + sleep(1000); + + // Verify branch combo is disabled again + assertFalse(ASSERT_BRANCH_COMBO_DISABLED, branchCombo.isEnabled()); + + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } + + @Test + public void testProjectSearch() throws TimeoutException { + testSuccessfulConnection(false); + addCheckmarxPlugin(true); + + SWTBotCombo projectCombo = _bot.comboBox(0); + + // Type partial project name + String partialName = "test"; + projectCombo.setText(partialName); + sleep(2000); + + // Verify filtered results + String[] items = projectCombo.items(); + for (String item : items) { + assertTrue("Filtered items should contain search text", + item.toLowerCase().contains(partialName.toLowerCase())); + } + + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } +} \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultDetails.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultDetails.java new file mode 100644 index 00000000..377b7507 --- /dev/null +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultDetails.java @@ -0,0 +1,74 @@ +package checkmarx.ast.eclipse.plugin.tests.ui; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.concurrent.TimeoutException; + +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.checkmarx.eclipse.utils.PluginConstants; + +@RunWith(SWTBotJunit4ClassRunner.class) +public class TestResultDetails extends BaseUITest { + + private static final String ASSERT_DETAILS_VISIBLE = "Result details should be visible when result is selected"; + private static final String ASSERT_DETAILS_HIDDEN = "Result details should be hidden when no result is selected"; + private static final String ASSERT_DESCRIPTION_NOT_EMPTY = "Result description should not be empty"; + private static final String ASSERT_SEVERITY_NOT_EMPTY = "Severity field should not be empty"; + private static final String ASSERT_STATE_NOT_EMPTY = "State field should not be empty"; + + @Test + public void testResultDetailsVisibility() throws TimeoutException { + setUpCheckmarxPlugin(true); + + // Initially details should be hidden + assertFalse(ASSERT_DETAILS_HIDDEN, isDetailsVisible()); + + // Select first result + SWTBotTreeItem resultNode = getFirstResultNode(); + resultNode.select(); + sleep(1000); + + // Verify details are shown + assertTrue(ASSERT_DETAILS_VISIBLE, isDetailsVisible()); + + // Verify details content + assertTrue(ASSERT_DESCRIPTION_NOT_EMPTY, + !_bot.textWithId(PluginConstants.DESCRIPTION_TEXT_ID).getText().isEmpty()); + assertTrue(ASSERT_SEVERITY_NOT_EMPTY, + !_bot.comboBoxWithId(PluginConstants.TRIAGE_SEVERITY_COMBO_ID).getText().isEmpty()); + assertTrue(ASSERT_STATE_NOT_EMPTY, + !_bot.comboBoxWithId(PluginConstants.TRIAGE_STATE_COMBO_ID).getText().isEmpty()); + + // Deselect result + _bot.tree(1).select(); + sleep(1000); + + // Verify details are hidden again + assertFalse(ASSERT_DETAILS_HIDDEN, isDetailsVisible()); + + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } + + private boolean isDetailsVisible() { + try { + _bot.textWithId(PluginConstants.DESCRIPTION_TEXT_ID); + return true; + } catch (Exception e) { + return false; + } + } + + private SWTBotTreeItem getFirstResultNode() { + String firstNodeName = _bot.tree(1).cell(0, 0); + SWTBotTreeItem node = _bot.tree(1).getTreeItem(firstNodeName); + while(!node.getNodes().isEmpty()) { + node = node.expand().getNode(0); + } + return node; + } +} \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultNavigation.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultNavigation.java new file mode 100644 index 00000000..9dfcef10 --- /dev/null +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultNavigation.java @@ -0,0 +1,78 @@ +package checkmarx.ast.eclipse.plugin.tests.ui; + +import static org.junit.Assert.assertTrue; + +import java.util.concurrent.TimeoutException; + +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(SWTBotJunit4ClassRunner.class) +public class TestResultNavigation extends BaseUITest { + + private static final String ASSERT_EDITOR_OPENED = "Editor should open when double-clicking result"; + private static final String ASSERT_LINE_SELECTED = "Correct line should be selected in editor"; + + @Test + public void testDoubleClickNavigation() throws TimeoutException { + setUpCheckmarxPlugin(true); + + // Get first result node + SWTBotTreeItem resultNode = getFirstResultNode(); + + // Double click to open editor + resultNode.doubleClick(); + sleep(2000); + + // Verify editor opened with correct file + assertTrue(ASSERT_EDITOR_OPENED, + _bot.activeEditor() != null); + + // Verify line selection + assertTrue(ASSERT_LINE_SELECTED, + _bot.activeEditor().toTextEditor().getSelection().x > 0); + + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } + + @Test + public void testMultipleResultsNavigation() throws TimeoutException { + setUpCheckmarxPlugin(true); + + // Navigate through multiple results + SWTBotTreeItem firstNode = getFirstResultNode(); + firstNode.select(); + sleep(1000); + + // Get next result + SWTBotTreeItem nextNode = getNextResultNode(firstNode); + nextNode.select(); + sleep(1000); + + // Verify different selections + assertTrue("Different results should be selectable", + !firstNode.getText().equals(nextNode.getText())); + + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } + + private SWTBotTreeItem getFirstResultNode() { + String firstNodeName = _bot.tree(1).cell(0, 0); + SWTBotTreeItem node = _bot.tree(1).getTreeItem(firstNodeName); + while(!node.getNodes().isEmpty()) { + node = node.expand().getNode(0); + } + return node; + } + + private SWTBotTreeItem getNextResultNode(SWTBotTreeItem currentNode) { + SWTBotTreeItem parent = currentNode.parent(); + int currentIndex = parent.getNodes().indexOf(currentNode.getText()); + if (currentIndex < parent.getNodes().size() - 1) { + return parent.getNode(currentIndex + 1); + } + return parent.getNode(0); // Wrap around to first if at end + } +} \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsFiltering.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsFiltering.java new file mode 100644 index 00000000..c0757f4b --- /dev/null +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsFiltering.java @@ -0,0 +1,66 @@ +package checkmarx.ast.eclipse.plugin.tests.ui; + +import static org.junit.Assert.assertTrue; + +import java.util.concurrent.TimeoutException; + +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.checkmarx.eclipse.utils.PluginConstants; + +@RunWith(SWTBotJunit4ClassRunner.class) +public class TestResultsFiltering extends BaseUITest { + + private static final String ASSERT_FILTERED_RESULTS = "Results should be filtered according to search text"; + private static final String ASSERT_NO_RESULTS = "No results should be shown for invalid search"; + + @Test + public void testQueryNameFiltering() throws TimeoutException { + setUpCheckmarxPlugin(true); + + // Get the first query name + String firstNodeName = _bot.tree(1).cell(0, 0); + SWTBotTreeItem firstNode = _bot.tree(1).getTreeItem(firstNodeName); + String queryName = getFirstQueryName(firstNode); + + // Type partial query name in filter + SWTBotText filterText = _bot.textWithId(PluginConstants.FILTER_TEXT_ID); + filterText.setText(queryName.substring(0, 5)); + sleep(2000); + + // Verify filtered results + SWTBotTreeItem[] items = _bot.tree(1).getAllItems(); + for (SWTBotTreeItem item : items) { + String itemText = getAllNodeText(item); + assertTrue(ASSERT_FILTERED_RESULTS, + itemText.toLowerCase().contains(queryName.substring(0, 5).toLowerCase())); + } + + // Test invalid search + filterText.setText("INVALID_QUERY_NAME_XXX"); + sleep(2000); + + assertTrue(ASSERT_NO_RESULTS, _bot.tree(1).getAllItems().length <= 1); + + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } + + private String getFirstQueryName(SWTBotTreeItem node) { + while(!node.getNodes().isEmpty()) { + node = node.expand().getNode(0); + } + return node.getText(); + } + + private String getAllNodeText(SWTBotTreeItem item) { + StringBuilder text = new StringBuilder(item.getText()); + for (SWTBotTreeItem child : item.getItems()) { + text.append(" ").append(getAllNodeText(child)); + } + return text.toString(); + } +} \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java new file mode 100644 index 00000000..e38ad6da --- /dev/null +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java @@ -0,0 +1,99 @@ +package checkmarx.ast.eclipse.plugin.tests.ui; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeoutException; + +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.checkmarx.eclipse.utils.PluginConstants; + +@RunWith(SWTBotJunit4ClassRunner.class) +public class TestResultsSorting extends BaseUITest { + + private static final String ASSERT_SORTED_BY_SEVERITY = "Results should be sorted by severity"; + private static final String ASSERT_SORTED_BY_STATE = "Results should be sorted by state"; + + @Test + public void testSortBySeverity() throws TimeoutException { + setUpCheckmarxPlugin(true); + + // Enable severity grouping + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.MENU_GROUP_BY) + .menu(PluginConstants.GROUP_BY_SEVERITY).click(); + + sleep(2000); + + // Get all severity groups + List severityGroups = getSeverityGroups(); + + // Verify order: High -> Medium -> Low -> Info + assertTrue(ASSERT_SORTED_BY_SEVERITY, + isSortedBySeverity(severityGroups)); + + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } + + @Test + public void testSortByState() throws TimeoutException { + setUpCheckmarxPlugin(true); + + // Enable state grouping + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.MENU_GROUP_BY) + .menu(PluginConstants.GROUP_BY_STATE_NAME).click(); + + sleep(2000); + + // Get all state groups + List stateGroups = getStateGroups(); + + // Verify order is alphabetical + assertTrue(ASSERT_SORTED_BY_STATE, + isAlphabeticallySorted(stateGroups)); + + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } + + private List getSeverityGroups() { + List groups = new ArrayList<>(); + SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; + for (SWTBotTreeItem item : root.getItems()) { + groups.add(item.getText().split("\\(")[0].trim()); + } + return groups; + } + + private List getStateGroups() { + List groups = new ArrayList<>(); + SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; + for (SWTBotTreeItem item : root.getItems()) { + groups.add(item.getText().split("\\(")[0].trim()); + } + return groups; + } + + private boolean isSortedBySeverity(List groups) { + int highIndex = groups.indexOf("HIGH"); + int mediumIndex = groups.indexOf("MEDIUM"); + int lowIndex = groups.indexOf("LOW"); + int infoIndex = groups.indexOf("INFO"); + + return highIndex < mediumIndex && + mediumIndex < lowIndex && + lowIndex < infoIndex; + } + + private boolean isAlphabeticallySorted(List groups) { + for (int i = 0; i < groups.size() - 1; i++) { + if (groups.get(i).compareTo(groups.get(i + 1)) > 0) { + return false; + } + } + return true; + } +} \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestToolbarActions.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestToolbarActions.java new file mode 100644 index 00000000..05358b38 --- /dev/null +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestToolbarActions.java @@ -0,0 +1,70 @@ +package checkmarx.ast.eclipse.plugin.tests.ui; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.concurrent.TimeoutException; + +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.checkmarx.eclipse.utils.PluginConstants; + +@RunWith(SWTBotJunit4ClassRunner.class) +public class TestToolbarActions extends BaseUITest { + + private static final String ASSERT_REFRESH_ENABLED = "Refresh button should be enabled"; + private static final String ASSERT_CLEAR_ENABLED = "Clear button should be enabled"; + private static final String ASSERT_TREE_CLEARED = "Tree should be cleared after clear action"; + private static final String ASSERT_RESULTS_REFRESHED = "Results should be updated after refresh"; + + @Test + public void testRefreshAction() throws TimeoutException { + setUpCheckmarxPlugin(true); + + // Get initial results count + String initialResults = _bot.tree(1).cell(0, 0); + + // Click refresh + SWTBotToolbarButton refreshBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN) + .getToolbarButtons().stream() + .filter(btn -> btn.getToolTipText().equals(PluginConstants.TOOLBAR_ACTION_REFRESH)) + .findFirst().get(); + + assertTrue(ASSERT_REFRESH_ENABLED, refreshBtn.isEnabled()); + refreshBtn.click(); + + sleep(2000); + + // Verify results are refreshed + String refreshedResults = _bot.tree(1).cell(0, 0); + assertTrue(ASSERT_RESULTS_REFRESHED, + !refreshedResults.equals(PluginConstants.RETRIEVING_RESULTS_FOR_SCAN)); + + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } + + @Test + public void testClearAction() throws TimeoutException { + setUpCheckmarxPlugin(true); + + // Click clear results + SWTBotToolbarButton clearBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN) + .getToolbarButtons().stream() + .filter(btn -> btn.getToolTipText().equals(PluginConstants.TOOLBAR_ACTION_CLEAR_RESULTS)) + .findFirst().get(); + + assertTrue(ASSERT_CLEAR_ENABLED, clearBtn.isEnabled()); + clearBtn.click(); + + sleep(1000); + + // Verify tree is cleared + assertTrue(ASSERT_TREE_CLEARED, + _bot.tree(1).getAllItems().length == 0); + + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } +} \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin/.project b/checkmarx-ast-eclipse-plugin/.project index 4671abdb..9ab7822d 100644 --- a/checkmarx-ast-eclipse-plugin/.project +++ b/checkmarx-ast-eclipse-plugin/.project @@ -31,4 +31,15 @@ org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + + + 1737534235229 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/com.checkmarx.eclipse.feature/.project b/com.checkmarx.eclipse.feature/.project index 81e01a64..cd934f0c 100644 --- a/com.checkmarx.eclipse.feature/.project +++ b/com.checkmarx.eclipse.feature/.project @@ -20,4 +20,15 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.pde.FeatureNature + + + 1737534235228 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/com.checkmarx.eclipse.site/.project b/com.checkmarx.eclipse.site/.project index 4beee618..b180d71e 100644 --- a/com.checkmarx.eclipse.site/.project +++ b/com.checkmarx.eclipse.site/.project @@ -20,4 +20,15 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.pde.UpdateSiteNature + + + 1737534235229 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + From 12364fa860d67687d957720b0ccb3df57ebd499f Mon Sep 17 00:00:00 2001 From: elchananarb Date: Wed, 22 Jan 2025 11:22:46 +0200 Subject: [PATCH 11/13] del most --- .../plugin/tests/ui/BestFixLocationTest.java | 58 +- .../plugin/tests/ui/TestFilterState.java | 222 ++++---- .../plugin/tests/ui/TestPreferences.java | 124 ----- .../ui/TestProjectAndBranchSelection.java | 136 ++--- .../plugin/tests/ui/TestResultDetails.java | 148 +++--- .../plugin/tests/ui/TestResultNavigation.java | 140 ++--- .../plugin/tests/ui/TestResultsFiltering.java | 102 ++-- .../plugin/tests/ui/TestResultsSorting.java | 198 +++---- .../ast/eclipse/plugin/tests/ui/TestScan.java | 232 ++++---- .../plugin/tests/ui/TestToolbarActions.java | 102 ++-- .../ast/eclipse/plugin/tests/ui/TestUI.java | 496 +++++++++--------- 11 files changed, 917 insertions(+), 1041 deletions(-) delete mode 100644 checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/BestFixLocationTest.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/BestFixLocationTest.java index 8a5d72ee..2ab8b200 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/BestFixLocationTest.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/BestFixLocationTest.java @@ -1,37 +1,37 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; +// package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.assertTrue; +// import static org.junit.Assert.assertTrue; -import java.util.concurrent.TimeoutException; +// import java.util.concurrent.TimeoutException; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.junit.Test; -import org.junit.runner.RunWith; +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +// import org.junit.Test; +// import org.junit.runner.RunWith; -import com.checkmarx.eclipse.utils.PluginConstants; +// import com.checkmarx.eclipse.utils.PluginConstants; -//@RunWith(SWTBotJunit4ClassRunner.class) -public class BestFixLocationTest extends BaseUITest{ +// //@RunWith(SWTBotJunit4ClassRunner.class) +// public class BestFixLocationTest extends BaseUITest{ - //@Test - public void testBestFixLocation() throws TimeoutException { -// setUpCheckmarxPlugin(true); -// SWTBotTreeItem firstNode = getFirstResultNode(); -// firstNode.select(); -// sleep(3000); -// String BFLText = _bot.textWithId(PluginConstants.BEST_FIX_LOCATION).getText(); -// assertTrue(BFLText.equals(PluginConstants.BFL_FOUND) || BFLText.equals(PluginConstants.BFL_NOT_FOUND)); -// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// //@Test +// public void testBestFixLocation() throws TimeoutException { +// // setUpCheckmarxPlugin(true); +// // SWTBotTreeItem firstNode = getFirstResultNode(); +// // firstNode.select(); +// // sleep(3000); +// // String BFLText = _bot.textWithId(PluginConstants.BEST_FIX_LOCATION).getText(); +// // assertTrue(BFLText.equals(PluginConstants.BFL_FOUND) || BFLText.equals(PluginConstants.BFL_NOT_FOUND)); +// // _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - private SWTBotTreeItem getFirstResultNode() { - String firstNodeName = _bot.tree().cell(0, 0); - SWTBotTreeItem node = _bot.tree().getTreeItem(firstNodeName); - while(!node.getNodes().isEmpty()) { - node = node.expand().getNode(0); - } - return node; - } -} +// private SWTBotTreeItem getFirstResultNode() { +// String firstNodeName = _bot.tree().cell(0, 0); +// SWTBotTreeItem node = _bot.tree().getTreeItem(firstNodeName); +// while(!node.getNodes().isEmpty()) { +// node = node.expand().getNode(0); +// } +// return node; +// } +// } diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestFilterState.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestFilterState.java index b4fba23c..262d2c86 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestFilterState.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestFilterState.java @@ -1,140 +1,140 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; +// package checkmarx.ast.eclipse.plugin.tests.ui; -import org.eclipse.jface.bindings.keys.KeyStroke; -import org.eclipse.jface.bindings.keys.ParseException; +// import org.eclipse.jface.bindings.keys.KeyStroke; +// import org.eclipse.jface.bindings.keys.ParseException; -import static org.junit.Assert.assertTrue; +// import static org.junit.Assert.assertTrue; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.TimeoutException; -import java.util.stream.Collectors; +// import java.util.ArrayList; +// import java.util.Arrays; +// import java.util.List; +// import java.util.concurrent.TimeoutException; +// import java.util.stream.Collectors; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.junit.Test; -import org.junit.runner.RunWith; +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +// import org.junit.Test; +// import org.junit.runner.RunWith; -import com.checkmarx.eclipse.enums.Severity; -import com.checkmarx.eclipse.enums.State; -import com.checkmarx.eclipse.views.actions.ToolBarActions; +// import com.checkmarx.eclipse.enums.Severity; +// import com.checkmarx.eclipse.enums.State; +// import com.checkmarx.eclipse.views.actions.ToolBarActions; -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestFilterState extends BaseUITest{ +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestFilterState extends BaseUITest{ - List groupByActions = Arrays.asList(ToolBarActions.GROUP_BY_QUERY_NAME,ToolBarActions.GROUP_BY_SEVERITY,ToolBarActions.GROUP_BY_STATE_NAME); +// List groupByActions = Arrays.asList(ToolBarActions.GROUP_BY_QUERY_NAME,ToolBarActions.GROUP_BY_SEVERITY,ToolBarActions.GROUP_BY_STATE_NAME); - @Test - public void testGroupByActionsInToolBar() throws TimeoutException { - int SECOND_NODE = 2; - int THIRD_NODE = 3; - int FOURTH_NODE = 4; +// @Test +// public void testGroupByActionsInToolBar() throws TimeoutException { +// int SECOND_NODE = 2; +// int THIRD_NODE = 3; +// int FOURTH_NODE = 4; - setUpCheckmarxPlugin(true); +// setUpCheckmarxPlugin(true); - // remove all groups and get the first individual node - disableAllGroupByActions(groupByActions); +// // remove all groups and get the first individual node +// disableAllGroupByActions(groupByActions); - sleep(1000); +// sleep(1000); - SWTBotTreeItem ll = getFirstResultNode(); - ArrayList severityFilters = new ArrayList<>(Arrays.asList(Severity.HIGH.name(), Severity.MEDIUM.name(),Severity.LOW.name(),Severity.INFO.name())); - ArrayList stateFilters = new ArrayList<>(Arrays.asList(State.CONFIRMED.name(),State.IGNORED.name(),State.NOT_EXPLOITABLE.name(),State.NOT_IGNORED.name(),State.PROPOSED_NOT_EXPLOITABLE.name(),State.TO_VERIFY.name(),State.URGENT.name())); - assertTrue(!severityFilters.contains(ll.getText())); +// SWTBotTreeItem ll = getFirstResultNode(); +// ArrayList severityFilters = new ArrayList<>(Arrays.asList(Severity.HIGH.name(), Severity.MEDIUM.name(),Severity.LOW.name(),Severity.INFO.name())); +// ArrayList stateFilters = new ArrayList<>(Arrays.asList(State.CONFIRMED.name(),State.IGNORED.name(),State.NOT_EXPLOITABLE.name(),State.NOT_IGNORED.name(),State.PROPOSED_NOT_EXPLOITABLE.name(),State.TO_VERIFY.name(),State.URGENT.name())); +// assertTrue(!severityFilters.contains(ll.getText())); - //enable group by severity (1st level group) - enableGroup(ToolBarActions.GROUP_BY_SEVERITY); - sleep(1000); - String severityFilter = getNodeLabel(SECOND_NODE); - assertTrue(severityFilters.contains(severityFilter)); +// //enable group by severity (1st level group) +// enableGroup(ToolBarActions.GROUP_BY_SEVERITY); +// sleep(1000); +// String severityFilter = getNodeLabel(SECOND_NODE); +// assertTrue(severityFilters.contains(severityFilter)); - // enable group by state (2nd level group) - enableGroup(ToolBarActions.GROUP_BY_STATE_NAME); - sleep(1000); - String stateFilter = getNodeLabel(THIRD_NODE); - assertTrue(stateFilters.contains(stateFilter)); +// // enable group by state (2nd level group) +// enableGroup(ToolBarActions.GROUP_BY_STATE_NAME); +// sleep(1000); +// String stateFilter = getNodeLabel(THIRD_NODE); +// assertTrue(stateFilters.contains(stateFilter)); - // enable group by query name (3rd level group) - enableGroup(ToolBarActions.GROUP_BY_QUERY_NAME); - sleep(1000); - String queryNameFilter = getNodeLabel(FOURTH_NODE); - assertTrue(queryNameFilter.startsWith(ll.getText())); +// // enable group by query name (3rd level group) +// enableGroup(ToolBarActions.GROUP_BY_QUERY_NAME); +// sleep(1000); +// String queryNameFilter = getNodeLabel(FOURTH_NODE); +// assertTrue(queryNameFilter.startsWith(ll.getText())); - // Close Checkmarx One Scan view - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// // Close Checkmarx One Scan view +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - private String getNodeLabel(int i) { - SWTBotTreeItem treeNode = _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)); - String value = ""; - while(i>0) { - treeNode = treeNode.expand().getNode(0); - i--; - } - value= treeNode.getText().split("\\(")[0].trim(); - return value; - } +// private String getNodeLabel(int i) { +// SWTBotTreeItem treeNode = _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)); +// String value = ""; +// while(i>0) { +// treeNode = treeNode.expand().getNode(0); +// i--; +// } +// value= treeNode.getText().split("\\(")[0].trim(); +// return value; +// } - private void enableGroup(String groupBy) { - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(groupBy).click(); - } +// private void enableGroup(String groupBy) { +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(groupBy).click(); +// } - private void disableAllGroupByActions(List groupByActions) { - for(String action : groupByActions) { - SWTBotMenu groupMenu = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(action); - if(groupMenu.isChecked()) - groupMenu.click(); - } +// private void disableAllGroupByActions(List groupByActions) { +// for(String action : groupByActions) { +// SWTBotMenu groupMenu = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(action); +// if(groupMenu.isChecked()) +// groupMenu.click(); +// } - } +// } - @Test - public void testFilterStateActionsInToolBar() throws TimeoutException, ParseException{ - sleep(1000); - setUpCheckmarxPlugin(true); +// @Test +// public void testFilterStateActionsInToolBar() throws TimeoutException, ParseException{ +// sleep(1000); +// setUpCheckmarxPlugin(true); - // deselect all group by actions and enable only the state group by - disableAllGroupByActions(groupByActions); +// // deselect all group by actions and enable only the state group by +// disableAllGroupByActions(groupByActions); - sleep(1000); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_STATE_NAME).click(); +// sleep(1000); +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_STATE_NAME).click(); - // get all filter nodes - List filterStateButtons = Arrays.asList("Not Exploitable","Confirmed","Proposed Not Exploitable","Urgent","Ignored","Not Ignored","To Verify"); - List enabledFilters = _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNode(0).expand().getNodes().stream().map(node -> node.split("\\(")[0].trim()).collect(Collectors.toList()); - String firstGroup = enabledFilters.get(0); - List filterButton = filterStateButtons.stream().filter(node -> node.equalsIgnoreCase(firstGroup.replace("_", " "))).collect(Collectors.toList()); - assertTrue(filterButton.size()==1); - SWTBotToolbarDropDownButton stateFilter = _bot.toolbarDropDownButtonWithTooltip("State"); - final SWTBotMenu menuItem = stateFilter.menuItem(filterButton.get(0)); - menuItem.setFocus(); - menuItem.click(); - stateFilter.pressShortcut(KeyStroke.getInstance("ESC")); +// // get all filter nodes +// List filterStateButtons = Arrays.asList("Not Exploitable","Confirmed","Proposed Not Exploitable","Urgent","Ignored","Not Ignored","To Verify"); +// List enabledFilters = _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNode(0).expand().getNodes().stream().map(node -> node.split("\\(")[0].trim()).collect(Collectors.toList()); +// String firstGroup = enabledFilters.get(0); +// List filterButton = filterStateButtons.stream().filter(node -> node.equalsIgnoreCase(firstGroup.replace("_", " "))).collect(Collectors.toList()); +// assertTrue(filterButton.size()==1); +// SWTBotToolbarDropDownButton stateFilter = _bot.toolbarDropDownButtonWithTooltip("State"); +// final SWTBotMenu menuItem = stateFilter.menuItem(filterButton.get(0)); +// menuItem.setFocus(); +// menuItem.click(); +// stateFilter.pressShortcut(KeyStroke.getInstance("ESC")); - sleep(1000); - List filteredGroup = new ArrayList(); - if(enabledFilters.size()>0) { - filteredGroup = _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNode(0).expand().getNodes().stream().map(node -> node.split("\\(")[0].trim()).collect(Collectors.toList()); - assertTrue(!filteredGroup.contains(firstGroup)); - } - else { - assertTrue(TestUI.ASSERT_NO_CHINDREN, _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNodes().isEmpty()); - } +// sleep(1000); +// List filteredGroup = new ArrayList(); +// if(enabledFilters.size()>0) { +// filteredGroup = _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNode(0).expand().getNodes().stream().map(node -> node.split("\\(")[0].trim()).collect(Collectors.toList()); +// assertTrue(!filteredGroup.contains(firstGroup)); +// } +// else { +// assertTrue(TestUI.ASSERT_NO_CHINDREN, _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNodes().isEmpty()); +// } - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// } - private SWTBotTreeItem getFirstResultNode() { - String firstNodeName = _bot.tree(1).cell(0, 0); - SWTBotTreeItem node = _bot.tree(1).getTreeItem(firstNodeName); - while(!node.getNodes().isEmpty()) { - node = node.expand().getNode(0); - } - return node; - } -} +// private SWTBotTreeItem getFirstResultNode() { +// String firstNodeName = _bot.tree(1).cell(0, 0); +// SWTBotTreeItem node = _bot.tree(1).getTreeItem(firstNodeName); +// while(!node.getNodes().isEmpty()) { +// node = node.expand().getNode(0); +// } +// return node; +// } +// } diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java deleted file mode 100644 index 0fee8a67..00000000 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestPreferences.java +++ /dev/null @@ -1,124 +0,0 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; - -import java.util.concurrent.TimeoutException; - -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.checkmarx.eclipse.utils.PluginConstants; - -import checkmarx.ast.eclipse.plugin.tests.common.Environment; - -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestPreferences extends BaseUITest { - - private static final String ASSERT_API_KEY_EMPTY = "API Key field must not be empty after setting"; - private static final String ASSERT_CONNECTION_FAILED = "Connection should fail with an invalid API key"; - private static final String ASSERT_CONNECTION_SUCCESS = "Connection should succeed with a valid API key"; - - @Test - public void testValidApiKeyConnection() throws TimeoutException { - preventWidgetWasNullInCIEnvironment(); - - // Open Preferences - _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); - _bot.shell(ITEM_PREFERENCES).activate(); - _bot.tree().select(ITEM_CHECKMARX_AST); - - // Set valid API key - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(Environment.API_KEY); - _bot.button(BTN_APPLY).click(); - _bot.button(BTN_TEST_CONNECTION).click(); - - // Wait for successful connection message - waitForConnectionResponse(); - - // Validate success message - assertTrue(ASSERT_CONNECTION_SUCCESS, - _bot.text(3).getText().contains("Successfully authenticated")); - - _bot.button(BTN_APPLY_AND_CLOSE).click(); - } - - @Test - public void testInvalidApiKeyConnection() throws TimeoutException { - preventWidgetWasNullInCIEnvironment(); - - // Open Preferences - _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); - _bot.shell(ITEM_PREFERENCES).activate(); - _bot.tree().select(ITEM_CHECKMARX_AST); - - // Set invalid API key - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText("invalid-key"); - _bot.button(BTN_APPLY).click(); - _bot.button(BTN_TEST_CONNECTION).click(); - - // Wait for error response - SWTBotPreferences.TIMEOUT = 5000; // Adjusted timeout - _bot.sleep(5000); // Simulating waiting time for the response - - // Validate error message - assertFalse(ASSERT_CONNECTION_FAILED, - _bot.text(3).getText().contains("Successfully authenticated")); - - _bot.button(BTN_APPLY_AND_CLOSE).click(); - } - - @Test - public void testApiKeyFieldNotEmpty() { - preventWidgetWasNullInCIEnvironment(); - - // Open Preferences - _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); - _bot.shell(ITEM_PREFERENCES).activate(); - _bot.tree().select(ITEM_CHECKMARX_AST); - - // Set API Key - String apiKey = "dummy-api-key"; - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(apiKey); - _bot.button(BTN_APPLY).click(); - - // Validate the API Key field is not empty - String currentKey = _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).getText(); - assertEquals(ASSERT_API_KEY_EMPTY, apiKey, currentKey); - - _bot.button(BTN_APPLY_AND_CLOSE).click(); - } - - @Test - public void testEmptyApiKeyFieldAfterClear() { - preventWidgetWasNullInCIEnvironment(); - - // Open Preferences - _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); - _bot.shell(ITEM_PREFERENCES).activate(); - _bot.tree().select(ITEM_CHECKMARX_AST); - - // Clear API Key - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(""); - _bot.button(BTN_APPLY).click(); - - // Validate the API Key field is empty - String currentKey = _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).getText(); - assertEquals("API Key field should be empty after clearing", "", currentKey); - - _bot.button(BTN_APPLY_AND_CLOSE).click(); - } - - private void waitForConnectionResponse() throws TimeoutException { - int retryIdx = 0; - while (!_bot.text(3).getText().contains("Successfully authenticated")) { - if (retryIdx++ == 10) { - throw new TimeoutException("Connection validation timeout after 10000ms."); - } - _bot.sleep(1000); - } - } -} diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestProjectAndBranchSelection.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestProjectAndBranchSelection.java index 4b862bc2..eb9448d9 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestProjectAndBranchSelection.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestProjectAndBranchSelection.java @@ -1,88 +1,88 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; +// package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +// import static org.junit.Assert.assertEquals; +// import static org.junit.Assert.assertFalse; +// import static org.junit.Assert.assertTrue; -import java.util.concurrent.TimeoutException; +// import java.util.concurrent.TimeoutException; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; -import org.junit.Test; -import org.junit.runner.RunWith; +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; +// import org.junit.Test; +// import org.junit.runner.RunWith; -import com.checkmarx.eclipse.utils.PluginConstants; +// import com.checkmarx.eclipse.utils.PluginConstants; -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestProjectAndBranchSelection extends BaseUITest { +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestProjectAndBranchSelection extends BaseUITest { - private static final String ASSERT_PROJECT_COMBO_ENABLED = "Project combo should be enabled after authentication"; - private static final String ASSERT_BRANCH_COMBO_DISABLED = "Branch combo should be disabled before project selection"; - private static final String ASSERT_BRANCH_COMBO_ENABLED = "Branch combo should be enabled after project selection"; - private static final String ASSERT_PROJECT_SELECTED = "Selected project should match the expected value"; - private static final String ASSERT_BRANCH_SELECTED = "Selected branch should match the expected value"; +// private static final String ASSERT_PROJECT_COMBO_ENABLED = "Project combo should be enabled after authentication"; +// private static final String ASSERT_BRANCH_COMBO_DISABLED = "Branch combo should be disabled before project selection"; +// private static final String ASSERT_BRANCH_COMBO_ENABLED = "Branch combo should be enabled after project selection"; +// private static final String ASSERT_PROJECT_SELECTED = "Selected project should match the expected value"; +// private static final String ASSERT_BRANCH_SELECTED = "Selected branch should match the expected value"; - @Test - public void testProjectAndBranchSelectionFlow() throws TimeoutException { - // Set up plugin with authentication - testSuccessfulConnection(false); - addCheckmarxPlugin(true); +// @Test +// public void testProjectAndBranchSelectionFlow() throws TimeoutException { +// // Set up plugin with authentication +// testSuccessfulConnection(false); +// addCheckmarxPlugin(true); - // Get combo boxes - SWTBotCombo projectCombo = _bot.comboBox(0); - SWTBotCombo branchCombo = _bot.comboBox(1); +// // Get combo boxes +// SWTBotCombo projectCombo = _bot.comboBox(0); +// SWTBotCombo branchCombo = _bot.comboBox(1); - // Verify initial state - assertTrue(ASSERT_PROJECT_COMBO_ENABLED, projectCombo.isEnabled()); - assertFalse(ASSERT_BRANCH_COMBO_DISABLED, branchCombo.isEnabled()); +// // Verify initial state +// assertTrue(ASSERT_PROJECT_COMBO_ENABLED, projectCombo.isEnabled()); +// assertFalse(ASSERT_BRANCH_COMBO_DISABLED, branchCombo.isEnabled()); - // Select first project - projectCombo.setSelection(0); - sleep(2000); +// // Select first project +// projectCombo.setSelection(0); +// sleep(2000); - // Verify branch combo is enabled after project selection - assertTrue(ASSERT_BRANCH_COMBO_ENABLED, branchCombo.isEnabled()); +// // Verify branch combo is enabled after project selection +// assertTrue(ASSERT_BRANCH_COMBO_ENABLED, branchCombo.isEnabled()); - // Select first branch - branchCombo.setSelection(0); - sleep(1000); +// // Select first branch +// branchCombo.setSelection(0); +// sleep(1000); - // Verify selections - String selectedProject = projectCombo.getText(); - String selectedBranch = branchCombo.getText(); +// // Verify selections +// String selectedProject = projectCombo.getText(); +// String selectedBranch = branchCombo.getText(); - assertFalse("Project selection should not be empty", selectedProject.isEmpty()); - assertFalse("Branch selection should not be empty", selectedBranch.isEmpty()); +// assertFalse("Project selection should not be empty", selectedProject.isEmpty()); +// assertFalse("Branch selection should not be empty", selectedBranch.isEmpty()); - // Clear project selection - projectCombo.setText(""); - sleep(1000); +// // Clear project selection +// projectCombo.setText(""); +// sleep(1000); - // Verify branch combo is disabled again - assertFalse(ASSERT_BRANCH_COMBO_DISABLED, branchCombo.isEnabled()); +// // Verify branch combo is disabled again +// assertFalse(ASSERT_BRANCH_COMBO_DISABLED, branchCombo.isEnabled()); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - @Test - public void testProjectSearch() throws TimeoutException { - testSuccessfulConnection(false); - addCheckmarxPlugin(true); +// @Test +// public void testProjectSearch() throws TimeoutException { +// testSuccessfulConnection(false); +// addCheckmarxPlugin(true); - SWTBotCombo projectCombo = _bot.comboBox(0); +// SWTBotCombo projectCombo = _bot.comboBox(0); - // Type partial project name - String partialName = "test"; - projectCombo.setText(partialName); - sleep(2000); - - // Verify filtered results - String[] items = projectCombo.items(); - for (String item : items) { - assertTrue("Filtered items should contain search text", - item.toLowerCase().contains(partialName.toLowerCase())); - } - - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } -} \ No newline at end of file +// // Type partial project name +// String partialName = "test"; +// projectCombo.setText(partialName); +// sleep(2000); + +// // Verify filtered results +// String[] items = projectCombo.items(); +// for (String item : items) { +// assertTrue("Filtered items should contain search text", +// item.toLowerCase().contains(partialName.toLowerCase())); +// } + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultDetails.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultDetails.java index 377b7507..f885ab79 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultDetails.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultDetails.java @@ -1,74 +1,74 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.concurrent.TimeoutException; - -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.checkmarx.eclipse.utils.PluginConstants; - -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestResultDetails extends BaseUITest { - - private static final String ASSERT_DETAILS_VISIBLE = "Result details should be visible when result is selected"; - private static final String ASSERT_DETAILS_HIDDEN = "Result details should be hidden when no result is selected"; - private static final String ASSERT_DESCRIPTION_NOT_EMPTY = "Result description should not be empty"; - private static final String ASSERT_SEVERITY_NOT_EMPTY = "Severity field should not be empty"; - private static final String ASSERT_STATE_NOT_EMPTY = "State field should not be empty"; - - @Test - public void testResultDetailsVisibility() throws TimeoutException { - setUpCheckmarxPlugin(true); - - // Initially details should be hidden - assertFalse(ASSERT_DETAILS_HIDDEN, isDetailsVisible()); - - // Select first result - SWTBotTreeItem resultNode = getFirstResultNode(); - resultNode.select(); - sleep(1000); - - // Verify details are shown - assertTrue(ASSERT_DETAILS_VISIBLE, isDetailsVisible()); - - // Verify details content - assertTrue(ASSERT_DESCRIPTION_NOT_EMPTY, - !_bot.textWithId(PluginConstants.DESCRIPTION_TEXT_ID).getText().isEmpty()); - assertTrue(ASSERT_SEVERITY_NOT_EMPTY, - !_bot.comboBoxWithId(PluginConstants.TRIAGE_SEVERITY_COMBO_ID).getText().isEmpty()); - assertTrue(ASSERT_STATE_NOT_EMPTY, - !_bot.comboBoxWithId(PluginConstants.TRIAGE_STATE_COMBO_ID).getText().isEmpty()); - - // Deselect result - _bot.tree(1).select(); - sleep(1000); - - // Verify details are hidden again - assertFalse(ASSERT_DETAILS_HIDDEN, isDetailsVisible()); - - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } - - private boolean isDetailsVisible() { - try { - _bot.textWithId(PluginConstants.DESCRIPTION_TEXT_ID); - return true; - } catch (Exception e) { - return false; - } - } - - private SWTBotTreeItem getFirstResultNode() { - String firstNodeName = _bot.tree(1).cell(0, 0); - SWTBotTreeItem node = _bot.tree(1).getTreeItem(firstNodeName); - while(!node.getNodes().isEmpty()) { - node = node.expand().getNode(0); - } - return node; - } -} \ No newline at end of file +// package checkmarx.ast.eclipse.plugin.tests.ui; + +// import static org.junit.Assert.assertFalse; +// import static org.junit.Assert.assertTrue; + +// import java.util.concurrent.TimeoutException; + +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +// import org.junit.Test; +// import org.junit.runner.RunWith; + +// import com.checkmarx.eclipse.utils.PluginConstants; + +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestResultDetails extends BaseUITest { + +// private static final String ASSERT_DETAILS_VISIBLE = "Result details should be visible when result is selected"; +// private static final String ASSERT_DETAILS_HIDDEN = "Result details should be hidden when no result is selected"; +// private static final String ASSERT_DESCRIPTION_NOT_EMPTY = "Result description should not be empty"; +// private static final String ASSERT_SEVERITY_NOT_EMPTY = "Severity field should not be empty"; +// private static final String ASSERT_STATE_NOT_EMPTY = "State field should not be empty"; + +// @Test +// public void testResultDetailsVisibility() throws TimeoutException { +// setUpCheckmarxPlugin(true); + +// // Initially details should be hidden +// assertFalse(ASSERT_DETAILS_HIDDEN, isDetailsVisible()); + +// // Select first result +// SWTBotTreeItem resultNode = getFirstResultNode(); +// resultNode.select(); +// sleep(1000); + +// // Verify details are shown +// assertTrue(ASSERT_DETAILS_VISIBLE, isDetailsVisible()); + +// // Verify details content +// assertTrue(ASSERT_DESCRIPTION_NOT_EMPTY, +// !_bot.textWithId(PluginConstants.DESCRIPTION_TEXT_ID).getText().isEmpty()); +// assertTrue(ASSERT_SEVERITY_NOT_EMPTY, +// !_bot.comboBoxWithId(PluginConstants.TRIAGE_SEVERITY_COMBO_ID).getText().isEmpty()); +// assertTrue(ASSERT_STATE_NOT_EMPTY, +// !_bot.comboBoxWithId(PluginConstants.TRIAGE_STATE_COMBO_ID).getText().isEmpty()); + +// // Deselect result +// _bot.tree(1).select(); +// sleep(1000); + +// // Verify details are hidden again +// assertFalse(ASSERT_DETAILS_HIDDEN, isDetailsVisible()); + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } + +// private boolean isDetailsVisible() { +// try { +// _bot.textWithId(PluginConstants.DESCRIPTION_TEXT_ID); +// return true; +// } catch (Exception e) { +// return false; +// } +// } + +// private SWTBotTreeItem getFirstResultNode() { +// String firstNodeName = _bot.tree(1).cell(0, 0); +// SWTBotTreeItem node = _bot.tree(1).getTreeItem(firstNodeName); +// while(!node.getNodes().isEmpty()) { +// node = node.expand().getNode(0); +// } +// return node; +// } +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultNavigation.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultNavigation.java index 9dfcef10..c6380543 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultNavigation.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultNavigation.java @@ -1,78 +1,78 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; +// package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.assertTrue; +// import static org.junit.Assert.assertTrue; -import java.util.concurrent.TimeoutException; +// import java.util.concurrent.TimeoutException; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.junit.Test; -import org.junit.runner.RunWith; +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +// import org.junit.Test; +// import org.junit.runner.RunWith; -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestResultNavigation extends BaseUITest { +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestResultNavigation extends BaseUITest { - private static final String ASSERT_EDITOR_OPENED = "Editor should open when double-clicking result"; - private static final String ASSERT_LINE_SELECTED = "Correct line should be selected in editor"; +// private static final String ASSERT_EDITOR_OPENED = "Editor should open when double-clicking result"; +// private static final String ASSERT_LINE_SELECTED = "Correct line should be selected in editor"; - @Test - public void testDoubleClickNavigation() throws TimeoutException { - setUpCheckmarxPlugin(true); +// @Test +// public void testDoubleClickNavigation() throws TimeoutException { +// setUpCheckmarxPlugin(true); - // Get first result node - SWTBotTreeItem resultNode = getFirstResultNode(); +// // Get first result node +// SWTBotTreeItem resultNode = getFirstResultNode(); - // Double click to open editor - resultNode.doubleClick(); - sleep(2000); - - // Verify editor opened with correct file - assertTrue(ASSERT_EDITOR_OPENED, - _bot.activeEditor() != null); - - // Verify line selection - assertTrue(ASSERT_LINE_SELECTED, - _bot.activeEditor().toTextEditor().getSelection().x > 0); - - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } - - @Test - public void testMultipleResultsNavigation() throws TimeoutException { - setUpCheckmarxPlugin(true); - - // Navigate through multiple results - SWTBotTreeItem firstNode = getFirstResultNode(); - firstNode.select(); - sleep(1000); - - // Get next result - SWTBotTreeItem nextNode = getNextResultNode(firstNode); - nextNode.select(); - sleep(1000); - - // Verify different selections - assertTrue("Different results should be selectable", - !firstNode.getText().equals(nextNode.getText())); - - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } - - private SWTBotTreeItem getFirstResultNode() { - String firstNodeName = _bot.tree(1).cell(0, 0); - SWTBotTreeItem node = _bot.tree(1).getTreeItem(firstNodeName); - while(!node.getNodes().isEmpty()) { - node = node.expand().getNode(0); - } - return node; - } - - private SWTBotTreeItem getNextResultNode(SWTBotTreeItem currentNode) { - SWTBotTreeItem parent = currentNode.parent(); - int currentIndex = parent.getNodes().indexOf(currentNode.getText()); - if (currentIndex < parent.getNodes().size() - 1) { - return parent.getNode(currentIndex + 1); - } - return parent.getNode(0); // Wrap around to first if at end - } -} \ No newline at end of file +// // Double click to open editor +// resultNode.doubleClick(); +// sleep(2000); + +// // Verify editor opened with correct file +// assertTrue(ASSERT_EDITOR_OPENED, +// _bot.activeEditor() != null); + +// // Verify line selection +// assertTrue(ASSERT_LINE_SELECTED, +// _bot.activeEditor().toTextEditor().getSelection().x > 0); + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } + +// @Test +// public void testMultipleResultsNavigation() throws TimeoutException { +// setUpCheckmarxPlugin(true); + +// // Navigate through multiple results +// SWTBotTreeItem firstNode = getFirstResultNode(); +// firstNode.select(); +// sleep(1000); + +// // Get next result +// SWTBotTreeItem nextNode = getNextResultNode(firstNode); +// nextNode.select(); +// sleep(1000); + +// // Verify different selections +// assertTrue("Different results should be selectable", +// !firstNode.getText().equals(nextNode.getText())); + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } + +// private SWTBotTreeItem getFirstResultNode() { +// String firstNodeName = _bot.tree(1).cell(0, 0); +// SWTBotTreeItem node = _bot.tree(1).getTreeItem(firstNodeName); +// while(!node.getNodes().isEmpty()) { +// node = node.expand().getNode(0); +// } +// return node; +// } + +// private SWTBotTreeItem getNextResultNode(SWTBotTreeItem currentNode) { +// SWTBotTreeItem parent = currentNode.parent(); +// int currentIndex = parent.getNodes().indexOf(currentNode.getText()); +// if (currentIndex < parent.getNodes().size() - 1) { +// return parent.getNode(currentIndex + 1); +// } +// return parent.getNode(0); // Wrap around to first if at end +// } +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsFiltering.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsFiltering.java index c0757f4b..fde589c6 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsFiltering.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsFiltering.java @@ -1,66 +1,66 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; +// package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.assertTrue; +// import static org.junit.Assert.assertTrue; -import java.util.concurrent.TimeoutException; +// import java.util.concurrent.TimeoutException; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.junit.Test; -import org.junit.runner.RunWith; +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +// import org.junit.Test; +// import org.junit.runner.RunWith; -import com.checkmarx.eclipse.utils.PluginConstants; +// import com.checkmarx.eclipse.utils.PluginConstants; -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestResultsFiltering extends BaseUITest { +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestResultsFiltering extends BaseUITest { - private static final String ASSERT_FILTERED_RESULTS = "Results should be filtered according to search text"; - private static final String ASSERT_NO_RESULTS = "No results should be shown for invalid search"; +// private static final String ASSERT_FILTERED_RESULTS = "Results should be filtered according to search text"; +// private static final String ASSERT_NO_RESULTS = "No results should be shown for invalid search"; - @Test - public void testQueryNameFiltering() throws TimeoutException { - setUpCheckmarxPlugin(true); +// @Test +// public void testQueryNameFiltering() throws TimeoutException { +// setUpCheckmarxPlugin(true); - // Get the first query name - String firstNodeName = _bot.tree(1).cell(0, 0); - SWTBotTreeItem firstNode = _bot.tree(1).getTreeItem(firstNodeName); - String queryName = getFirstQueryName(firstNode); +// // Get the first query name +// String firstNodeName = _bot.tree(1).cell(0, 0); +// SWTBotTreeItem firstNode = _bot.tree(1).getTreeItem(firstNodeName); +// String queryName = getFirstQueryName(firstNode); - // Type partial query name in filter - SWTBotText filterText = _bot.textWithId(PluginConstants.FILTER_TEXT_ID); - filterText.setText(queryName.substring(0, 5)); - sleep(2000); +// // Type partial query name in filter +// SWTBotText filterText = _bot.textWithId(PluginConstants.FILTER_TEXT_ID); +// filterText.setText(queryName.substring(0, 5)); +// sleep(2000); - // Verify filtered results - SWTBotTreeItem[] items = _bot.tree(1).getAllItems(); - for (SWTBotTreeItem item : items) { - String itemText = getAllNodeText(item); - assertTrue(ASSERT_FILTERED_RESULTS, - itemText.toLowerCase().contains(queryName.substring(0, 5).toLowerCase())); - } +// // Verify filtered results +// SWTBotTreeItem[] items = _bot.tree(1).getAllItems(); +// for (SWTBotTreeItem item : items) { +// String itemText = getAllNodeText(item); +// assertTrue(ASSERT_FILTERED_RESULTS, +// itemText.toLowerCase().contains(queryName.substring(0, 5).toLowerCase())); +// } - // Test invalid search - filterText.setText("INVALID_QUERY_NAME_XXX"); - sleep(2000); +// // Test invalid search +// filterText.setText("INVALID_QUERY_NAME_XXX"); +// sleep(2000); - assertTrue(ASSERT_NO_RESULTS, _bot.tree(1).getAllItems().length <= 1); +// assertTrue(ASSERT_NO_RESULTS, _bot.tree(1).getAllItems().length <= 1); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - private String getFirstQueryName(SWTBotTreeItem node) { - while(!node.getNodes().isEmpty()) { - node = node.expand().getNode(0); - } - return node.getText(); - } +// private String getFirstQueryName(SWTBotTreeItem node) { +// while(!node.getNodes().isEmpty()) { +// node = node.expand().getNode(0); +// } +// return node.getText(); +// } - private String getAllNodeText(SWTBotTreeItem item) { - StringBuilder text = new StringBuilder(item.getText()); - for (SWTBotTreeItem child : item.getItems()) { - text.append(" ").append(getAllNodeText(child)); - } - return text.toString(); - } -} \ No newline at end of file +// private String getAllNodeText(SWTBotTreeItem item) { +// StringBuilder text = new StringBuilder(item.getText()); +// for (SWTBotTreeItem child : item.getItems()) { +// text.append(" ").append(getAllNodeText(child)); +// } +// return text.toString(); +// } +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java index e38ad6da..e69b78b6 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java @@ -1,99 +1,99 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; - -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeoutException; - -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.checkmarx.eclipse.utils.PluginConstants; - -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestResultsSorting extends BaseUITest { - - private static final String ASSERT_SORTED_BY_SEVERITY = "Results should be sorted by severity"; - private static final String ASSERT_SORTED_BY_STATE = "Results should be sorted by state"; - - @Test - public void testSortBySeverity() throws TimeoutException { - setUpCheckmarxPlugin(true); - - // Enable severity grouping - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.MENU_GROUP_BY) - .menu(PluginConstants.GROUP_BY_SEVERITY).click(); - - sleep(2000); - - // Get all severity groups - List severityGroups = getSeverityGroups(); - - // Verify order: High -> Medium -> Low -> Info - assertTrue(ASSERT_SORTED_BY_SEVERITY, - isSortedBySeverity(severityGroups)); - - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } - - @Test - public void testSortByState() throws TimeoutException { - setUpCheckmarxPlugin(true); - - // Enable state grouping - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.MENU_GROUP_BY) - .menu(PluginConstants.GROUP_BY_STATE_NAME).click(); - - sleep(2000); - - // Get all state groups - List stateGroups = getStateGroups(); - - // Verify order is alphabetical - assertTrue(ASSERT_SORTED_BY_STATE, - isAlphabeticallySorted(stateGroups)); - - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } - - private List getSeverityGroups() { - List groups = new ArrayList<>(); - SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; - for (SWTBotTreeItem item : root.getItems()) { - groups.add(item.getText().split("\\(")[0].trim()); - } - return groups; - } - - private List getStateGroups() { - List groups = new ArrayList<>(); - SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; - for (SWTBotTreeItem item : root.getItems()) { - groups.add(item.getText().split("\\(")[0].trim()); - } - return groups; - } - - private boolean isSortedBySeverity(List groups) { - int highIndex = groups.indexOf("HIGH"); - int mediumIndex = groups.indexOf("MEDIUM"); - int lowIndex = groups.indexOf("LOW"); - int infoIndex = groups.indexOf("INFO"); - - return highIndex < mediumIndex && - mediumIndex < lowIndex && - lowIndex < infoIndex; - } - - private boolean isAlphabeticallySorted(List groups) { - for (int i = 0; i < groups.size() - 1; i++) { - if (groups.get(i).compareTo(groups.get(i + 1)) > 0) { - return false; - } - } - return true; - } -} \ No newline at end of file +// package checkmarx.ast.eclipse.plugin.tests.ui; + +// import static org.junit.Assert.assertTrue; + +// import java.util.ArrayList; +// import java.util.List; +// import java.util.concurrent.TimeoutException; + +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +// import org.junit.Test; +// import org.junit.runner.RunWith; + +// import com.checkmarx.eclipse.utils.PluginConstants; + +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestResultsSorting extends BaseUITest { + +// private static final String ASSERT_SORTED_BY_SEVERITY = "Results should be sorted by severity"; +// private static final String ASSERT_SORTED_BY_STATE = "Results should be sorted by state"; + +// @Test +// public void testSortBySeverity() throws TimeoutException { +// setUpCheckmarxPlugin(true); + +// // Enable severity grouping +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.MENU_GROUP_BY) +// .menu(PluginConstants.GROUP_BY_SEVERITY).click(); + +// sleep(2000); + +// // Get all severity groups +// List severityGroups = getSeverityGroups(); + +// // Verify order: High -> Medium -> Low -> Info +// assertTrue(ASSERT_SORTED_BY_SEVERITY, +// isSortedBySeverity(severityGroups)); + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } + +// @Test +// public void testSortByState() throws TimeoutException { +// setUpCheckmarxPlugin(true); + +// // Enable state grouping +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.MENU_GROUP_BY) +// .menu(PluginConstants.GROUP_BY_STATE_NAME).click(); + +// sleep(2000); + +// // Get all state groups +// List stateGroups = getStateGroups(); + +// // Verify order is alphabetical +// assertTrue(ASSERT_SORTED_BY_STATE, +// isAlphabeticallySorted(stateGroups)); + +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } + +// private List getSeverityGroups() { +// List groups = new ArrayList<>(); +// SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; +// for (SWTBotTreeItem item : root.getItems()) { +// groups.add(item.getText().split("\\(")[0].trim()); +// } +// return groups; +// } + +// private List getStateGroups() { +// List groups = new ArrayList<>(); +// SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; +// for (SWTBotTreeItem item : root.getItems()) { +// groups.add(item.getText().split("\\(")[0].trim()); +// } +// return groups; +// } + +// private boolean isSortedBySeverity(List groups) { +// int highIndex = groups.indexOf("HIGH"); +// int mediumIndex = groups.indexOf("MEDIUM"); +// int lowIndex = groups.indexOf("LOW"); +// int infoIndex = groups.indexOf("INFO"); + +// return highIndex < mediumIndex && +// mediumIndex < lowIndex && +// lowIndex < infoIndex; +// } + +// private boolean isAlphabeticallySorted(List groups) { +// for (int i = 0; i < groups.size() - 1; i++) { +// if (groups.get(i).compareTo(groups.get(i + 1)) > 0) { +// return false; +// } +// } +// return true; +// } +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestScan.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestScan.java index 906ebba2..c847495d 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestScan.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestScan.java @@ -1,164 +1,164 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; +// package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.assertFalse; +// import static org.junit.Assert.assertFalse; -import java.util.concurrent.TimeoutException; +// import java.util.concurrent.TimeoutException; -import org.eclipse.swtbot.swt.finder.SWTBot; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; -import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import org.eclipse.swtbot.swt.finder.waits.ICondition; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; -import org.junit.Test; -import org.junit.runner.RunWith; +// import org.eclipse.swtbot.swt.finder.SWTBot; +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; +// import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; +// import org.eclipse.swtbot.swt.finder.waits.ICondition; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; +// import org.junit.Test; +// import org.junit.runner.RunWith; -import com.checkmarx.eclipse.utils.PluginConstants; +// import com.checkmarx.eclipse.utils.PluginConstants; -import checkmarx.ast.eclipse.plugin.tests.common.Environment; +// import checkmarx.ast.eclipse.plugin.tests.common.Environment; -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestScan extends BaseUITest { +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestScan extends BaseUITest { - public static final String ASSERT_START_SCAN_DISABLED = "Start scan must be disabled since there is no project or branch selected."; - 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."; - public static final String BTN_YES = "Yes"; - public static final String BTN_NO = "No"; +// public static final String ASSERT_START_SCAN_DISABLED = "Start scan must be disabled since there is no project or branch selected."; +// 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."; +// public static final String BTN_YES = "Yes"; +// public static final String BTN_NO = "No"; - @Test - public void testScanButtonsDisabledWhenMissingProjectOrBranch() throws TimeoutException { - // Test Connection - testSuccessfulConnection(false); +// @Test +// public void testScanButtonsDisabledWhenMissingProjectOrBranch() throws TimeoutException { +// // Test Connection +// testSuccessfulConnection(false); - // Add Checkmarx One Plugin - addCheckmarxPlugin(true); +// // Add Checkmarx One Plugin +// addCheckmarxPlugin(true); - // clear the view before getting the scan id - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.TOOLBAR_ACTION_CLEAR_RESULTS).click(); +// // clear the view before getting the scan id +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.TOOLBAR_ACTION_CLEAR_RESULTS).click(); - SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); - assertFalse(ASSERT_START_SCAN_DISABLED, startBtn.isEnabled()); - SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get(); - assertFalse(ASSERT_CANCEL_SCAN_DISABLED, cancelBtn.isEnabled()); - } +// SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); +// assertFalse(ASSERT_START_SCAN_DISABLED, startBtn.isEnabled()); +// SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get(); +// assertFalse(ASSERT_CANCEL_SCAN_DISABLED, cancelBtn.isEnabled()); +// } - @Test - public void testScanProjectDoesNotMatch() throws TimeoutException { - // Used to wait for scan to finish - SWTBotPreferences.TIMEOUT = 300000; // 5minutes +// @Test +// public void testScanProjectDoesNotMatch() throws TimeoutException { +// // Used to wait for scan to finish +// SWTBotPreferences.TIMEOUT = 300000; // 5minutes - testSuccessfulConnection(false); +// testSuccessfulConnection(false); - addCheckmarxPlugin(true); +// addCheckmarxPlugin(true); - preventWidgetWasNullInCIEnvironment(); +// preventWidgetWasNullInCIEnvironment(); - _bot.comboBox(2).setText(Environment.SCAN_ID_PROJECT_DOES_NOT_MATCH); - _bot.comboBox(2).pressShortcut(Keystrokes.LF); +// _bot.comboBox(2).setText(Environment.SCAN_ID_PROJECT_DOES_NOT_MATCH); +// _bot.comboBox(2).pressShortcut(Keystrokes.LF); - waitUntilBranchComboIsEnabled(); +// waitUntilBranchComboIsEnabled(); - _bot.waitUntil(startScanButtonEnabled); +// _bot.waitUntil(startScanButtonEnabled); - SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); - startBtn.click(); +// SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); +// startBtn.click(); - SWTBotShell shell = _bot.shell(PluginConstants.CX_PROJECT_MISMATCH); - shell.activate(); +// SWTBotShell shell = _bot.shell(PluginConstants.CX_PROJECT_MISMATCH); +// shell.activate(); - _bot.button(BTN_NO).click(); +// _bot.button(BTN_NO).click(); - SWTBotPreferences.TIMEOUT = 5000; - } +// SWTBotPreferences.TIMEOUT = 5000; +// } - @Test - public void testCancelScan() throws TimeoutException { - // Used to wait for scan to finish - SWTBotPreferences.TIMEOUT = 300000; // 5minutes +// @Test +// public void testCancelScan() throws TimeoutException { +// // Used to wait for scan to finish +// SWTBotPreferences.TIMEOUT = 300000; // 5minutes - testSuccessfulConnection(false); +// testSuccessfulConnection(false); - addCheckmarxPlugin(true); +// addCheckmarxPlugin(true); - preventWidgetWasNullInCIEnvironment(); +// preventWidgetWasNullInCIEnvironment(); - _bot.comboBox(2).setText(Environment.SCAN_ID); - _bot.comboBox(2).pressShortcut(Keystrokes.LF); +// _bot.comboBox(2).setText(Environment.SCAN_ID); +// _bot.comboBox(2).pressShortcut(Keystrokes.LF); - waitUntilBranchComboIsEnabled(); +// waitUntilBranchComboIsEnabled(); - SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); - startBtn.click(); +// SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); +// startBtn.click(); - SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get(); - _bot.waitUntil(cancelScanButtonEnabled); - cancelBtn.click(); +// SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get(); +// _bot.waitUntil(cancelScanButtonEnabled); +// cancelBtn.click(); - _bot.waitUntil(startScanButtonEnabled); +// _bot.waitUntil(startScanButtonEnabled); - SWTBotPreferences.TIMEOUT = 5000; - } +// SWTBotPreferences.TIMEOUT = 5000; +// } - @Test - public void testRunScan() throws TimeoutException { - // Used to wait for scan to finish - SWTBotPreferences.TIMEOUT = 300000; // 5minutes +// @Test +// public void testRunScan() throws TimeoutException { +// // Used to wait for scan to finish +// SWTBotPreferences.TIMEOUT = 300000; // 5minutes - testSuccessfulConnection(false); +// testSuccessfulConnection(false); - addCheckmarxPlugin(true); +// addCheckmarxPlugin(true); - preventWidgetWasNullInCIEnvironment(); +// preventWidgetWasNullInCIEnvironment(); - _bot.comboBox(2).setText(Environment.SCAN_ID); - _bot.comboBox(2).pressShortcut(Keystrokes.LF); +// _bot.comboBox(2).setText(Environment.SCAN_ID); +// _bot.comboBox(2).pressShortcut(Keystrokes.LF); - waitUntilBranchComboIsEnabled(); +// waitUntilBranchComboIsEnabled(); - sleep(10000); +// sleep(10000); - SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); - startBtn.click(); +// SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); +// startBtn.click(); - _bot.waitUntil(startScanButtonEnabled); +// _bot.waitUntil(startScanButtonEnabled); - SWTBotPreferences.TIMEOUT = 5000; - } +// SWTBotPreferences.TIMEOUT = 5000; +// } - private static final ICondition startScanButtonEnabled = new ICondition() { - @Override - public boolean test() throws Exception { - SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); - return startBtn.isEnabled(); - } - - @Override - public String getFailureMessage() { - return "Start scan button must be enabled"; - } +// private static final ICondition startScanButtonEnabled = new ICondition() { +// @Override +// public boolean test() throws Exception { +// SWTBotToolbarButton startBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_START_SCAN)).findFirst().get(); +// return startBtn.isEnabled(); +// } + +// @Override +// public String getFailureMessage() { +// return "Start scan button must be enabled"; +// } - @Override - public void init(SWTBot bot) { +// @Override +// public void init(SWTBot bot) { - } - }; +// } +// }; - private static final ICondition cancelScanButtonEnabled = new ICondition() { - @Override - public boolean test() throws Exception { - SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get(); - return cancelBtn.isEnabled(); - } - - @Override - public String getFailureMessage() { - return "Cancel scan button must be enabled"; - } +// private static final ICondition cancelScanButtonEnabled = new ICondition() { +// @Override +// public boolean test() throws Exception { +// SWTBotToolbarButton cancelBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().equals(PluginConstants.CX_CANCEL_RUNNING_SCAN)).findFirst().get(); +// return cancelBtn.isEnabled(); +// } + +// @Override +// public String getFailureMessage() { +// return "Cancel scan button must be enabled"; +// } - @Override - public void init(SWTBot bot) { +// @Override +// public void init(SWTBot bot) { - } - }; -} \ No newline at end of file +// } +// }; +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestToolbarActions.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestToolbarActions.java index 05358b38..699e99d0 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestToolbarActions.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestToolbarActions.java @@ -1,70 +1,70 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; +// package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +// import static org.junit.Assert.assertFalse; +// import static org.junit.Assert.assertTrue; -import java.util.concurrent.TimeoutException; +// import java.util.concurrent.TimeoutException; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; -import org.junit.Test; -import org.junit.runner.RunWith; +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; +// import org.junit.Test; +// import org.junit.runner.RunWith; -import com.checkmarx.eclipse.utils.PluginConstants; +// import com.checkmarx.eclipse.utils.PluginConstants; -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestToolbarActions extends BaseUITest { +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestToolbarActions extends BaseUITest { - private static final String ASSERT_REFRESH_ENABLED = "Refresh button should be enabled"; - private static final String ASSERT_CLEAR_ENABLED = "Clear button should be enabled"; - private static final String ASSERT_TREE_CLEARED = "Tree should be cleared after clear action"; - private static final String ASSERT_RESULTS_REFRESHED = "Results should be updated after refresh"; +// private static final String ASSERT_REFRESH_ENABLED = "Refresh button should be enabled"; +// private static final String ASSERT_CLEAR_ENABLED = "Clear button should be enabled"; +// private static final String ASSERT_TREE_CLEARED = "Tree should be cleared after clear action"; +// private static final String ASSERT_RESULTS_REFRESHED = "Results should be updated after refresh"; - @Test - public void testRefreshAction() throws TimeoutException { - setUpCheckmarxPlugin(true); +// @Test +// public void testRefreshAction() throws TimeoutException { +// setUpCheckmarxPlugin(true); - // Get initial results count - String initialResults = _bot.tree(1).cell(0, 0); +// // Get initial results count +// String initialResults = _bot.tree(1).cell(0, 0); - // Click refresh - SWTBotToolbarButton refreshBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN) - .getToolbarButtons().stream() - .filter(btn -> btn.getToolTipText().equals(PluginConstants.TOOLBAR_ACTION_REFRESH)) - .findFirst().get(); +// // Click refresh +// SWTBotToolbarButton refreshBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN) +// .getToolbarButtons().stream() +// .filter(btn -> btn.getToolTipText().equals(PluginConstants.TOOLBAR_ACTION_REFRESH)) +// .findFirst().get(); - assertTrue(ASSERT_REFRESH_ENABLED, refreshBtn.isEnabled()); - refreshBtn.click(); +// assertTrue(ASSERT_REFRESH_ENABLED, refreshBtn.isEnabled()); +// refreshBtn.click(); - sleep(2000); +// sleep(2000); - // Verify results are refreshed - String refreshedResults = _bot.tree(1).cell(0, 0); - assertTrue(ASSERT_RESULTS_REFRESHED, - !refreshedResults.equals(PluginConstants.RETRIEVING_RESULTS_FOR_SCAN)); +// // Verify results are refreshed +// String refreshedResults = _bot.tree(1).cell(0, 0); +// assertTrue(ASSERT_RESULTS_REFRESHED, +// !refreshedResults.equals(PluginConstants.RETRIEVING_RESULTS_FOR_SCAN)); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - @Test - public void testClearAction() throws TimeoutException { - setUpCheckmarxPlugin(true); +// @Test +// public void testClearAction() throws TimeoutException { +// setUpCheckmarxPlugin(true); - // Click clear results - SWTBotToolbarButton clearBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN) - .getToolbarButtons().stream() - .filter(btn -> btn.getToolTipText().equals(PluginConstants.TOOLBAR_ACTION_CLEAR_RESULTS)) - .findFirst().get(); +// // Click clear results +// SWTBotToolbarButton clearBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN) +// .getToolbarButtons().stream() +// .filter(btn -> btn.getToolTipText().equals(PluginConstants.TOOLBAR_ACTION_CLEAR_RESULTS)) +// .findFirst().get(); - assertTrue(ASSERT_CLEAR_ENABLED, clearBtn.isEnabled()); - clearBtn.click(); +// assertTrue(ASSERT_CLEAR_ENABLED, clearBtn.isEnabled()); +// clearBtn.click(); - sleep(1000); +// sleep(1000); - // Verify tree is cleared - assertTrue(ASSERT_TREE_CLEARED, - _bot.tree(1).getAllItems().length == 0); +// // Verify tree is cleared +// assertTrue(ASSERT_TREE_CLEARED, +// _bot.tree(1).getAllItems().length == 0); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } -} \ No newline at end of file +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } +// } \ No newline at end of file diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestUI.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestUI.java index 240c96d2..a6cbe276 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestUI.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestUI.java @@ -1,322 +1,322 @@ -package checkmarx.ast.eclipse.plugin.tests.ui; +// package checkmarx.ast.eclipse.plugin.tests.ui; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +// import static org.junit.Assert.assertEquals; +// import static org.junit.Assert.assertTrue; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.TimeoutException; -import java.util.stream.Collectors; +// import java.util.ArrayList; +// import java.util.Arrays; +// import java.util.List; +// import java.util.UUID; +// import java.util.concurrent.TimeoutException; +// import java.util.stream.Collectors; -import org.eclipse.jface.bindings.keys.KeyStroke; -import org.eclipse.jface.bindings.keys.ParseException; -import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton; -import org.junit.Test; -import org.junit.runner.RunWith; +// import org.eclipse.jface.bindings.keys.KeyStroke; +// import org.eclipse.jface.bindings.keys.ParseException; +// import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; +// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +// import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; +// import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton; +// import org.junit.Test; +// import org.junit.runner.RunWith; -import com.checkmarx.eclipse.enums.ActionName; -import com.checkmarx.eclipse.enums.Severity; -import com.checkmarx.eclipse.utils.PluginConstants; -import com.checkmarx.eclipse.views.actions.ToolBarActions; +// import com.checkmarx.eclipse.enums.ActionName; +// import com.checkmarx.eclipse.enums.Severity; +// import com.checkmarx.eclipse.utils.PluginConstants; +// import com.checkmarx.eclipse.views.actions.ToolBarActions; -import checkmarx.ast.eclipse.plugin.tests.common.Environment; +// import checkmarx.ast.eclipse.plugin.tests.common.Environment; -@RunWith(SWTBotJunit4ClassRunner.class) -public class TestUI extends BaseUITest { +// @RunWith(SWTBotJunit4ClassRunner.class) +// public class TestUI extends BaseUITest { - private static final String ASSERT_GROUP_BY_ACTIONS_IN_TOOLBAR = "All group by actions must be in the tool bar"; - private static final String ASSERT_TREE_CONSTAIN_HIGH_MEDIUM = "Results must contain results grouped by High and Medium"; - private static final String ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW = "Results must contain results grouped by High, Medium and Low"; - private static final String ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW_INFO = "Results must contain results grouped by High, Medium, Low and Info"; - protected static final String ASSERT_TREE_WITH_NO_ISSUES = "The tree mustn't have results once we are grouping by severity and no severity is selected"; - private static final String ASSERT_GROUP_BY_QUERY_NAME = "Child name must contain the parent name once it is grouped by query name"; - protected static final String ASSERT_NO_CHINDREN = "One group by severity and group by query name are not selected, this node shouldn't have children"; - private static final String ASSERT_GROUP_BY_SEVERITY_NOT_SELECTED = "Engine child should not be HIGH, MEDIUM, LOW or INFO once the group by severity is not enabled"; - private static final String ASSERT_CREDENTIALS_PANEL = "The credentials panel must appear once Checkmarx credentials are not defined"; +// private static final String ASSERT_GROUP_BY_ACTIONS_IN_TOOLBAR = "All group by actions must be in the tool bar"; +// private static final String ASSERT_TREE_CONSTAIN_HIGH_MEDIUM = "Results must contain results grouped by High and Medium"; +// private static final String ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW = "Results must contain results grouped by High, Medium and Low"; +// private static final String ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW_INFO = "Results must contain results grouped by High, Medium, Low and Info"; +// protected static final String ASSERT_TREE_WITH_NO_ISSUES = "The tree mustn't have results once we are grouping by severity and no severity is selected"; +// private static final String ASSERT_GROUP_BY_QUERY_NAME = "Child name must contain the parent name once it is grouped by query name"; +// protected static final String ASSERT_NO_CHINDREN = "One group by severity and group by query name are not selected, this node shouldn't have children"; +// private static final String ASSERT_GROUP_BY_SEVERITY_NOT_SELECTED = "Engine child should not be HIGH, MEDIUM, LOW or INFO once the group by severity is not enabled"; +// private static final String ASSERT_CREDENTIALS_PANEL = "The credentials panel must appear once Checkmarx credentials are not defined"; - @Test - public void testSuccessfulConnetion() throws TimeoutException { - testSuccessfulConnection(false); - } +// @Test +// public void testSuccessfulConnetion() throws TimeoutException { +// testSuccessfulConnection(false); +// } - //@Test - public void testAddCheckmarxASTPlugin() throws TimeoutException { - clearCheckmarxCredentials(); +// //@Test +// public void testAddCheckmarxASTPlugin() throws TimeoutException { +// clearCheckmarxCredentials(); - // Add Checkmarx plugin to the eclipse view - addCheckmarxPlugin(false); +// // Add Checkmarx plugin to the eclipse view +// addCheckmarxPlugin(false); - preventWidgetWasNullInCIEnvironment(); +// preventWidgetWasNullInCIEnvironment(); - // Assert that active view is the Checkmarx One Scan - assertTrue("Active view must be the Checkmarx One Scan", _bot.activeView().getTitle().equals(VIEW_CHECKMARX_AST_SCAN)); +// // Assert that active view is the Checkmarx One Scan +// assertTrue("Active view must be the Checkmarx One Scan", _bot.activeView().getTitle().equals(VIEW_CHECKMARX_AST_SCAN)); - preventWidgetWasNullInCIEnvironment(); +// preventWidgetWasNullInCIEnvironment(); - assertTrue(ASSERT_CREDENTIALS_PANEL, _bot.button(PluginConstants.BTN_OPEN_SETTINGS) != null); +// assertTrue(ASSERT_CREDENTIALS_PANEL, _bot.button(PluginConstants.BTN_OPEN_SETTINGS) != null); - // Close Checkmarx One Scan view - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// // Close Checkmarx One Scan view +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - @Test - public void testMissingSetCheckmarxServerUrl() throws TimeoutException { - // Test Connection - testSuccessfulConnection(false); +// @Test +// public void testMissingSetCheckmarxServerUrl() throws TimeoutException { +// // Test Connection +// testSuccessfulConnection(false); - // Add Checkmarx One Plugin - addCheckmarxPlugin(true); +// // Add Checkmarx One Plugin +// addCheckmarxPlugin(true); - // Clear Checkmarx credentials to expect missing Server Url - clearCheckmarxCredentials(); +// // Clear Checkmarx credentials to expect missing Server Url +// clearCheckmarxCredentials(); - // Type a valid and existing scan id - preventWidgetWasNullInCIEnvironment(); +// // Type a valid and existing scan id +// preventWidgetWasNullInCIEnvironment(); - _bot.comboBox(2).setText(UUID.randomUUID().toString()); - _bot.comboBox(2).pressShortcut(Keystrokes.LF); +// _bot.comboBox(2).setText(UUID.randomUUID().toString()); +// _bot.comboBox(2).pressShortcut(Keystrokes.LF); - assertEquals("The tree must contain a single row", _bot.tree(1).rowCount(), 1); - String firstTreeCell = _bot.tree(1).cell(0, 0); +// assertEquals("The tree must contain a single row", _bot.tree(1).rowCount(), 1); +// String firstTreeCell = _bot.tree(1).cell(0, 0); - // The first row must have a message saying that One is getting results or - // failing due the missing Server Url - firstTreeCell.equals(String.format(PluginConstants.RETRIEVING_RESULTS_FOR_SCAN, Environment.SCAN_ID)); +// // The first row must have a message saying that One is getting results or +// // failing due the missing Server Url +// firstTreeCell.equals(String.format(PluginConstants.RETRIEVING_RESULTS_FOR_SCAN, Environment.SCAN_ID)); - sleep(); +// sleep(); - // Close Checkmarx One Scan view - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// // Close Checkmarx One Scan view +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - /** - * Test UI End-to-End - * - * -> Set Checkmarx credentials and test connection - * -> Add Checkmarx plugin to the show view perspective - * -> Type and assert invalid scan id - * -> Type and assert valid scan id - * -> Expand scan results - * - * @throws TimeoutException - */ - @Test - public void testEnd2End() throws TimeoutException { - // Set credentials, test connection and add checkmarx plugin - setUpCheckmarxPlugin(false); +// /** +// * Test UI End-to-End +// * +// * -> Set Checkmarx credentials and test connection +// * -> Add Checkmarx plugin to the show view perspective +// * -> Type and assert invalid scan id +// * -> Type and assert valid scan id +// * -> Expand scan results +// * +// * @throws TimeoutException +// */ +// @Test +// public void testEnd2End() throws TimeoutException { +// // Set credentials, test connection and add checkmarx plugin +// setUpCheckmarxPlugin(false); - String firstNodeName = _bot.tree(1).cell(0, 0); - String secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); - String thirdNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).expand().getNode(0).getText(); +// String firstNodeName = _bot.tree(1).cell(0, 0); +// String secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); +// String thirdNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).expand().getNode(0).getText(); - // Expand nodes until the first vulnerability - _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).select(); +// // Expand nodes until the first vulnerability +// _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).select(); - // Close Checkmarx One Scan view - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// // Close Checkmarx One Scan view +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - @Test - public void testFilterButtonsAndGroupByActionsInToolBar() throws TimeoutException { - // Test Connection - testSuccessfulConnection(false); +// @Test +// public void testFilterButtonsAndGroupByActionsInToolBar() throws TimeoutException { +// // Test Connection +// testSuccessfulConnection(false); - // Add Checkmarx One Plugin - addCheckmarxPlugin(true); +// // Add Checkmarx One Plugin +// addCheckmarxPlugin(true); - List toolbarButtons = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons(); - List toolBarButtonsNames = toolbarButtons.stream().map(btn -> btn.getToolTipText().toUpperCase()).collect(Collectors.toList()); - List filterActions = Arrays.asList(ActionName.HIGH.name(), ActionName.MEDIUM.name(), ActionName.LOW.name(), ActionName.INFO.name()); +// List toolbarButtons = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons(); +// List toolBarButtonsNames = toolbarButtons.stream().map(btn -> btn.getToolTipText().toUpperCase()).collect(Collectors.toList()); +// List filterActions = Arrays.asList(ActionName.HIGH.name(), ActionName.MEDIUM.name(), ActionName.LOW.name(), ActionName.INFO.name()); - // Assert all filter actions are present in the tool bar - assertTrue(ASSERT_FILTER_ACTIONS_IN_TOOLBAR, toolBarButtonsNames.containsAll(filterActions)); +// // Assert all filter actions are present in the tool bar +// assertTrue(ASSERT_FILTER_ACTIONS_IN_TOOLBAR, toolBarButtonsNames.containsAll(filterActions)); - List groupByActions = Arrays.asList(ToolBarActions.GROUP_BY_SEVERITY, ToolBarActions.GROUP_BY_QUERY_NAME); - List toolBarGroupByActions = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menuItems(); +// List groupByActions = Arrays.asList(ToolBarActions.GROUP_BY_SEVERITY, ToolBarActions.GROUP_BY_QUERY_NAME); +// List toolBarGroupByActions = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menuItems(); - // Assert all group by actions are present in the tool bar - assertTrue(ASSERT_GROUP_BY_ACTIONS_IN_TOOLBAR, toolBarGroupByActions.containsAll(groupByActions)); +// // Assert all group by actions are present in the tool bar +// assertTrue(ASSERT_GROUP_BY_ACTIONS_IN_TOOLBAR, toolBarGroupByActions.containsAll(groupByActions)); - // Close Checkmarx One Scan view - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// // Close Checkmarx One Scan view +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - @Test - public void testFilteringAndGroupingResults() throws TimeoutException, ParseException { - // Set credentials, test connection and add checkmarx plugin - setUpCheckmarxPlugin(true); +// @Test +// public void testFilteringAndGroupingResults() throws TimeoutException, ParseException { +// // Set credentials, test connection and add checkmarx plugin +// setUpCheckmarxPlugin(true); - List filterStateButtons = Arrays.asList("Not Exploitable","Confirmed","Ignored","Not Ignored","To Verify"); - SWTBotToolbarDropDownButton stateFilter = _bot.toolbarDropDownButtonWithTooltip("State"); +// List filterStateButtons = Arrays.asList("Not Exploitable","Confirmed","Ignored","Not Ignored","To Verify"); +// SWTBotToolbarDropDownButton stateFilter = _bot.toolbarDropDownButtonWithTooltip("State"); - for(String filter: filterStateButtons) { - try { - final SWTBotMenu menuItem = stateFilter.menuItem(filter); +// for(String filter: filterStateButtons) { +// try { +// final SWTBotMenu menuItem = stateFilter.menuItem(filter); - if(!menuItem.isChecked()) { - menuItem.click(); - } - } catch(WidgetNotFoundException e) {} - } +// if(!menuItem.isChecked()) { +// menuItem.click(); +// } +// } catch(WidgetNotFoundException e) {} +// } - stateFilter.pressShortcut(KeyStroke.getInstance("ESC")); +// stateFilter.pressShortcut(KeyStroke.getInstance("ESC")); - ArrayList currentActiveFilters = new ArrayList<>(Arrays.asList(Severity.HIGH.name(), Severity.MEDIUM.name())); +// ArrayList currentActiveFilters = new ArrayList<>(Arrays.asList(Severity.HIGH.name(), Severity.MEDIUM.name())); - // Checks that tree contains High and Medium results - assertTrue(ASSERT_TREE_CONSTAIN_HIGH_MEDIUM, expandTreeUntilFirstEngineAndGetCurrentSeverities().containsAll(currentActiveFilters)); +// // Checks that tree contains High and Medium results +// assertTrue(ASSERT_TREE_CONSTAIN_HIGH_MEDIUM, expandTreeUntilFirstEngineAndGetCurrentSeverities().containsAll(currentActiveFilters)); - // Click to include Low severity - clickSeverityFilter(ActionName.LOW.name()); - currentActiveFilters.add(Severity.LOW.name()); +// // Click to include Low severity +// clickSeverityFilter(ActionName.LOW.name()); +// currentActiveFilters.add(Severity.LOW.name()); - // Checks that tree contains High, Medium and Low results - assertTrue(ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW, expandTreeUntilFirstEngineAndGetCurrentSeverities().containsAll(currentActiveFilters)); +// // Checks that tree contains High, Medium and Low results +// assertTrue(ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW, expandTreeUntilFirstEngineAndGetCurrentSeverities().containsAll(currentActiveFilters)); - // Click to include Info severity - clickSeverityFilter(ActionName.INFO.name()); - currentActiveFilters.add(Severity.INFO.name()); +// // Click to include Info severity +// clickSeverityFilter(ActionName.INFO.name()); +// currentActiveFilters.add(Severity.INFO.name()); - // Checks that tree contains High, Medium, Low and Info results - assertTrue(ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW_INFO, expandTreeUntilFirstEngineAndGetCurrentSeverities().containsAll(currentActiveFilters)); +// // Checks that tree contains High, Medium, Low and Info results +// assertTrue(ASSERT_TREE_CONSTAIN_HIGH_MEDIUM_LOW_INFO, expandTreeUntilFirstEngineAndGetCurrentSeverities().containsAll(currentActiveFilters)); - // Get all filter buttons individually - SWTBotToolbarButton filterHighBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.HIGH.name())).findFirst().get(); - SWTBotToolbarButton filterMediumBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.MEDIUM.name())).findFirst().get(); - SWTBotToolbarButton filterLowBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.LOW.name())).findFirst().get(); - SWTBotToolbarButton filterInfoBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.INFO.name())).findFirst().get(); +// // Get all filter buttons individually +// SWTBotToolbarButton filterHighBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.HIGH.name())).findFirst().get(); +// SWTBotToolbarButton filterMediumBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.MEDIUM.name())).findFirst().get(); +// SWTBotToolbarButton filterLowBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.LOW.name())).findFirst().get(); +// SWTBotToolbarButton filterInfoBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(ActionName.INFO.name())).findFirst().get(); - // Click to remove all filters - filterHighBtn.click(); - filterMediumBtn.click(); - filterLowBtn.click(); - filterInfoBtn.click(); +// // Click to remove all filters +// filterHighBtn.click(); +// filterMediumBtn.click(); +// filterLowBtn.click(); +// filterInfoBtn.click(); - // Asserts that no issues are visible in the tree once we are grouping by Severity and no severity is selected - assertEquals(ASSERT_TREE_WITH_NO_ISSUES, _bot.tree(1).cell(0, 0), Environment.SCAN_ID + " (0 Issues)"); +// // Asserts that no issues are visible in the tree once we are grouping by Severity and no severity is selected +// assertEquals(ASSERT_TREE_WITH_NO_ISSUES, _bot.tree(1).cell(0, 0), Environment.SCAN_ID + " (0 Issues)"); - // Click to include High severity - clickSeverityFilter(ActionName.HIGH.name()); - currentActiveFilters.add(Severity.HIGH.name()); +// // Click to include High severity +// clickSeverityFilter(ActionName.HIGH.name()); +// currentActiveFilters.add(Severity.HIGH.name()); - sleep(1000); +// sleep(1000); - String firstNodeName = _bot.tree(1).cell(0, 0); - String secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); - String thirdNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).expand().getNode(0).getText(); +// String firstNodeName = _bot.tree(1).cell(0, 0); +// String secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); +// String thirdNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).expand().getNode(0).getText(); - // Expand nodes until the first vulnerability - String groupByQueryNameParent = _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).expand().getNode(0).getText(); - String groupByQueryNameChild = _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).expand().getNode(0).expand().getNode(0).getText(); +// // Expand nodes until the first vulnerability +// String groupByQueryNameParent = _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).expand().getNode(0).getText(); +// String groupByQueryNameChild = _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).expand().getNode(0).expand().getNode(0).getText(); - // Select the first vulnerability - _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).expand().getNode(0).expand().getNode(0).select(); +// // Select the first vulnerability +// _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).expandNode(thirdNodeName).getNode(0).expand().getNode(0).expand().getNode(0).select(); - // Asserts that the vulnerability has the same name as the parent node which means it is grouped by query name - assertTrue(ASSERT_GROUP_BY_QUERY_NAME, groupByQueryNameChild.contains(groupByQueryNameParent.split("\\(")[0].trim())); +// // Asserts that the vulnerability has the same name as the parent node which means it is grouped by query name +// assertTrue(ASSERT_GROUP_BY_QUERY_NAME, groupByQueryNameChild.contains(groupByQueryNameParent.split("\\(")[0].trim())); - // Remove either group by severity and query name - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_QUERY_NAME).click(); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_SEVERITY).click(); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_STATE_NAME).click(); +// // Remove either group by severity and query name +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_QUERY_NAME).click(); +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_SEVERITY).click(); +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_STATE_NAME).click(); - sleep(1000); +// sleep(1000); - firstNodeName = _bot.tree(1).cell(0, 0); - secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); - _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName); +// firstNodeName = _bot.tree(1).cell(0, 0); +// secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); +// _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName); - // Get's the first engine child - String firstEngineChild = _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).getNode(0).getText(); - - // Checks if it starts by HIGH, MEDIUM, LOW or INFO - boolean engineChildDontStartWithHIGH = !firstEngineChild.startsWith(ActionName.HIGH.name()); - boolean engineChildDontStartWithMEDIUM = !firstEngineChild.startsWith(ActionName.MEDIUM.name()); - boolean engineChildDontStartWithLOW = !firstEngineChild.startsWith(ActionName.LOW.name()); - boolean engineChildDontStartWithINFO = !firstEngineChild.startsWith(ActionName.INFO.name()); - - // Asserts group by options are not enabled - assertTrue(ASSERT_NO_CHINDREN, _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).getNode(0).getNodes().isEmpty()); - assertTrue(ASSERT_GROUP_BY_SEVERITY_NOT_SELECTED, engineChildDontStartWithHIGH && engineChildDontStartWithMEDIUM && engineChildDontStartWithLOW && engineChildDontStartWithINFO); - - // re-enable group by and severity - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_QUERY_NAME).click(); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_SEVERITY).click(); - - // Close Checkmarx One Scan view - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); - } +// // Get's the first engine child +// String firstEngineChild = _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).getNode(0).getText(); + +// // Checks if it starts by HIGH, MEDIUM, LOW or INFO +// boolean engineChildDontStartWithHIGH = !firstEngineChild.startsWith(ActionName.HIGH.name()); +// boolean engineChildDontStartWithMEDIUM = !firstEngineChild.startsWith(ActionName.MEDIUM.name()); +// boolean engineChildDontStartWithLOW = !firstEngineChild.startsWith(ActionName.LOW.name()); +// boolean engineChildDontStartWithINFO = !firstEngineChild.startsWith(ActionName.INFO.name()); + +// // Asserts group by options are not enabled +// assertTrue(ASSERT_NO_CHINDREN, _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName).getNode(0).getNodes().isEmpty()); +// assertTrue(ASSERT_GROUP_BY_SEVERITY_NOT_SELECTED, engineChildDontStartWithHIGH && engineChildDontStartWithMEDIUM && engineChildDontStartWithLOW && engineChildDontStartWithINFO); + +// // re-enable group by and severity +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_QUERY_NAME).click(); +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(ToolBarActions.MENU_GROUP_BY).menu(ToolBarActions.GROUP_BY_SEVERITY).click(); + +// // Close Checkmarx One Scan view +// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); +// } - @Test(expected = WidgetNotFoundException.class) - public void testInitialPanelWhenMissingCredentials() throws TimeoutException { - // Add Checkmarx plugin to the eclipse view - addCheckmarxPlugin(false); +// @Test(expected = WidgetNotFoundException.class) +// public void testInitialPanelWhenMissingCredentials() throws TimeoutException { +// // Add Checkmarx plugin to the eclipse view +// addCheckmarxPlugin(false); - // Assert that active view is the Checkmarx One Scan - assertTrue("Active view must be the Checkmarx One Scan", _bot.activeView().getTitle().equals(VIEW_CHECKMARX_AST_SCAN)); +// // Assert that active view is the Checkmarx One Scan +// assertTrue("Active view must be the Checkmarx One Scan", _bot.activeView().getTitle().equals(VIEW_CHECKMARX_AST_SCAN)); - assertTrue(ASSERT_CREDENTIALS_PANEL, _bot.button(PluginConstants.BTN_OPEN_SETTINGS) != null); +// assertTrue(ASSERT_CREDENTIALS_PANEL, _bot.button(PluginConstants.BTN_OPEN_SETTINGS) != null); - _bot.button(PluginConstants.BTN_OPEN_SETTINGS).click(); +// _bot.button(PluginConstants.BTN_OPEN_SETTINGS).click(); - testSuccessfulConnection(true); +// testSuccessfulConnection(true); - // Button Open Settings must not be present at this moment so we are expecting WidgetNotFoundException in this test - _bot.button(PluginConstants.BTN_OPEN_SETTINGS); - } +// // Button Open Settings must not be present at this moment so we are expecting WidgetNotFoundException in this test +// _bot.button(PluginConstants.BTN_OPEN_SETTINGS); +// } - /** - * Click on a severity filter - * - * @param actionName - */ - private void clickSeverityFilter(String actionName) { - SWTBotToolbarButton filterLowBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(actionName)).findFirst().get(); - filterLowBtn.click(); - } +// /** +// * Click on a severity filter +// * +// * @param actionName +// */ +// private void clickSeverityFilter(String actionName) { +// SWTBotToolbarButton filterLowBtn = _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).getToolbarButtons().stream().filter(btn -> btn.getToolTipText().toUpperCase().equals(actionName)).findFirst().get(); +// filterLowBtn.click(); +// } - /** - * Expands the tree until the first engine and picks the list of available severities - * - * @return - */ - private List expandTreeUntilFirstEngineAndGetCurrentSeverities() { - String firstNodeName = _bot.tree(1).cell(0, 0); - String secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); - - _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName); - - return _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNode(0).getNodes().stream().map(node -> node.split("\\(")[0].trim()).collect(Collectors.toList()); - } +// /** +// * Expands the tree until the first engine and picks the list of available severities +// * +// * @return +// */ +// private List expandTreeUntilFirstEngineAndGetCurrentSeverities() { +// String firstNodeName = _bot.tree(1).cell(0, 0); +// String secondNodeName = _bot.tree(1).getTreeItem(firstNodeName).expand().getNode(0).getText(); + +// _bot.tree(1).expandNode(firstNodeName).expandNode(secondNodeName); + +// return _bot.tree(1).getTreeItem(_bot.tree(1).cell(0, 0)).expand().getNode(0).getNodes().stream().map(node -> node.split("\\(")[0].trim()).collect(Collectors.toList()); +// } - /** - * Clear all Checkmarx credentials - */ - private void clearCheckmarxCredentials() { - if (!_cxSettingsDefined) { - return; - } - - preventWidgetWasNullInCIEnvironment(); +// /** +// * Clear all Checkmarx credentials +// */ +// private void clearCheckmarxCredentials() { +// if (!_cxSettingsDefined) { +// return; +// } + +// preventWidgetWasNullInCIEnvironment(); - _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); - _bot.shell(ITEM_PREFERENCES).activate(); - _bot.tree().select(ITEM_CHECKMARX_AST); +// _bot.menu(TAB_WINDOW).menu(ITEM_PREFERENCES).click(); +// _bot.shell(ITEM_PREFERENCES).activate(); +// _bot.tree().select(ITEM_CHECKMARX_AST); - _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(PluginConstants.EMPTY_STRING); +// _bot.textWithLabel(PluginConstants.PREFERENCES_API_KEY).setText(PluginConstants.EMPTY_STRING); - _bot.button(BTN_APPLY).click(); - _bot.button(BTN_APPLY_AND_CLOSE).click(); +// _bot.button(BTN_APPLY).click(); +// _bot.button(BTN_APPLY_AND_CLOSE).click(); - _cxSettingsDefined = false; - } -} +// _cxSettingsDefined = false; +// } +// } From 705744f41ea1ca69967da8a3612b9bc206632f90 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Wed, 22 Jan 2025 12:07:13 +0200 Subject: [PATCH 12/13] Update TestResultsSorting.java --- .../plugin/tests/ui/TestResultsSorting.java | 198 +++++++++--------- 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java index e69b78b6..e38ad6da 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java @@ -1,99 +1,99 @@ -// package checkmarx.ast.eclipse.plugin.tests.ui; - -// import static org.junit.Assert.assertTrue; - -// import java.util.ArrayList; -// import java.util.List; -// import java.util.concurrent.TimeoutException; - -// import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -// import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; -// import org.junit.Test; -// import org.junit.runner.RunWith; - -// import com.checkmarx.eclipse.utils.PluginConstants; - -// @RunWith(SWTBotJunit4ClassRunner.class) -// public class TestResultsSorting extends BaseUITest { - -// private static final String ASSERT_SORTED_BY_SEVERITY = "Results should be sorted by severity"; -// private static final String ASSERT_SORTED_BY_STATE = "Results should be sorted by state"; - -// @Test -// public void testSortBySeverity() throws TimeoutException { -// setUpCheckmarxPlugin(true); - -// // Enable severity grouping -// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.MENU_GROUP_BY) -// .menu(PluginConstants.GROUP_BY_SEVERITY).click(); - -// sleep(2000); - -// // Get all severity groups -// List severityGroups = getSeverityGroups(); - -// // Verify order: High -> Medium -> Low -> Info -// assertTrue(ASSERT_SORTED_BY_SEVERITY, -// isSortedBySeverity(severityGroups)); - -// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); -// } - -// @Test -// public void testSortByState() throws TimeoutException { -// setUpCheckmarxPlugin(true); - -// // Enable state grouping -// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.MENU_GROUP_BY) -// .menu(PluginConstants.GROUP_BY_STATE_NAME).click(); - -// sleep(2000); - -// // Get all state groups -// List stateGroups = getStateGroups(); - -// // Verify order is alphabetical -// assertTrue(ASSERT_SORTED_BY_STATE, -// isAlphabeticallySorted(stateGroups)); - -// _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); -// } - -// private List getSeverityGroups() { -// List groups = new ArrayList<>(); -// SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; -// for (SWTBotTreeItem item : root.getItems()) { -// groups.add(item.getText().split("\\(")[0].trim()); -// } -// return groups; -// } - -// private List getStateGroups() { -// List groups = new ArrayList<>(); -// SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; -// for (SWTBotTreeItem item : root.getItems()) { -// groups.add(item.getText().split("\\(")[0].trim()); -// } -// return groups; -// } - -// private boolean isSortedBySeverity(List groups) { -// int highIndex = groups.indexOf("HIGH"); -// int mediumIndex = groups.indexOf("MEDIUM"); -// int lowIndex = groups.indexOf("LOW"); -// int infoIndex = groups.indexOf("INFO"); - -// return highIndex < mediumIndex && -// mediumIndex < lowIndex && -// lowIndex < infoIndex; -// } - -// private boolean isAlphabeticallySorted(List groups) { -// for (int i = 0; i < groups.size() - 1; i++) { -// if (groups.get(i).compareTo(groups.get(i + 1)) > 0) { -// return false; -// } -// } -// return true; -// } -// } \ No newline at end of file +package checkmarx.ast.eclipse.plugin.tests.ui; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeoutException; + +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.checkmarx.eclipse.utils.PluginConstants; + +@RunWith(SWTBotJunit4ClassRunner.class) +public class TestResultsSorting extends BaseUITest { + + private static final String ASSERT_SORTED_BY_SEVERITY = "Results should be sorted by severity"; + private static final String ASSERT_SORTED_BY_STATE = "Results should be sorted by state"; + + @Test + public void testSortBySeverity() throws TimeoutException { + setUpCheckmarxPlugin(true); + + // Enable severity grouping + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.MENU_GROUP_BY) + .menu(PluginConstants.GROUP_BY_SEVERITY).click(); + + sleep(2000); + + // Get all severity groups + List severityGroups = getSeverityGroups(); + + // Verify order: High -> Medium -> Low -> Info + assertTrue(ASSERT_SORTED_BY_SEVERITY, + isSortedBySeverity(severityGroups)); + + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } + + @Test + public void testSortByState() throws TimeoutException { + setUpCheckmarxPlugin(true); + + // Enable state grouping + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.MENU_GROUP_BY) + .menu(PluginConstants.GROUP_BY_STATE_NAME).click(); + + sleep(2000); + + // Get all state groups + List stateGroups = getStateGroups(); + + // Verify order is alphabetical + assertTrue(ASSERT_SORTED_BY_STATE, + isAlphabeticallySorted(stateGroups)); + + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } + + private List getSeverityGroups() { + List groups = new ArrayList<>(); + SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; + for (SWTBotTreeItem item : root.getItems()) { + groups.add(item.getText().split("\\(")[0].trim()); + } + return groups; + } + + private List getStateGroups() { + List groups = new ArrayList<>(); + SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; + for (SWTBotTreeItem item : root.getItems()) { + groups.add(item.getText().split("\\(")[0].trim()); + } + return groups; + } + + private boolean isSortedBySeverity(List groups) { + int highIndex = groups.indexOf("HIGH"); + int mediumIndex = groups.indexOf("MEDIUM"); + int lowIndex = groups.indexOf("LOW"); + int infoIndex = groups.indexOf("INFO"); + + return highIndex < mediumIndex && + mediumIndex < lowIndex && + lowIndex < infoIndex; + } + + private boolean isAlphabeticallySorted(List groups) { + for (int i = 0; i < groups.size() - 1; i++) { + if (groups.get(i).compareTo(groups.get(i + 1)) > 0) { + return false; + } + } + return true; + } +} \ No newline at end of file From 6cb7f3481e71da5dee1880101779caf99ee79196 Mon Sep 17 00:00:00 2001 From: elchananarb Date: Wed, 22 Jan 2025 12:19:53 +0200 Subject: [PATCH 13/13] Update TestResultsSorting.java --- .../plugin/tests/ui/TestResultsSorting.java | 69 +++++++++---------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java index e38ad6da..fbb5efd1 100644 --- a/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java +++ b/checkmarx-ast-eclipse-plugin-tests/src/test/java/checkmarx/ast/eclipse/plugin/tests/ui/TestResultsSorting.java @@ -11,7 +11,7 @@ import org.junit.Test; import org.junit.runner.RunWith; -import com.checkmarx.eclipse.utils.PluginConstants; +import com.checkmarx.eclipse.views.actions.ToolBarActions; @RunWith(SWTBotJunit4ClassRunner.class) public class TestResultsSorting extends BaseUITest { @@ -24,19 +24,15 @@ public void testSortBySeverity() throws TimeoutException { setUpCheckmarxPlugin(true); // Enable severity grouping - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.MENU_GROUP_BY) - .menu(PluginConstants.GROUP_BY_SEVERITY).click(); - - sleep(2000); + enableGrouping(ToolBarActions.GROUP_BY_SEVERITY); // Get all severity groups - List severityGroups = getSeverityGroups(); + List severityGroups = getGroups(); // Verify order: High -> Medium -> Low -> Info - assertTrue(ASSERT_SORTED_BY_SEVERITY, - isSortedBySeverity(severityGroups)); + assertTrue(ASSERT_SORTED_BY_SEVERITY, isSortedBySeverity(severityGroups)); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + closeCheckmarxView(); } @Test @@ -44,31 +40,24 @@ public void testSortByState() throws TimeoutException { setUpCheckmarxPlugin(true); // Enable state grouping - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu().menu(PluginConstants.MENU_GROUP_BY) - .menu(PluginConstants.GROUP_BY_STATE_NAME).click(); - - sleep(2000); + enableGrouping(ToolBarActions.GROUP_BY_STATE_NAME); // Get all state groups - List stateGroups = getStateGroups(); + List stateGroups = getGroups(); // Verify order is alphabetical - assertTrue(ASSERT_SORTED_BY_STATE, - isAlphabeticallySorted(stateGroups)); + assertTrue(ASSERT_SORTED_BY_STATE, isAlphabeticallySorted(stateGroups)); - _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + closeCheckmarxView(); } - private List getSeverityGroups() { - List groups = new ArrayList<>(); - SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; - for (SWTBotTreeItem item : root.getItems()) { - groups.add(item.getText().split("\\(")[0].trim()); - } - return groups; + private void enableGrouping(String groupingOption) { + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).viewMenu() + .menu(ToolBarActions.MENU_GROUP_BY).menu(groupingOption).click(); + sleep(2000); // Allow time for the grouping to take effect } - private List getStateGroups() { + private List getGroups() { List groups = new ArrayList<>(); SWTBotTreeItem root = _bot.tree(1).getAllItems()[0]; for (SWTBotTreeItem item : root.getItems()) { @@ -78,22 +67,32 @@ private List getStateGroups() { } private boolean isSortedBySeverity(List groups) { - int highIndex = groups.indexOf("HIGH"); - int mediumIndex = groups.indexOf("MEDIUM"); - int lowIndex = groups.indexOf("LOW"); - int infoIndex = groups.indexOf("INFO"); - - return highIndex < mediumIndex && - mediumIndex < lowIndex && - lowIndex < infoIndex; + List expectedOrder = List.of("HIGH", "MEDIUM", "LOW", "INFO"); + return isInExpectedOrder(groups, expectedOrder); } private boolean isAlphabeticallySorted(List groups) { for (int i = 0; i < groups.size() - 1; i++) { - if (groups.get(i).compareTo(groups.get(i + 1)) > 0) { + if (groups.get(i).compareToIgnoreCase(groups.get(i + 1)) > 0) { return false; } } return true; } -} \ No newline at end of file + + private boolean isInExpectedOrder(List actual, List expected) { + int previousIndex = -1; + for (String group : actual) { + int currentIndex = expected.indexOf(group); + if (currentIndex == -1 || currentIndex < previousIndex) { + return false; + } + previousIndex = currentIndex; + } + return true; + } + + private void closeCheckmarxView() { + _bot.viewByTitle(VIEW_CHECKMARX_AST_SCAN).close(); + } +}