Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/test-execution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ jobs:
- name: Build with Maven
run: mvn -q -B -DskipTests package --file pom.xml

- name: Run Health Check Tests
run: mvn -q -B test -Dgroups="health"

- name: Run Contract Tests
run: mvn -q -B test -Dgroups="contract"

Expand Down
39 changes: 23 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,37 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.8.0] - 12-01-2026

### Added

- Thread-safe caching JUnit Extension mechanism in `EnvironmentAvailabilityExtension` to ensure the health check runs
only once per test suite execution.

## [2.7.0] - 04-01-2026

### Changed

- Adoption of Java 25
- Set `java.version` to 25
- Changed `actions/setup-java@v4` in `.github/workflows/test-execution.yml` to Java 25
- Set `java.version` to 25
- Changed `actions/setup-java@v4` in `.github/workflows/test-execution.yml` to Java 25
- Renamed `MessageFormat` to `LocationUrlResolver` and updated usages
- Updated CPF generation to avoid deprecated DataFaker API
- Updated the following dependencies
- `maven-compiler-plugin.version -> 3.14.1`
- `maven-surefire-plugin.version -> 3.5.4`
- `restassured.version -> 6.0.0`
- `junit.jupiter.version -> 6.0.1`
- `assertj.version -> 3.27.6`
- `datafaker.version -> 2.5.3`
- `log4j.version -> 2.25.3`
- `slf4j.version -> 2.0.17`
- `allure.version -> 2.32.0`
- `allure-maven.version -> 2.17.0`
- `aspectj.version -> 1.9.25.1`
- `commons-codec.version -> 1.20.0`
- `jackson-databind.version -> 3.0.3`
- `rhino.version -> 1.9.0`
- `maven-compiler-plugin.version -> 3.14.1`
- `maven-surefire-plugin.version -> 3.5.4`
- `restassured.version -> 6.0.0`
- `junit.jupiter.version -> 6.0.1`
- `assertj.version -> 3.27.6`
- `datafaker.version -> 2.5.3`
- `log4j.version -> 2.25.3`
- `slf4j.version -> 2.0.17`
- `allure.version -> 2.32.0`
- `allure-maven.version -> 2.17.0`
- `aspectj.version -> 1.9.25.1`
- `commons-codec.version -> 1.20.0`
- `jackson-databind.version -> 3.0.3`
- `rhino.version -> 1.9.0`
- Added `junit-platform-launcher` (test scope)
- Removed `allure-testng`

Expand Down
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* MIT License
*
* Copyright (c) 2026 Elias Nogueira
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.eliasnogueira.credit.extensions;

import com.eliasnogueira.credit.config.ConfigurationManager;
import io.restassured.RestAssured;
import org.apache.http.HttpStatus;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

import static io.restassured.config.ConnectionConfig.connectionConfig;

public class EnvironmentAvailabilityExtension implements BeforeAllCallback {

private static Boolean isEnvironmentReady;

private static final Logger log = LogManager.getLogger(EnvironmentAvailabilityExtension.class);

@Override
public void beforeAll(ExtensionContext context) {
if (isEnvironmentReady == null) checkEnvironmentHealth();

Assumptions.assumeTrue(isEnvironmentReady, "Environment is not available.");
}

private synchronized void checkEnvironmentHealth() {
if (isEnvironmentReady != null) return;

try {
RestAssured.given()
.baseUri(buildHealthUrlString())
.config(RestAssured.config().connectionConfig(connectionConfig()
.closeIdleConnectionsAfterEachResponse()))
.when().get().then().statusCode(HttpStatus.SC_OK);

isEnvironmentReady = true;
} catch (Exception e) {
log.error("Environment is not available. Check it before running the tests.");
log.error("Endpoint used: {}", buildHealthUrlString());
log.error("Exception: {}", e.getMessage());
isEnvironmentReady = false;
}
}

private String buildHealthUrlString() {
var config = ConfigurationManager.getConfiguration();
return String.format("%s:%s%s/health", config.baseURI(), config.port(), config.health());
}
}
3 changes: 3 additions & 0 deletions src/test/java/com/eliasnogueira/credit/BaseAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@

import com.eliasnogueira.credit.config.Configuration;
import com.eliasnogueira.credit.config.ConfigurationManager;
import com.eliasnogueira.credit.extensions.EnvironmentAvailabilityExtension;
import io.restassured.RestAssured;
import io.restassured.config.SSLConfig;
import io.restassured.filter.log.RequestLoggingFilter;
import io.restassured.filter.log.ResponseLoggingFilter;
import io.restassured.path.json.config.JsonPathConfig.NumberReturnType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.extension.ExtendWith;

import static io.restassured.RestAssured.basePath;
import static io.restassured.RestAssured.baseURI;
Expand All @@ -39,6 +41,7 @@
import static io.restassured.config.JsonConfig.jsonConfig;
import static io.restassured.config.RestAssuredConfig.newConfig;

@ExtendWith(EnvironmentAvailabilityExtension.class)
public abstract class BaseAPI {

protected static Configuration configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@

import com.eliasnogueira.credit.client.RestrictionsClient;
import com.eliasnogueira.credit.client.SimulationsClient;
import com.eliasnogueira.credit.extensions.EnvironmentAvailabilityExtension;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import static com.eliasnogueira.credit.data.changeless.TestSuiteTags.E2E;
import static org.apache.http.HttpStatus.SC_NOT_FOUND;
import static org.assertj.core.api.Assertions.assertThat;

@ExtendWith(EnvironmentAvailabilityExtension.class)
class FullSimulationE2ETest {

private final RestrictionsClient restrictionsClient = new RestrictionsClient();
Expand Down

This file was deleted.