Skip to content

Commit

Permalink
Fix version endpoint and test (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
janinko authored Feb 6, 2024
1 parent 01391bd commit a6fbdc9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
</scm>

<properties>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.release>11</maven.compiler.release>
<mavenVersion>3.6.2</mavenVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static ComponentVersion getComponentVersion() {
ComponentVersion quarkus = ComponentVersion.builder().name("Quarkus").version(getQuarkusVersion()).build();

return ComponentVersion.builder()
.name("Deliverables Analyzer")
.version(getVersionNumber())
.commit(getScmRevision())
.builtOn(ZonedDateTime.parse(getBuildDate()))
Expand All @@ -78,7 +79,7 @@ private static String getAppProperty(String name) {
return PROPERTIES.getProperty(name, "unknown");
}

private static String getVersionNumber() {
public static String getVersionNumber() {
return getAppProperty("version");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
package org.jboss.pnc.deliverablesanalyzer.rest;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.emptyOrNullString;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.equalTo;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
Expand All @@ -46,17 +43,15 @@ static void init() {
void testVersion() {
String version = given().log()
.all()
.accept(MediaType.TEXT_PLAIN)
.accept(MediaType.APPLICATION_JSON)
.when()
.get("/api/version")
.then()
.log()
.all()
.statusCode(Response.Status.OK.getStatusCode())
.body(
not(is(emptyOrNullString())),
not(containsString("unknown")),
containsString(Version.getVersion()))
.body("name", equalTo("Deliverables Analyzer"))
.body("version", equalTo(Version.getVersionNumber()))
.extract()
.response()
.asString();
Expand Down

0 comments on commit a6fbdc9

Please sign in to comment.