Skip to content

Commit

Permalink
CIRCSTORE-331 Add account ID (#348)
Browse files Browse the repository at this point in the history
* CIRCSTORE-331 Add account ID

* CIRCSTORE-331 Fix test

* CIRCSTORE-331 Refactor test

* CIRCSTORE-331 Refactor test

* Refactor

* Refactor
  • Loading branch information
Mykyta-Varenyk authored Jun 24, 2022
1 parent e999beb commit b645aa5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ramls/actual-cost-record.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 11 additions & 4 deletions src/test/java/org/folio/rest/api/ActualCostRecordAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit b645aa5

Please sign in to comment.