diff --git a/NEWS.md b/NEWS.md index c425885..b25abc2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +## 4.9.2 2022-08-19 + +* [EDGPATRON-96](https://issues.folio.org/browse/EDGPATRON-96): Suppress headers, edge-common 4.4.0, fix timeout, enable compression + ## 4.9.1 2022-06-30 * [EDGPATRON-15](https://issues.folio.org/browse/EDGPATRON-15): Fix sonar code smells diff --git a/pom.xml b/pom.xml index c6fdece..bdcfbbc 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.folio edge-patron - 4.9.2-SNAPSHOT + 4.9.3-SNAPSHOT jar Edge API - Patron Empowerment @@ -107,7 +107,7 @@ org.folio edge-common - 4.3.0 + 4.4.0 diff --git a/src/main/java/org/folio/edge/patron/PatronHandler.java b/src/main/java/org/folio/edge/patron/PatronHandler.java index ed880c0..d20edc7 100644 --- a/src/main/java/org/folio/edge/patron/PatronHandler.java +++ b/src/main/java/org/folio/edge/patron/PatronHandler.java @@ -32,7 +32,6 @@ import java.util.List; import java.util.Map; import java.util.TimeZone; -import java.util.concurrent.TimeoutException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.folio.edge.core.Handler; @@ -87,7 +86,7 @@ protected void handleCommon(RoutingContext ctx, String[] requiredParams, String[ action.apply(patronClient, params); }) .onFailure(t -> { - if (t instanceof TimeoutException) { + if (isTimeoutException(t)) { requestTimeout(ctx, t.getMessage()); } else { notFound(ctx, "Unable to find patron " + extPatronId); @@ -116,7 +115,6 @@ public void handleGetAccount(RoutingContext ctx) { sortBy, limit, offset, - ctx.request().headers(), resp -> handleProxyResponse(ctx, resp), t -> handleProxyException(ctx, t)); }); @@ -129,7 +127,6 @@ public void handleRenew(RoutingContext ctx) { (client, params) -> ((PatronOkapiClient) client).renewItem( params.get(PARAM_PATRON_ID), params.get(PARAM_ITEM_ID), - ctx.request().headers(), resp -> handleProxyResponse(ctx, resp), t -> handleProxyException(ctx, t))); @@ -144,7 +141,6 @@ public void handlePlaceItemHold(RoutingContext ctx) { params.get(PARAM_PATRON_ID), params.get(PARAM_ITEM_ID), body, - ctx.request().headers().remove(CONTENT_LENGTH), //removing content-length header here as the new message's size isn't the same it was originally resp -> handleProxyResponse(ctx, resp), t -> handleProxyException(ctx, t))); } @@ -169,7 +165,6 @@ public void handleCancelHold(RoutingContext ctx) { params.get(PARAM_PATRON_ID), params.get(PARAM_HOLD_ID), ctx.body().asJsonObject(), - ctx.request().headers().remove(CONTENT_LENGTH), resp -> handleProxyResponse(ctx, resp), t -> handleProxyException(ctx, t)) ); @@ -184,7 +179,6 @@ public void handlePlaceInstanceHold(RoutingContext ctx) { params.get(PARAM_PATRON_ID), params.get(PARAM_INSTANCE_ID), body, - ctx.request().headers().remove(CONTENT_LENGTH), //removing content-length header here as the new message's size isn't the same it was originally resp -> handleProxyResponse(ctx, resp), t -> handleProxyException(ctx, t))); } @@ -264,7 +258,7 @@ protected void handleProxyResponse(RoutingContext ctx, HttpResponse resp @Override protected void handleProxyException(RoutingContext ctx, Throwable t) { logger.error("Exception calling OKAPI", t); - if (t instanceof TimeoutException) { + if (isTimeoutException(t)) { requestTimeout(ctx, t.getMessage()); } else { internalServerError(ctx, t.getMessage()); diff --git a/src/main/java/org/folio/edge/patron/utils/PatronOkapiClient.java b/src/main/java/org/folio/edge/patron/utils/PatronOkapiClient.java index 0c8c284..199f750 100644 --- a/src/main/java/org/folio/edge/patron/utils/PatronOkapiClient.java +++ b/src/main/java/org/folio/edge/patron/utils/PatronOkapiClient.java @@ -7,7 +7,6 @@ import org.folio.edge.core.utils.OkapiClient; import io.vertx.core.Future; import io.vertx.core.Handler; -import io.vertx.core.MultiMap; import io.vertx.core.Promise; import io.vertx.core.Vertx; import io.vertx.core.json.JsonObject; @@ -71,15 +70,8 @@ public Future getPatron(String extPatronId) { return promise.future(); } - public void getAccount(String patronId, boolean includeLoans, boolean includeCharges, - boolean includeHolds, String sortBy, String limit, String offset, Handler> responseHandler, - Handler exceptionHandler) { - getAccount(patronId, includeLoans, includeCharges, includeHolds, sortBy, limit, offset, null, - responseHandler, exceptionHandler); - } - public void getAccount(String patronId, boolean includeLoans, boolean includeCharges, boolean includeHolds, - String sortBy, String limit, String offset, MultiMap headers, Handler> responseHandler, + String sortBy, String limit, String offset, Handler> responseHandler, Handler exceptionHandler) { String url = String.format("%s/patron/account/%s?includeLoans=%s&includeCharges=%s&includeHolds=%s", okapiURL, @@ -100,62 +92,36 @@ public void getAccount(String patronId, boolean includeLoans, boolean includeCha get( url, tenant, - combineHeadersWithDefaults(headers), + null, responseHandler, exceptionHandler); } public void renewItem(String patronId, String itemId, Handler> responseHandler, Handler exceptionHandler) { - renewItem(patronId, itemId, null, responseHandler, exceptionHandler); - } - - public void renewItem(String patronId, String itemId, MultiMap headers, - Handler> responseHandler, Handler exceptionHandler) { post( String.format("%s/patron/account/%s/item/%s/renew", okapiURL, patronId, itemId), tenant, null, - combineHeadersWithDefaults(headers), - responseHandler, - exceptionHandler); - } - - public void placeItemHold(String patronId, String itemId, String requestBody, - Handler> responseHandler, Handler exceptionHandler) { - placeItemHold(patronId, - itemId, - requestBody, null, responseHandler, exceptionHandler); } - public void placeItemHold(String patronId, String itemId, String requestBody, MultiMap headers, + public void placeItemHold(String patronId, String itemId, String requestBody, Handler> responseHandler, Handler exceptionHandler) { post( String.format("%s/patron/account/%s/item/%s/hold", okapiURL, patronId, itemId), tenant, requestBody, - combineHeadersWithDefaults(headers), + null, responseHandler, exceptionHandler); } - public void cancelHold(String patronId, String holdId, JsonObject requestBody, + public void cancelHold(String patronId, String holdId, JsonObject holdCancellationRequest, Handler> responseHandler, Handler exceptionHandler) { - cancelHold(patronId, - holdId, - requestBody, - null, - responseHandler, - exceptionHandler); - } - - public void cancelHold(String patronId, String holdId, JsonObject holdCancellationRequest, MultiMap headers, - Handler> responseHandler, Handler exceptionHandler) { getRequest(holdId, - headers, resp -> { if (resp.statusCode() == 200) { String bodyStr = resp.bodyAsString(); @@ -166,7 +132,7 @@ public void cancelHold(String patronId, String holdId, JsonObject holdCancellati String.format("%s/patron/account/%s/hold/%s/cancel", okapiURL, patronId, holdId), tenant, holdEntity.toJson(), - combineHeadersWithDefaults(headers), + null, responseHandler, exceptionHandler); } catch (Exception ex) { @@ -183,39 +149,23 @@ public void cancelHold(String patronId, String holdId, JsonObject holdCancellati public void getRequest(String holdId, Handler> responseHandler, Handler exceptionHandler) { - getRequest(holdId, null, responseHandler, exceptionHandler); - } - - public void getRequest(String holdId, MultiMap headers, - Handler> responseHandler, Handler exceptionHandler) { - String url = String.format("%s/circulation/requests/%s", okapiURL, holdId); get( url, tenant, - combineHeadersWithDefaults(headers), + null, responseHandler, exceptionHandler); } public void placeInstanceHold(String patronId, String instanceId, String requestBody, Handler> responseHandler, Handler exceptionHandler) { - placeInstanceHold(patronId, - instanceId, - requestBody, - null, - responseHandler, - exceptionHandler); - } - - public void placeInstanceHold(String patronId, String instanceId, String requestBody, MultiMap headers, - Handler> responseHandler, Handler exceptionHandler) { post( String.format("%s/patron/account/%s/instance/%s/hold", okapiURL, patronId, instanceId), tenant, requestBody, - combineHeadersWithDefaults(headers), + null, responseHandler, exceptionHandler); } diff --git a/src/test/java/org/folio/edge/patron/MainVerticleTest.java b/src/test/java/org/folio/edge/patron/MainVerticleTest.java index ef51000..8f5e433 100644 --- a/src/test/java/org/folio/edge/patron/MainVerticleTest.java +++ b/src/test/java/org/folio/edge/patron/MainVerticleTest.java @@ -6,9 +6,9 @@ import static org.folio.edge.core.Constants.SYS_OKAPI_URL; import static org.folio.edge.core.Constants.SYS_PORT; import static org.folio.edge.core.Constants.SYS_REQUEST_TIMEOUT_MS; +import static org.folio.edge.core.Constants.SYS_RESPONSE_COMPRESSION; import static org.folio.edge.core.Constants.SYS_SECURE_STORE_PROP_FILE; import static org.folio.edge.core.Constants.TEXT_PLAIN; -import static org.folio.edge.core.utils.test.MockOkapi.X_DURATION; import static org.folio.edge.patron.Constants.MSG_ACCESS_DENIED; import static org.folio.edge.patron.Constants.MSG_REQUEST_TIMEOUT; import static org.folio.edge.patron.utils.PatronMockOkapi.holdCancellationHoldId; @@ -20,9 +20,9 @@ import static org.folio.edge.patron.utils.PatronMockOkapi.nonUUIDHoldCanceledByPatronId; import static org.folio.edge.patron.utils.PatronMockOkapi.offset_param; import static org.folio.edge.patron.utils.PatronMockOkapi.wrongIntegerParamMessage; +import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import static org.junit.Assert.assertNull; import static org.mockito.Matchers.any; import static org.mockito.Mockito.atLeast; @@ -49,6 +49,7 @@ import org.folio.edge.patron.model.Hold; import org.folio.edge.patron.model.Loan; import org.folio.edge.patron.utils.PatronMockOkapi; +import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -56,11 +57,12 @@ import org.junit.runner.RunWith; import io.restassured.RestAssured; +import io.restassured.config.DecoderConfig; +import io.restassured.config.DecoderConfig.ContentDecoder; import io.restassured.response.Response; import io.vertx.core.DeploymentOptions; import io.vertx.core.Vertx; -import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; @@ -91,19 +93,22 @@ public static void setUpOnce(TestContext context) throws Exception { List knownTenants = new ArrayList<>(); knownTenants.add(ApiKeyUtils.parseApiKey(apiKey).tenantId); - mockOkapi = spy(new PatronMockOkapi(okapiPort, knownTenants)); - mockOkapi.start(context); - vertx = Vertx.vertx(); System.setProperty(SYS_PORT, String.valueOf(serverPort)); System.setProperty(SYS_OKAPI_URL, "http://localhost:" + okapiPort); System.setProperty(SYS_SECURE_STORE_PROP_FILE, "src/main/resources/ephemeral.properties"); System.setProperty(SYS_LOG_LEVEL, "DEBUG"); + System.setProperty(SYS_RESPONSE_COMPRESSION, "true"); System.setProperty(SYS_REQUEST_TIMEOUT_MS, String.valueOf(requestTimeoutMs)); - final DeploymentOptions opt = new DeploymentOptions(); - vertx.deployVerticle(MainVerticle.class.getName(), opt, context.asyncAssertSuccess()); + mockOkapi = spy(new PatronMockOkapi(okapiPort, knownTenants)); + mockOkapi.start() + .compose(x -> { + final DeploymentOptions opt = new DeploymentOptions(); + return vertx.deployVerticle(MainVerticle.class.getName(), opt); + }) + .onComplete(context.asyncAssertSuccess()); RestAssured.baseURI = "http://localhost:" + serverPort; RestAssured.port = serverPort; @@ -113,19 +118,15 @@ public static void setUpOnce(TestContext context) throws Exception { @AfterClass public static void tearDownOnce(TestContext context) { logger.info("Shutting down server"); - final Async async = context.async(); - vertx.close(res -> { - if (res.failed()) { - logger.error("Failed to shut down edge-patron server", res.cause()); - fail(res.cause().getMessage()); - } else { - logger.info("Successfully shut down edge-patron server"); - } - - logger.info("Shutting down mock Okapi"); - mockOkapi.close(context); - async.complete(); - }); + mockOkapi.close() + .compose(x -> vertx.close()) + .onSuccess(x -> logger.info("Successfully shut down mock Okapi and edge-patron server")) + .onComplete(context.asyncAssertSuccess()); + } + + @After + public void after() { + mockOkapi.setDelay(0); } @Test @@ -187,18 +188,48 @@ public void testGetAccountBadApiKey(TestContext context) throws Exception { public void testGetAccountPatronFound(TestContext context) throws Exception { logger.info("=== Test request where patron is found ==="); - final Response resp = RestAssured + final String expected = PatronMockOkapi.getAccountJson(patronId, false, false, false); + + RestAssured + .get(String.format("/patron/account/%s?apikey=%s", extPatronId, apiKey)) + .then() + .statusCode(200) + .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) + .body(is(expected)); + } + + @Test + public void testGetAccountPatronFoundGzip(TestContext context) throws Exception { + logger.info("=== Patron in GZip compression ==="); + + final String expected = PatronMockOkapi.getAccountJson(patronId, false, false, false); + + RestAssured.given() + .config(RestAssured.config().decoderConfig(new DecoderConfig(ContentDecoder.GZIP))) + .when() .get(String.format("/patron/account/%s?apikey=%s", extPatronId, apiKey)) - .then() + .then() .statusCode(200) .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) - .extract() - .response(); + .header(HttpHeaders.CONTENT_ENCODING, "gzip") + .body(is(expected)); + } - String expected = PatronMockOkapi.getAccountJson(patronId, false, false, false); - String actual = resp.body().asString(); + @Test + public void testGetAccountPatronFoundDeflate(TestContext context) throws Exception { + logger.info("=== Patron in Deflate compression ==="); - assertEquals(expected, actual); + final String expected = PatronMockOkapi.getAccountJson(patronId, false, false, false); + + RestAssured.given() + .config(RestAssured.config().decoderConfig(new DecoderConfig(ContentDecoder.DEFLATE))) + .when() + .get(String.format("/patron/account/%s?apikey=%s", extPatronId, apiKey)) + .then() + .statusCode(200) + .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) + .header(HttpHeaders.CONTENT_ENCODING, "deflate") + .body(is(expected)); } @Test @@ -428,20 +459,14 @@ public void testGetAccountEmptyQueryArgs(TestContext context) throws Exception { public void testGetAccountRequestTimeout(TestContext context) throws Exception { logger.info("=== Test getAccount request timeout ==="); - int expectedStatusCode = 408; - final Response resp = RestAssured - .with() - .header(X_DURATION, requestTimeoutMs * 3) + mockOkapi.setDelay(requestTimeoutMs * 3); + RestAssured .get(String.format("/patron/account/%s?apikey=%s", patronId, apiKey)) .then() .contentType(APPLICATION_JSON) - .statusCode(expectedStatusCode) - .extract() - .response(); - - ErrorMessage msg = ErrorMessage.fromJson(resp.body().asString()); - assertEquals(MSG_REQUEST_TIMEOUT, msg.message); - assertEquals(expectedStatusCode, msg.httpStatusCode); + .statusCode(408) + .body("code", is(408)) + .body("errorMessage", is(MSG_REQUEST_TIMEOUT)); } @Test @@ -547,22 +572,15 @@ public void testRenewBadApiKey(TestContext context) throws Exception { public void testRenewRequestTimeout(TestContext context) throws Exception { logger.info("=== Test renew request timeout ==="); - int expectedStatusCode = 408; - - final Response resp = RestAssured - .with() - .header(X_DURATION, requestTimeoutMs * 3) + mockOkapi.setDelay(requestTimeoutMs * 3); + RestAssured .post(String.format("/patron/account/%s/item/%s/renew?apikey=%s", patronId, itemId, apiKey)) .then() .contentType(APPLICATION_JSON) - .statusCode(expectedStatusCode) - .extract() - .response(); - - ErrorMessage msg = ErrorMessage.fromJson(resp.body().asString()); - assertEquals(MSG_REQUEST_TIMEOUT, msg.message); - assertEquals(expectedStatusCode, msg.httpStatusCode); + .statusCode(408) + .body("code", is(408)) + .body("errorMessage", is(MSG_REQUEST_TIMEOUT)); } @Test @@ -757,25 +775,20 @@ public void testPlaceInstanceHoldRequestTimeout(TestContext context) throws Exce logger.info("=== Test place instance hold request timeout ==="); Hold hold = PatronMockOkapi.getHold(instanceId); - int expectedStatusCode = 408; - final Response resp = RestAssured + mockOkapi.setDelay(requestTimeoutMs * 3); + RestAssured .with() .body(hold.toJson()) - .header(X_DURATION, requestTimeoutMs * 3) .contentType(APPLICATION_JSON) .post( String.format("/patron/account/%s/instance/%s/hold?apikey=%s", patronId, instanceId, apiKey)) .then() .contentType(APPLICATION_JSON) - .statusCode(expectedStatusCode) - .extract() - .response(); - - ErrorMessage msg = ErrorMessage.fromJson(resp.body().asString()); - assertEquals(MSG_REQUEST_TIMEOUT, msg.message); - assertEquals(expectedStatusCode, msg.httpStatusCode); + .statusCode(408) + .body("code", is(408)) + .body("errorMessage", is(MSG_REQUEST_TIMEOUT)); } @Test @@ -984,25 +997,20 @@ public void testPlaceItemHoldRequestTimeout(TestContext context) throws Exceptio logger.info("=== Test place item hold request timeout ==="); Hold hold = PatronMockOkapi.getHold(itemId); - int expectedStatusCode = 408; - final Response resp = RestAssured + mockOkapi.setDelay(requestTimeoutMs * 3); + RestAssured .with() .body(hold.toJson()) - .header(X_DURATION, requestTimeoutMs * 3) .contentType(APPLICATION_JSON) .post( String.format("/patron/account/%s/item/%s/hold?apikey=%s", patronId, itemId, apiKey)) .then() .contentType(APPLICATION_JSON) - .statusCode(expectedStatusCode) - .extract() - .response(); - - ErrorMessage msg = ErrorMessage.fromJson(resp.body().asString()); - assertEquals(MSG_REQUEST_TIMEOUT, msg.message); - assertEquals(expectedStatusCode, msg.httpStatusCode); + .statusCode(408) + .body("code", is(408)) + .body("errorMessage", is(MSG_REQUEST_TIMEOUT)); } @Test @@ -1201,27 +1209,21 @@ public void testCancelHoldBadApiKey(TestContext context) throws Exception { @Test public void testCancelHoldRequestTimeout(TestContext context) throws Exception { logger.info("=== Test cancel hold request timeout ==="); - int expectedStatusCode = 408; String cancedHoldJson = PatronMockOkapi.getHoldCancellation(holdCancellationHoldId, extPatronId); - final Response resp = RestAssured + mockOkapi.setDelay(requestTimeoutMs * 3); + RestAssured .with() - .header(X_DURATION, requestTimeoutMs * 3) .contentType(APPLICATION_JSON) .body(cancedHoldJson) .post(String.format("/patron/account/%s/hold/%s/cancel?apikey=%s", extPatronId, holdCancellationHoldId, apiKey)) .then() .contentType(APPLICATION_JSON) - .statusCode(expectedStatusCode) - .extract() - .response(); - - ErrorMessage msg = ErrorMessage.fromJson(resp.body().asString()); - - assertEquals(MSG_REQUEST_TIMEOUT, msg.message); - assertEquals(expectedStatusCode, msg.httpStatusCode); + .statusCode(408) + .body("code", is(408)) + .body("errorMessage", is(MSG_REQUEST_TIMEOUT)); } @Test @@ -1349,24 +1351,19 @@ public void testEditHoldBadApiKey(TestContext context) throws Exception { public void testEditHoldRequestTimeout(TestContext context) throws Exception { logger.info("=== Test edit hold request timeout ==="); - int expectedStatusCode = 408; String canceledHold = PatronMockOkapi.getHoldCancellation(holdReqId_notFound, extPatronId); - final Response resp = RestAssured + mockOkapi.setDelay(requestTimeoutMs * 3); + RestAssured .with() .contentType(APPLICATION_JSON) - .header(X_DURATION, requestTimeoutMs * 3) .body(canceledHold) .post(String.format("/patron/account/%s/hold/%s/cancel?apikey=%s", extPatronId, holdId, apiKey)) .then() .contentType(APPLICATION_JSON) - .statusCode(expectedStatusCode) - .extract() - .response(); - - ErrorMessage msg = ErrorMessage.fromJson(resp.body().asString()); - assertEquals(MSG_REQUEST_TIMEOUT, msg.message); - assertEquals(expectedStatusCode, msg.httpStatusCode); + .statusCode(408) + .body("code", is(408)) + .body("errorMessage", is(MSG_REQUEST_TIMEOUT)); } @Test diff --git a/src/test/java/org/folio/edge/patron/utils/PatronOkapiClientCompressionTest.java b/src/test/java/org/folio/edge/patron/utils/PatronOkapiClientCompressionTest.java deleted file mode 100644 index b02638f..0000000 --- a/src/test/java/org/folio/edge/patron/utils/PatronOkapiClientCompressionTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.folio.edge.patron.utils; - -import io.vertx.core.MultiMap; -import io.vertx.core.Vertx; -import io.vertx.core.http.HttpServer; -import io.vertx.core.http.HttpServerOptions; -import io.vertx.ext.unit.Async; -import io.vertx.ext.unit.TestContext; -import io.vertx.ext.unit.junit.VertxUnitRunner; -import java.util.UUID; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.folio.edge.core.utils.test.TestUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(VertxUnitRunner.class) -public class PatronOkapiClientCompressionTest { - private static final Logger logger = LogManager.getLogger(PatronOkapiClientCompressionTest.class); - - private final Vertx vertx = Vertx.vertx(); - - private final String patronId = UUID.randomUUID().toString(); - private static final String tenant = "diku"; - private static final int reqTimeout = 3000; - - private PatronOkapiClient client; - - @Before - public void setUp(TestContext context) throws Exception { - int okapiPort = TestUtils.getPort(); - - final HttpServer server = vertx.createHttpServer( - new HttpServerOptions().setCompressionSupported(true)); - - server.requestHandler(req -> { - req.response() - .setStatusCode(200) - .putHeader("content-type", "application/json") - .end("{\"test\":\"1234\"}"); - }); - - final Async async = context.async(); - server.listen(okapiPort, "localhost", ar -> { - context.assertTrue(ar.succeeded()); - async.complete(); - }); - - client = new PatronOkapiClientFactory(vertx, - "http://localhost:" + okapiPort, reqTimeout).getPatronOkapiClient(tenant); - } - - @After - public void tearDown(TestContext context) { - vertx.close(context.asyncAssertSuccess()); - } - - @Test - public void testCompression(TestContext context) throws Exception { - logger.info("=== Test Compression ==="); - - MultiMap headers = MultiMap.caseInsensitiveMultiMap(); - headers.add("Accept-Encoding", "gzip"); - Async async = context.async(); - client.getAccount(patronId, - true, - true, - true, - null, - null, - null, - headers, - resp -> { - logger.info("mod-patron response body: " + resp.body()); - context.assertEquals("{\"test\":\"1234\"}", resp.bodyAsString()); - async.complete(); - }, - context::fail); - } -} diff --git a/src/test/java/org/folio/edge/patron/utils/PatronOkapiClientTest.java b/src/test/java/org/folio/edge/patron/utils/PatronOkapiClientTest.java index 622aee3..9f921a9 100644 --- a/src/test/java/org/folio/edge/patron/utils/PatronOkapiClientTest.java +++ b/src/test/java/org/folio/edge/patron/utils/PatronOkapiClientTest.java @@ -50,7 +50,8 @@ public void setUp(TestContext context) throws Exception { knownTenants.add(tenant); mockOkapi = new PatronMockOkapi(okapiPort, knownTenants); - mockOkapi.start(context); + mockOkapi.start() + .onComplete(context.asyncAssertSuccess()); client = new PatronOkapiClientFactory(Vertx.vertx(), "http://localhost:" + okapiPort, reqTimeout) .getPatronOkapiClient(tenant); @@ -58,7 +59,8 @@ public void setUp(TestContext context) throws Exception { @After public void tearDown(TestContext context) { - mockOkapi.close(context); + mockOkapi.close() + .onComplete(context.asyncAssertSuccess()); } @Test