-
Notifications
You must be signed in to change notification settings - Fork 6
Enhanced CI/CD, Configuration Management & Dependency Updates #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
1740e85
init commit
a14dbb3
init commit
aacb02a
init commit
bf394f9
init commit
3c6b26e
init commit
9a691b8
init commit
c5087e2
init commit
44bda81
init commit
6bd4682
init commit
2832cfc
init commit
c0e0436
init commit
73c1446
init commit
68e9648
init commit
0bcac45
init commit
8b6396e
init commit
654074c
init commit
1192991
init commit
02ebb1d
init commit
ec4b777
init commit
4b38f45
init commit
944bbf8
init commit
13f51c8
init commit
20995aa
init commit
faba95c
init commit
5622b2c
init commit
2f7cbbe
init commit
a6601d3
init commit
a46452a
refactored code base
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
common/src/main/java/com/cmccarthy/common/config/TestConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.cmccarthy.common.config; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Setter | ||
@Getter | ||
@Configuration | ||
@ConfigurationProperties(prefix = "test") | ||
public class TestConfiguration { | ||
|
||
// Main getters and setters | ||
private int maxRetries = 3; | ||
private int threadCount = 4; | ||
private int timeoutSeconds = 30; | ||
private boolean takeScreenshotOnFailure = true; | ||
private boolean enableDetailedReporting = true; | ||
private String defaultBrowser = "chrome"; | ||
|
||
// Parallel execution settings | ||
private ParallelExecution parallelExecution = new ParallelExecution(); | ||
|
||
// API testing settings | ||
private ApiConfig api = new ApiConfig(); | ||
|
||
// UI testing settings | ||
private UiConfig ui = new UiConfig(); | ||
|
||
@Setter | ||
@Getter | ||
public static class ParallelExecution { | ||
// getters and setters | ||
private boolean enabled = true; | ||
private int threadPoolSize = 4; | ||
private int dataProviderThreadCount = 4; | ||
} | ||
|
||
@Setter | ||
@Getter | ||
public static class ApiConfig { | ||
// getters and setters | ||
private int connectionTimeout = 30000; | ||
private int socketTimeout = 30000; | ||
private int maxRetries = 3; | ||
private boolean logRequestResponse = false; | ||
} | ||
|
||
@Setter | ||
@Getter | ||
public static class UiConfig { | ||
// getters and setters | ||
private boolean headless = true; | ||
private int implicitWait = 10; | ||
private int pageLoadTimeout = 30; | ||
private String windowSize = "1920x1080"; | ||
private boolean enableVideoRecording = false; | ||
} | ||
|
||
} |
80 changes: 79 additions & 1 deletion
80
common/src/main/java/com/cmccarthy/common/service/RestService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,14 +1,92 @@ | ||||||
package com.cmccarthy.common.service; | ||||||
|
||||||
import com.cmccarthy.common.config.TestConfiguration; | ||||||
import com.cmccarthy.common.utils.LogManager; | ||||||
import io.restassured.RestAssured; | ||||||
import io.restassured.config.HttpClientConfig; | ||||||
import io.restassured.config.RestAssuredConfig; | ||||||
import io.restassured.filter.log.RequestLoggingFilter; | ||||||
import io.restassured.filter.log.ResponseLoggingFilter; | ||||||
import io.restassured.response.Response; | ||||||
import io.restassured.specification.RequestSpecification; | ||||||
import jakarta.annotation.PostConstruct; | ||||||
import org.springframework.beans.factory.annotation.Autowired; | ||||||
import org.springframework.retry.annotation.Backoff; | ||||||
import org.springframework.retry.annotation.Retryable; | ||||||
import org.springframework.stereotype.Service; | ||||||
|
||||||
import static io.restassured.RestAssured.given; | ||||||
|
||||||
@Service | ||||||
public class RestService { | ||||||
|
||||||
@Autowired(required = false) | ||||||
private TestConfiguration testConfiguration; | ||||||
|
||||||
@Autowired(required = false) | ||||||
private LogManager logManager; | ||||||
|
||||||
@PostConstruct | ||||||
public void init() { | ||||||
if (testConfiguration != null) { | ||||||
setupRestAssuredConfig(); | ||||||
} | ||||||
} | ||||||
|
||||||
private void setupRestAssuredConfig() { | ||||||
TestConfiguration.ApiConfig apiConfig = testConfiguration.getApi(); | ||||||
|
||||||
RestAssured.config = RestAssuredConfig.config() | ||||||
.httpClient(HttpClientConfig.httpClientConfig() | ||||||
.setParam("http.connection.timeout", apiConfig.getConnectionTimeout()) | ||||||
.setParam("http.socket.timeout", apiConfig.getSocketTimeout())); | ||||||
|
||||||
if (apiConfig.isLogRequestResponse() && logManager != null) { | ||||||
RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter()); | ||||||
} | ||||||
} | ||||||
|
||||||
public RequestSpecification getRequestSpecification() { | ||||||
return given().header("Content-Type", "application/json"); | ||||||
return given() | ||||||
.header("Content-Type", "application/json") | ||||||
.accept("application/json"); | ||||||
} | ||||||
|
||||||
@Retryable(value = {Exception.class}, maxAttempts = 3, backoff = @Backoff(delay = 1000)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The retry maxAttempts is hard-coded to 3; consider using
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
public Response executeWithRetry(RequestSpecification request, String method, String endpoint) { | ||||||
if (logManager != null) { | ||||||
logManager.info("Executing " + method + " request to: " + endpoint); | ||||||
} | ||||||
|
||||||
Response response = switch (method.toUpperCase()) { | ||||||
case "GET" -> request.get(endpoint); | ||||||
case "POST" -> request.post(endpoint); | ||||||
case "PUT" -> request.put(endpoint); | ||||||
case "DELETE" -> request.delete(endpoint); | ||||||
default -> throw new IllegalArgumentException("Unsupported HTTP method: " + method); | ||||||
}; | ||||||
|
||||||
if (logManager != null) { | ||||||
logManager.info("Response status: " + response.getStatusCode()); | ||||||
logManager.debug("Response body: " + response.getBody().asString()); | ||||||
} | ||||||
|
||||||
return response; | ||||||
} | ||||||
|
||||||
public Response get(String endpoint) { | ||||||
return executeWithRetry(getRequestSpecification(), "GET", endpoint); | ||||||
} | ||||||
|
||||||
public Response post(String endpoint, Object body) { | ||||||
return executeWithRetry(getRequestSpecification().body(body), "POST", endpoint); | ||||||
} | ||||||
|
||||||
public Response put(String endpoint, Object body) { | ||||||
return executeWithRetry(getRequestSpecification().body(body), "PUT", endpoint); | ||||||
} | ||||||
|
||||||
public Response delete(String endpoint) { | ||||||
return executeWithRetry(getRequestSpecification(), "DELETE", endpoint); | ||||||
} | ||||||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spring Boot may not bind
@ConfigurationProperties
on a scanned@Configuration
class without enabling it; consider adding@EnableConfigurationProperties(TestConfiguration.class)
in your test context or using@ConfigurationPropertiesScan
.Copilot uses AI. Check for mistakes.