diff --git a/src/test/java/org/icatproject/authn_db/DescriptionIT.java b/src/test/java/org/icatproject/authn_db/DescriptionIT.java index 38f134c..72784b9 100644 --- a/src/test/java/org/icatproject/authn_db/DescriptionIT.java +++ b/src/test/java/org/icatproject/authn_db/DescriptionIT.java @@ -1,9 +1,9 @@ package org.icatproject.authn_db; import io.quarkus.test.junit.QuarkusIntegrationTest; -import io.restassured.RestAssured; import org.junit.jupiter.api.Test; +import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; @QuarkusIntegrationTest @@ -11,7 +11,7 @@ public class DescriptionIT { @Test public void getDescription() { - RestAssured.given() + given() .when().get("/authn.db/description") .then() .statusCode(200) diff --git a/src/test/java/org/icatproject/authn_db/VersionIT.java b/src/test/java/org/icatproject/authn_db/VersionIT.java index ec98168..e882051 100644 --- a/src/test/java/org/icatproject/authn_db/VersionIT.java +++ b/src/test/java/org/icatproject/authn_db/VersionIT.java @@ -1,12 +1,11 @@ package org.icatproject.authn_db; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.equalTo; import io.quarkus.test.junit.QuarkusIntegrationTest; -import io.restassured.RestAssured; -import jakarta.json.Json; -import jakarta.json.JsonObject; -import jakarta.json.JsonReader; + +import jakarta.ws.rs.core.Response; import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -14,34 +13,22 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; -import java.io.StringReader; @QuarkusIntegrationTest public class VersionIT { @Test public void testVersion() throws Exception { + // Get the version from the pom.xml String expectedVersion = getVersionFromPom(); - // Send a request to the version endpoint - String versionResponse = RestAssured.given() - .when().get("/authn.db/version") + given() + .when() + .get("/authn.db/version") .then() - .statusCode(200) - .extract().asString(); - - // Parse the JSON response - JsonObject versionJson; - try (JsonReader jsonReader = Json.createReader(new StringReader(versionResponse))) { - versionJson = jsonReader.readObject(); - } - - // Extract the version from the JSON object - String actualVersion = versionJson.getString("version"); - - // Assert that the version matches the expected version from the pom.xml - assertEquals(expectedVersion, actualVersion); + .statusCode(Response.Status.OK.getStatusCode()) + .body("version", equalTo(expectedVersion)); } // Helper method to load the version from the pom.xml