Skip to content

Commit

Permalink
Refactor mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSimmons committed Jun 5, 2023
1 parent 8119fcd commit 47db928
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/test/java/AuthFailureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ public void stopProxy() {
}

private void createMock(final int statusCode) {
final MockServerClient client = new MockServerClient("127.0.0.1", 1081);

client.when(request().withMethod("POST").withPath("/oauth2/token"))
.respond(response().withStatusCode(statusCode));
client.when(request().withMethod("GET").withPath("/search/images")
.withQueryStringParameters(new Parameter("phrase", "cat")))
.respond(response().withStatusCode(200).withBody("success"));
authClientMock.when(request().withMethod("POST").withPath("/oauth2/token"))
.respond(response().withStatusCode(statusCode));
apiClientMock.when(request().withMethod("GET").withPath("/search/images")
.withQueryStringParameters(new Parameter("phrase", "cat")))
.respond(response().withStatusCode(200).withBody("success"));
}
}
4 changes: 2 additions & 2 deletions src/test/java/TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
public class TestBase {
private ClientAndServer apiServerMock;
protected MockServerClient apiClientMock;
private ClientAndServer authServerMock;
private MockServerClient authClientMock;
protected ClientAndServer authServerMock;
protected MockServerClient authClientMock;

protected void startMockServersAndSetupAuth() throws Exception {
startMockServers();
Expand Down

0 comments on commit 47db928

Please sign in to comment.