Skip to content

Commit

Permalink
Use Response.Status.OK instead of HTTP_OK (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwalluck authored Nov 9, 2024
1 parent b2a1426 commit 92cc52a
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
import static java.net.HttpURLConnection.HTTP_OK;
import static jakarta.ws.rs.core.Response.Status.OK;
import static org.jboss.pnc.api.dto.Request.Method.GET;
import static org.jboss.pnc.api.dto.Request.Method.POST;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down Expand Up @@ -53,12 +53,12 @@
@QuarkusTest
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class HttpClientTest {
@Inject
HttpClient httpClient;
private final WireMockServer wiremock = new WireMockServer(options().port(PORT));

protected static final int PORT = 8082;

private final WireMockServer wiremock = new WireMockServer(options().port(PORT));
@Inject
HttpClient httpClient;

@BeforeAll
void beforeAll() {
Expand All @@ -81,7 +81,7 @@ void testSimplePerformHttpRequest() throws Exception {
String relativePath = "/testSimplePerformHttpRequest";
String fullUrl = "http://localhost:" + PORT + relativePath;
Request request = new Request(GET, new URI(fullUrl));
wiremock.stubFor(get(urlEqualTo(relativePath)).willReturn(aResponse().withStatus(HTTP_OK)));
wiremock.stubFor(get(urlEqualTo(relativePath)).willReturn(aResponse().withStatus(OK.getStatusCode())));

// when
httpClient.performHttpRequest(request);
Expand All @@ -96,7 +96,7 @@ void testSimplePerformHttpRequestFailsafe() throws URISyntaxException {
String relativePath = "/testSimplePerformHttpRequest";
String fullUrl = "http://localhost:" + PORT + relativePath;
Request request = new Request(GET, new URI(fullUrl + "anything"));
wiremock.stubFor(get(urlEqualTo(relativePath)).willReturn(aResponse().withStatus(HTTP_OK)));
wiremock.stubFor(get(urlEqualTo(relativePath)).willReturn(aResponse().withStatus(OK.getStatusCode())));

// when - then
assertThrows(IOException.class, () -> httpClient.performHttpRequest(request));
Expand All @@ -120,7 +120,7 @@ void testAdvancedPerformHttpRequest() throws Exception {

Request request = new Request(POST, new URI(fullUrl));

wiremock.stubFor(post(urlEqualTo(relativePath)).willReturn(aResponse().withStatus(HTTP_OK)));
wiremock.stubFor(post(urlEqualTo(relativePath)).willReturn(aResponse().withStatus(OK.getStatusCode())));

// when
httpClient.performHttpRequest(request, new TestPayload(1, "str"));
Expand Down

0 comments on commit 92cc52a

Please sign in to comment.