From 77ce90c8d95fd8118b8d25cd6d8c5cae13a016d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?James=20Pether=20S=C3=B6rling?= Date: Fri, 17 Jan 2025 01:11:56 +0100 Subject: [PATCH] refactor: replace hardcoded MAX_RETRIES with TestConstants.DEFAULT_MAX_RETRIES in integration tests --- .../systemintegrationtest/admin/AdminEmailTest.java | 4 ++-- .../user/AuthorizationTest.java | 4 ++-- .../systemintegrationtest/user/PartyViewTest.java | 5 ++--- .../systemintegrationtest/user/SearchViewTest.java | 1 - .../user/SessionManagementTest.java | 7 ++----- .../user/UserAuthenticationTest.java | 13 ++++++------- .../user/UserNavigationTest.java | 13 ++++++------- .../user/ViewNavigationTest.java | 10 +++++----- 8 files changed, 25 insertions(+), 32 deletions(-) diff --git a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/admin/AdminEmailTest.java b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/admin/AdminEmailTest.java index a3a6b46406..8e930f8ce3 100644 --- a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/admin/AdminEmailTest.java +++ b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/admin/AdminEmailTest.java @@ -22,7 +22,7 @@ public void shouldSendValidEmail() { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = TestConstants.DEFAULT_TIMEOUT) @@ -36,6 +36,6 @@ public void shouldFailWithInvalidEmail() { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } } diff --git a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/AuthorizationTest.java b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/AuthorizationTest.java index 23bd3c1801..e9c90584f9 100644 --- a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/AuthorizationTest.java +++ b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/AuthorizationTest.java @@ -26,7 +26,7 @@ public void shouldDenyAccessToAdminPages() { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } catch (Exception e) { throw new RuntimeException(e); } @@ -46,7 +46,7 @@ public void shouldAllowAccessToPublicPages() { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/PartyViewTest.java b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/PartyViewTest.java index e6550cff35..fad9595720 100644 --- a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/PartyViewTest.java +++ b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/PartyViewTest.java @@ -10,7 +10,6 @@ @Category(IntegrationTest.class) public final class PartyViewTest extends AbstractUITest { - private static final int MAX_RETRIES = 3; @Test(timeout = DEFAULT_TIMEOUT) public void shouldViewPartyCommitteeRoles() throws Exception { @@ -22,7 +21,7 @@ public void shouldViewPartyCommitteeRoles() throws Exception { throw new RuntimeException("Failed to visit party committee roles page", e); } pageVisit.verifyPageContent("Committee Roles"); - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = DEFAULT_TIMEOUT) @@ -35,7 +34,7 @@ public void shouldViewPartyDocumentHistory() throws Exception { e.printStackTrace(); } pageVisit.verifyPageContent("Document History"); - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } // ... other party view tests diff --git a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/SearchViewTest.java b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/SearchViewTest.java index 9f6a20d4f3..25005a76e3 100644 --- a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/SearchViewTest.java +++ b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/SearchViewTest.java @@ -9,7 +9,6 @@ @Category(IntegrationTest.class) public class SearchViewTest extends AbstractUITest { - private static final int DEFAULT_MAX_RETRIES = 3; @Test(timeout = DEFAULT_TIMEOUT) public void testSearch() throws Exception { diff --git a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/SessionManagementTest.java b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/SessionManagementTest.java index 4965684686..dcc61938f1 100644 --- a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/SessionManagementTest.java +++ b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/SessionManagementTest.java @@ -10,10 +10,7 @@ @Category(IntegrationTest.class) public final class SessionManagementTest extends AbstractUITest { - private static final int DEFAULT_MAX_RETRIES = 3; - private static final int MAX_RETRIES = 3; - private static final int DEFAULT_TIMEOUT = 60000; - + @Test(timeout = DEFAULT_TIMEOUT) public void shouldHandleSessionPagination() throws Exception { retryOnFailure(() -> { @@ -51,6 +48,6 @@ public void shouldShowSessionDetails() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } } diff --git a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/UserAuthenticationTest.java b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/UserAuthenticationTest.java index 7db6254510..975b3a4875 100644 --- a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/UserAuthenticationTest.java +++ b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/UserAuthenticationTest.java @@ -15,7 +15,6 @@ @Category(IntegrationTest.class) public final class UserAuthenticationTest extends AbstractUITest { - private static final int MAX_RETRIES = TestConstants.DEFAULT_MAX_RETRIES; private static final String EMAIL_SUFFIX = "@test.com"; private static final String PATH_PREFIX = "main/"; private static final String ERROR_USER_EXISTS = "USER_ALREADY_EXISTS"; @@ -46,7 +45,7 @@ public void shouldRegisterNewUser() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = TestConstants.DEFAULT_TIMEOUT) @@ -66,7 +65,7 @@ public void shouldRegisterUserWithWeakPasswordFail() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = TestConstants.DEFAULT_TIMEOUT) @@ -93,7 +92,7 @@ public void shouldNotRegisterDuplicateUser() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = TestConstants.DEFAULT_TIMEOUT) @@ -128,7 +127,7 @@ public void shouldManageUserSecurity() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = TestConstants.DEFAULT_TIMEOUT) @@ -152,7 +151,7 @@ public void shouldFailLoginWithWrongPassword() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = TestConstants.DEFAULT_TIMEOUT) @@ -179,6 +178,6 @@ public void shouldEnableAndDisableGoogleAuthenticator() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } } diff --git a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/UserNavigationTest.java b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/UserNavigationTest.java index 9472d8d155..55a564c471 100644 --- a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/UserNavigationTest.java +++ b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/UserNavigationTest.java @@ -13,7 +13,6 @@ @Category(IntegrationTest.class) public final class UserNavigationTest extends AbstractUITest { - private static final int MAX_RETRIES = 3; // Constants for page modes private static final String DOCUMENT_ACTIVITY = "DOCUMENTACTIVITY"; private static final String ROLE_SUMMARY = "ROLESUMMARY"; @@ -43,7 +42,7 @@ public void shouldNavigatePoliticianViews() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = DEFAULT_TIMEOUT) @@ -67,7 +66,7 @@ public void shouldNavigateParliamentViews() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = DEFAULT_TIMEOUT) @@ -79,7 +78,7 @@ public void shouldNavigateCommitteeRanking() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = DEFAULT_TIMEOUT) @@ -91,7 +90,7 @@ public void shouldNavigateMinistryRanking() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = DEFAULT_TIMEOUT) @@ -106,7 +105,7 @@ public void shouldNavigatePartyRanking() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = DEFAULT_TIMEOUT) @@ -118,7 +117,7 @@ public void shouldNavigatePoliticianRanking() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } // Other navigation tests... diff --git a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/ViewNavigationTest.java b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/ViewNavigationTest.java index 8a7f78c9f9..ae9a6b3b4a 100644 --- a/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/ViewNavigationTest.java +++ b/citizen-intelligence-agency/src/test/java/com/hack23/cia/systemintegrationtest/user/ViewNavigationTest.java @@ -25,7 +25,7 @@ public void shouldNavigateCommitteeRanking() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = DEFAULT_TIMEOUT) @@ -37,7 +37,7 @@ public void shouldNavigateMinistryRanking() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = DEFAULT_TIMEOUT) @@ -49,7 +49,7 @@ public void shouldNavigatePartyRanking() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = DEFAULT_TIMEOUT) @@ -61,7 +61,7 @@ public void shouldNavigatePoliticianRanking() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } @Test(timeout = DEFAULT_TIMEOUT) @@ -80,6 +80,6 @@ public void shouldNavigatePoliticianViews() throws Exception { } catch (Exception e) { throw new RuntimeException(e); } - }, DEFAULT_MAX_RETRIES); + }, TestConstants.DEFAULT_MAX_RETRIES); } }