From 47db92836b279c1523737e86d684646b1495e12d Mon Sep 17 00:00:00 2001 From: Chris Simmons Date: Mon, 5 Jun 2023 15:14:34 -0700 Subject: [PATCH] Refactor mocks --- src/test/java/AuthFailureTest.java | 12 +++++------- src/test/java/TestBase.java | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/test/java/AuthFailureTest.java b/src/test/java/AuthFailureTest.java index 9649885..bb75169 100644 --- a/src/test/java/AuthFailureTest.java +++ b/src/test/java/AuthFailureTest.java @@ -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")); } } diff --git a/src/test/java/TestBase.java b/src/test/java/TestBase.java index a4480d8..cbefb35 100644 --- a/src/test/java/TestBase.java +++ b/src/test/java/TestBase.java @@ -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();