Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDGPATRON-160 - Updated raml pieces #139

Merged
merged 18 commits into from
Dec 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9b6a4e9
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 14, 2024
7f367e8
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 14, 2024
6c8b93d
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 14, 2024
95108ac
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 14, 2024
42dfc7e
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 14, 2024
8ee0678
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
0f22b74
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
57bea13
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
9e9d293
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
8e4a27e
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
4fc663b
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
da0a17e
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 18, 2024
ac69dec
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 19, 2024
b8ada70
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 20, 2024
0c6b0bb
Merge branch 'master' into EDGPATRON-160
gurleenkaurbp Dec 20, 2024
461b120
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 20, 2024
4c5e82c
Merge remote-tracking branch 'origin/EDGPATRON-160' into EDGPATRON-160
gurleenkaurbp Dec 20, 2024
b325745
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[EDGPATRON-160] - Add put API for /patron/{externalSystemId}
gurleenkaurbp committed Dec 14, 2024
commit 6c8b93d6c0769a998c2359e937fb0e94688b81df
11 changes: 1 addition & 10 deletions src/main/java/org/folio/edge/patron/PatronHandler.java
Original file line number Diff line number Diff line change
@@ -218,21 +218,12 @@ public void handlePutPatronRequest(RoutingContext ctx) {
.end(getErrorMsg("MISSING_BODY", "Request body must not null"));
return;
}
String externalSystemId = ctx.request().getParam(PARAM_EXTERNAL_SYSTEM_ID);
if(StringUtils.isNullOrEmpty(externalSystemId)) {
logger.warn("handlePutPatronRequest:: Missing or empty externalSystemId");
ctx.response()
.setStatusCode(400)
.putHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON)
.end(getErrorMsg("EXTERNAL_SYSTEM_ID_NOT_PROVIDED", "externalSystemId is missing in the request"));
return;
}

final String body = String.valueOf(ctx.body().asJsonObject());
super.handleCommon(ctx, new String[]{}, new String[]{}, (client, params) -> {
String alternateTenantId = ctx.request().getParam("alternateTenantId", client.tenant);
final PatronOkapiClient patronClient = new PatronOkapiClient(client, alternateTenantId);
patronClient.putPatron(externalSystemId, body,
patronClient.putPatron(ctx.request().getParam(PARAM_EXTERNAL_SYSTEM_ID), body,
resp -> handleProxyResponse(ctx, resp),
t -> handleProxyException(ctx, t));
});
85 changes: 85 additions & 0 deletions src/test/java/org/folio/edge/patron/MainVerticleTest.java
Original file line number Diff line number Diff line change
@@ -1022,6 +1022,25 @@ public void testPostPatron_400(TestContext context) {
.body("code", is(400));
}

@Test
public void testPutPatron_400(TestContext context) {
logger.info("=== testPutPatron_400 ===");
JsonObject jsonObject = new JsonObject(readMockFile("/staging-users-put-request.json"));
jsonObject.getJsonObject("generalInfo").put("firstName", "TEST_STATUS_CODE_400");
RestAssured
.with()
.body(jsonObject.encode())
.contentType(APPLICATION_JSON)
.put(
String.format("/patron/%s?apikey=%s", externalSystemId, apiKey))
.then()
.statusCode(400)
.header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON)
.body("errorMessage", is("A bad exception occurred"))
.body("code", is(400));
}


@Test
public void testPostPatron_422(TestContext context) {
logger.info("=== testPostPatron_422 ===");
@@ -1040,6 +1059,24 @@ public void testPostPatron_422(TestContext context) {
.body("code", is(422));
}

@Test
public void testPutPatron_422(TestContext context) {
logger.info("=== testPutPatron_422 ===");
JsonObject jsonObject = new JsonObject(readMockFile("/staging-users-put-request.json"));
jsonObject.getJsonObject("generalInfo").put("firstName", "TEST_STATUS_CODE_422");
RestAssured
.with()
.body(jsonObject.encode())
.contentType(APPLICATION_JSON)
.put(
String.format("/patron/%s?apikey=%s", externalSystemId, apiKey))
.then()
.statusCode(422)
.header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON)
.body("errorMessage", is("ABC is required"))
.body("code", is(422));
}

@Test
public void testPostPatron_500(TestContext context) {
logger.info("=== testPostPatron_500 ===");
@@ -1073,6 +1110,54 @@ public void testPostPatron_NoRequestBody(TestContext context) {
.body("code", is("MISSING_BODY"));
}

@Test
public void testPutPatron_500(TestContext context) {
logger.info("=== testPutPatron_500 ===");
JsonObject jsonObject = new JsonObject(readMockFile("/staging-users-put-request.json"));
jsonObject.getJsonObject("generalInfo").put("firstName", "TEST_STATUS_CODE_500");
RestAssured
.with()
.body(jsonObject.encode())
.contentType(APPLICATION_JSON)
.put(
String.format("/patron/%s?apikey=%s", externalSystemId, apiKey))
.then()
.statusCode(500)
.header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON)
.body("errorMessage", is("Server exception occurred"))
.body("code", is(500));
}

@Test
public void testPutPatron_NoRequestBody(TestContext context) {
logger.info("=== testPutPatron_NoRequestBody ===");
RestAssured
.with()
.contentType(APPLICATION_JSON)
.put(
String.format("/patron/%s?apikey=%s", externalSystemId, apiKey))
.then()
.statusCode(400)
.header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON)
.body("errorMessage", is("Request body must not null"))
.body("code", is("MISSING_BODY"));
}

@Test
public void testPutPatron_NoParam(TestContext context) {
logger.info("=== testPutPatron_NoParam ===");
JsonObject jsonObject = new JsonObject(readMockFile("/staging-users-put-request.json"));
jsonObject.getJsonObject("generalInfo").put("firstName", "TEST_STATUS_CODE_405");
RestAssured
.with()
.body(jsonObject.encode())
.contentType(APPLICATION_JSON)
.put(
String.format("/patron/%s?apikey=%s", "", apiKey))
.then()
.statusCode(405);
}

@Test
public void testPlaceInstanceHoldInstanceNotFound(TestContext context) throws Exception {
logger.info("=== Test place instance hold w/ instance not found ===");