From b645aa5fe798589e1bf78ce31684267e34291207 Mon Sep 17 00:00:00 2001 From: Mykyta-Varenyk <85155942+Mykyta-Varenyk@users.noreply.github.com> Date: Fri, 24 Jun 2022 17:49:13 +0300 Subject: [PATCH] CIRCSTORE-331 Add account ID (#348) * CIRCSTORE-331 Add account ID * CIRCSTORE-331 Fix test * CIRCSTORE-331 Refactor test * CIRCSTORE-331 Refactor test * Refactor * Refactor --- ramls/actual-cost-record.json | 4 ++++ .../folio/rest/api/ActualCostRecordAPITest.java | 15 +++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ramls/actual-cost-record.json b/ramls/actual-cost-record.json index 71e1cd960..72cbe718b 100644 --- a/ramls/actual-cost-record.json +++ b/ramls/actual-cost-record.json @@ -96,6 +96,10 @@ "description": "Permanent item location of the lost item", "type": "string" }, + "accountId": { + "description": "ID of the fee/fine created based on the actual cost record during its manual processing", + "$ref": "raml-util/schemas/uuid.schema" + }, "feeFineOwnerId": { "description": "Fee/fine owner ID", "type": "string", diff --git a/src/test/java/org/folio/rest/api/ActualCostRecordAPITest.java b/src/test/java/org/folio/rest/api/ActualCostRecordAPITest.java index f9f44a42d..848166af3 100644 --- a/src/test/java/org/folio/rest/api/ActualCostRecordAPITest.java +++ b/src/test/java/org/folio/rest/api/ActualCostRecordAPITest.java @@ -28,7 +28,6 @@ import io.vertx.core.json.JsonObject; import lombok.SneakyThrows; import static org.folio.rest.jaxrs.model.ActualCostRecord.ItemLossType.AGED_TO_LOST; -import static org.folio.rest.jaxrs.model.ActualCostRecord.ItemLossType.DECLARED_LOST; import static org.folio.rest.support.matchers.JsonMatchers.hasSameProperties; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -87,12 +86,19 @@ public void canCreateAndGetAndUpdateActualCostRecord() { assertThat(createResult, hasSameProperties(actualCostRecord)); - JsonObject updatedJson = createResult.put("lossType", DECLARED_LOST.value()); + UUID accountId = UUID.randomUUID(); + JsonObject updatedJson = createResult.put("accountId", accountId.toString()); + updateActualCostRecordAndCheckTheResult(updatedJson); - actualCostRecordClient.attemptPutById(updatedJson); + updatedJson.remove("accountId"); + updateActualCostRecordAndCheckTheResult(updatedJson); + } - JsonObject fetchedJson = actualCostRecordClient.getById(updatedJson.getString("id")).getJson(); + @SneakyThrows + private void updateActualCostRecordAndCheckTheResult(JsonObject updatedJson) { + actualCostRecordClient.attemptPutById(updatedJson); + JsonObject fetchedJson = actualCostRecordClient.getById(updatedJson.getString("id")).getJson(); fetchedJson.remove("metadata"); assertThat(updatedJson, hasSameProperties(fetchedJson)); } @@ -121,6 +127,7 @@ private ActualCostRecord createActualCostRecord() { .withFeeFineType("Lost Item fee (actual cost)"); } + private JsonObject toJsonObject(ActualCostRecord actualCostRecord1) throws JsonProcessingException { return new JsonObject(objectMapper.writeValueAsString(actualCostRecord1));