Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
moonraker595 committed Sep 13, 2024
1 parent 76b3f94 commit defdb90
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/test/java/org/icatproject/authn_db/DescriptionIT.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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
public class DescriptionIT {

@Test
public void getDescription() {
RestAssured.given()
given()
.when().get("/authn.db/description")
.then()
.statusCode(200)
Expand Down
33 changes: 10 additions & 23 deletions src/test/java/org/icatproject/authn_db/VersionIT.java
Original file line number Diff line number Diff line change
@@ -1,47 +1,34 @@
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;

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
Expand Down

0 comments on commit defdb90

Please sign in to comment.