Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
malkusch committed Nov 6, 2023
1 parent 6b5124a commit 4603aee
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/test/java/de/malkusch/km200/KM200Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
import static com.github.tomakehurst.wiremock.stubbing.Scenario.STARTED;
import static com.google.common.net.HttpHeaders.LOCATION;
import static de.malkusch.km200.KM200.RETRY_DISABLED;
import static de.malkusch.km200.KM200.USER_AGENT;
import static java.nio.charset.StandardCharsets.UTF_8;
Expand Down Expand Up @@ -74,6 +75,18 @@ public void queryShouldSucceedWith2xx(int status) throws Exception {
assertEquals("2021-09-21T10:49:25", dateTime);
}

@ParameterizedTest
@ValueSource(ints = { 301, 302, 303 })
public void queryShouldFollowRedirect(int status) throws Exception {
stubFor(get("/moved").willReturn(aResponse().withStatus(status).withHeader(LOCATION, "/new")));
stubFor(get("/new").willReturn(ok(loadBody("gateway.DateTime"))));
var km200 = new KM200(URI, TIMEOUT, GATEWAY_PASSWORD, PRIVATE_PASSWORD, SALT);

var dateTime = km200.queryString("/moved");

assertEquals("2021-09-21T10:49:25", dateTime);
}

@ParameterizedTest
@ValueSource(strings = { "http://localhost:" + PORT, "http://localhost:" + PORT + "/" })
public void queryShouldReplaceSlashesInURI(String uri) throws Exception {
Expand Down

0 comments on commit 4603aee

Please sign in to comment.