From edb3dafc4e26dc4bc1fc8938d9dce981e12562fb Mon Sep 17 00:00:00 2001 From: Adesh_Singh Date: Thu, 6 Jun 2024 12:51:51 +0530 Subject: [PATCH] [EDGEPATRON-131]-Added POST edge api for LOC patron --- .../org/folio/edge/patron/MainVerticleTest.java | 11 +++++------ .../edge/patron/utils/PatronMockOkapi.java | 17 ++++------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/test/java/org/folio/edge/patron/MainVerticleTest.java b/src/test/java/org/folio/edge/patron/MainVerticleTest.java index 152cf6c..b96ac9f 100644 --- a/src/test/java/org/folio/edge/patron/MainVerticleTest.java +++ b/src/test/java/org/folio/edge/patron/MainVerticleTest.java @@ -702,15 +702,14 @@ public void testPlaceInstanceHoldPatronNotFound(TestContext context) throws Exce } @Test - public void test1(TestContext context) throws Exception { - logger.info("=== Test place instance hold w/ patron not found ==="); + public void testPostExternalPatron(TestContext context) throws Exception { + logger.info("=== Test post external patron ==="); - Patron hold = PatronMockOkapi.getPatron(); + Patron patron = PatronMockOkapi.getPatron(); int expectedStatusCode = 201; - - final Response resp = RestAssured + RestAssured .with() - .body(hold.toJson()) + .body(patron.toJson()) .contentType(APPLICATION_JSON) .post( String.format("/patron/account/%s?apikey=%s", UUID.randomUUID(), apiKey)) diff --git a/src/test/java/org/folio/edge/patron/utils/PatronMockOkapi.java b/src/test/java/org/folio/edge/patron/utils/PatronMockOkapi.java index 3b7eab8..2d5b169 100644 --- a/src/test/java/org/folio/edge/patron/utils/PatronMockOkapi.java +++ b/src/test/java/org/folio/edge/patron/utils/PatronMockOkapi.java @@ -135,7 +135,7 @@ public Router defineRoutes() { .handler(this::placeItemHoldHandler); router.route(HttpMethod.POST, "/patron/account") - .handler(this::postP1); + .handler(this::postPatronMock); router.route(HttpMethod.POST, "/patron/account/:patronId/instance/:instanceId/hold") .handler(this::placeInstanceHoldHandler); @@ -321,33 +321,24 @@ public void placeItemHoldHandler(RoutingContext ctx) { } } - public void postP1(RoutingContext ctx) { - logger.info("Inside postp1"); - String token = ctx.request().getHeader(X_OKAPI_TOKEN); - - String body = ctx.getBodyAsString(); - - Patron hold; + public void postPatronMock(RoutingContext ctx) { try { - hold = Patron.fromJson(body); ctx.response() .setStatusCode(201) .putHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) - .end("hiiiiiiiiiii"); - } catch (IOException e) { + .end(); + } catch (Exception e) { logger.error("Exception parsing request payload", e); ctx.response() .setStatusCode(400) .putHeader(HttpHeaders.CONTENT_TYPE, TEXT_PLAIN) .end("Bad Request"); - return; } } public void getRequestHandler(RoutingContext ctx) { String requestId = ctx.request().getParam(PARAM_REQUEST_ID); String token = ctx.request().getHeader(X_OKAPI_TOKEN); - if (token == null || !token.equals(MOCK_TOKEN)) { ctx.response() .setStatusCode(403)