diff --git a/NEWS.md b/NEWS.md index 9651aed8c..6af146747 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,28 @@ -## v28.0.0 In progress +## v28.1.0 YYYY-mm-DD +### Breaking changes +* Description ([ISSUE](https://folio-org.atlassian.net/browse/ISSUE)) + +### New APIs versions +* Provides `API_NAME vX.Y` +* Requires `API_NAME vX.Y` + +### Features +* Modify endpoint for bulk instances upsert with publish events flag ([MODINVSTOR-1283](https://folio-org.atlassian.net/browse/MODINVSTOR-1283)) + +### Bug fixes +* Description ([ISSUE](https://folio-org.atlassian.net/browse/ISSUE)) + +### Tech Dept +* Description ([ISSUE](https://folio-org.atlassian.net/browse/ISSUE)) + +### Dependencies +* Bump `LIB_NAME` from `OLD_VERSION` to `NEW_VERSION` +* Add `LIB_NAME VERSION` +* Remove `LIB_NAME` + +--- + +## v28.0.0 2024-11-01 ### Breaking changes * Migrate "publicationPeriod" data to the Dates object and remove it from the Instance schema ([MODINVSTOR-1232](https://folio-org.atlassian.net/browse/MODINVSTOR-1232)) * Delete deprecated `shelf-locations` API ([MODINVSTOR-1183](https://folio-org.atlassian.net/browse/MODINVSTOR-1183)) diff --git a/ramls/bulkUpsertRequest.json b/ramls/bulkUpsertRequest.json index d119356db..9d4d8cd46 100644 --- a/ramls/bulkUpsertRequest.json +++ b/ramls/bulkUpsertRequest.json @@ -7,6 +7,11 @@ "recordsFileName": { "description": "File name of entities records", "type": "string" + }, + "publishEvents": { + "description": "A flag that indicates whether domain events should be published.", + "type": "boolean", + "default": true } }, "required": [ diff --git a/src/main/java/org/folio/rest/impl/InstanceBatchSyncApi.java b/src/main/java/org/folio/rest/impl/InstanceBatchSyncApi.java index f2fa3aadb..d03bf5117 100644 --- a/src/main/java/org/folio/rest/impl/InstanceBatchSyncApi.java +++ b/src/main/java/org/folio/rest/impl/InstanceBatchSyncApi.java @@ -25,7 +25,7 @@ public void postInstanceStorageBatchSynchronous(boolean upsert, InstancesPost en var instances = ObjectConverterUtils.convertObject(entity, Instances.class); new InstanceService(vertxContext, okapiHeaders) - .createInstances(instances.getInstances(), upsert, true) + .createInstances(instances.getInstances(), upsert, true, true) .otherwise(cause -> respond500WithTextPlain(cause.getMessage())) .onComplete(asyncResultHandler); } diff --git a/src/main/java/org/folio/rest/impl/InstanceBatchSyncUnsafeApi.java b/src/main/java/org/folio/rest/impl/InstanceBatchSyncUnsafeApi.java index 5ce994149..fcfde1e77 100644 --- a/src/main/java/org/folio/rest/impl/InstanceBatchSyncUnsafeApi.java +++ b/src/main/java/org/folio/rest/impl/InstanceBatchSyncUnsafeApi.java @@ -24,7 +24,7 @@ public void postInstanceStorageBatchSynchronousUnsafe(InstancesPost entity, Map< var instances = ObjectConverterUtils.convertObject(entity, Instances.class); new InstanceService(vertxContext, okapiHeaders) - .createInstances(instances.getInstances(), true, false) + .createInstances(instances.getInstances(), true, false, true) .otherwise(cause -> respond500WithTextPlain(cause.getMessage())) .onComplete(asyncResultHandler); } diff --git a/src/main/java/org/folio/services/BulkProcessingContext.java b/src/main/java/org/folio/services/BulkProcessingContext.java index 24f6584a8..d1e9b2246 100644 --- a/src/main/java/org/folio/services/BulkProcessingContext.java +++ b/src/main/java/org/folio/services/BulkProcessingContext.java @@ -1,6 +1,7 @@ package org.folio.services; import org.apache.commons.lang3.StringUtils; +import org.folio.rest.jaxrs.model.BulkUpsertRequest; /** * Encapsulates the context for bulk processing of entities from external file. @@ -17,13 +18,15 @@ public class BulkProcessingContext { private final String errorsFilePath; private final String errorEntitiesFileLocalPath; private final String errorsFileLocalPath; + private final boolean publishEvents; - public BulkProcessingContext(String entitiesFilePath) { - this.initialFilePath = StringUtils.removeStart(entitiesFilePath, '/'); + public BulkProcessingContext(BulkUpsertRequest request) { + this.initialFilePath = StringUtils.removeStart(request.getRecordsFileName(), '/'); this.errorEntitiesFilePath = initialFilePath + FAILED_ENTITIES_FILE_SUFFIX; this.errorsFilePath = initialFilePath + ERRORS_FILE_SUFFIX; this.errorEntitiesFileLocalPath = ROOT_FOLDER + errorEntitiesFilePath; this.errorsFileLocalPath = ROOT_FOLDER + errorsFilePath; + this.publishEvents = request.getPublishEvents(); } public String getErrorEntitiesFilePath() { @@ -42,4 +45,7 @@ public String getErrorsFileLocalPath() { return errorsFileLocalPath; } + public boolean isPublishEvents() { + return publishEvents; + } } diff --git a/src/main/java/org/folio/services/batch/BatchOperationContext.java b/src/main/java/org/folio/services/batch/BatchOperationContext.java index 6e01db3fb..7a9f4fa6e 100644 --- a/src/main/java/org/folio/services/batch/BatchOperationContext.java +++ b/src/main/java/org/folio/services/batch/BatchOperationContext.java @@ -11,9 +11,12 @@ public final class BatchOperationContext { */ private final Collection existingRecords; - public BatchOperationContext(Collection recordsToBeCreated, Collection existingRecords) { + private final boolean publishEvents; + + public BatchOperationContext(Collection recordsToBeCreated, Collection existingRecords, boolean publishEvents) { this.recordsToBeCreated = unmodifiableCollection(recordsToBeCreated); this.existingRecords = unmodifiableCollection(existingRecords); + this.publishEvents = publishEvents; } public Collection getRecordsToBeCreated() { @@ -23,4 +26,8 @@ public Collection getRecordsToBeCreated() { public Collection getExistingRecords() { return existingRecords; } + + public boolean isPublishEvents() { + return publishEvents; + } } diff --git a/src/main/java/org/folio/services/batch/BatchOperationContextFactory.java b/src/main/java/org/folio/services/batch/BatchOperationContextFactory.java index 8d4a30616..786528ba2 100644 --- a/src/main/java/org/folio/services/batch/BatchOperationContextFactory.java +++ b/src/main/java/org/folio/services/batch/BatchOperationContextFactory.java @@ -12,11 +12,13 @@ public final class BatchOperationContextFactory { private BatchOperationContextFactory() { } - public static Future> buildBatchOperationContext( - boolean upsert, List all, AbstractRepository repository, Function idGetter) { + public static Future> buildBatchOperationContext(boolean upsert, List all, + AbstractRepository repository, + Function idGetter, + boolean publishEvents) { if (!upsert) { - return succeededFuture(new BatchOperationContext<>(all, emptyList())); + return succeededFuture(new BatchOperationContext<>(all, emptyList(), publishEvents)); } return repository.getById(all, idGetter).map(found -> { @@ -24,7 +26,7 @@ public static Future> buildBatchOperationContext( .filter(entity -> !found.containsKey(idGetter.apply(entity))) .collect(toList()); - return new BatchOperationContext<>(toBeCreated, found.values()); + return new BatchOperationContext<>(toBeCreated, found.values(), publishEvents); }); } } diff --git a/src/main/java/org/folio/services/bulkprocessing/AbstractEntityS3Service.java b/src/main/java/org/folio/services/bulkprocessing/AbstractEntityS3Service.java index 8690ef55f..742280d96 100644 --- a/src/main/java/org/folio/services/bulkprocessing/AbstractEntityS3Service.java +++ b/src/main/java/org/folio/services/bulkprocessing/AbstractEntityS3Service.java @@ -77,9 +77,9 @@ private Future> loadEntities(BulkUpsertRequest bulkRequest) { } private Future upsertEntities(List entities, BulkUpsertRequest bulkRequest) { - BulkProcessingContext bulkProcessingContext = new BulkProcessingContext(bulkRequest.getRecordsFileName()); + BulkProcessingContext bulkProcessingContext = new BulkProcessingContext(bulkRequest); - return upsert(entities) + return upsert(entities, bulkProcessingContext.isPublishEvents()) .map(v -> new BulkUpsertResponse().withErrorsNumber(0)) .recover(e -> processSequentially(entities, bulkProcessingContext)); } @@ -89,7 +89,7 @@ private Future processSequentially(List entities, BulkPro BulkProcessingErrorFileWriter errorsWriter = new BulkProcessingErrorFileWriter(vertx, bulkContext); return errorsWriter.initialize() - .compose(v -> processInBatches(entities, entity -> upsert(List.of(entity)) + .compose(v -> processInBatches(entities, entity -> upsert(List.of(entity), bulkContext.isPublishEvents()) .recover(e -> handleUpsertFailure(errorsCounter, errorsWriter, entity, e)))) .eventually(errorsWriter::close) .eventually(() -> uploadErrorsFiles(bulkContext)) @@ -166,10 +166,11 @@ private Future uploadErrorsFiles(BulkProcessingContext bulkContext) { * Performs an upsert operation on specified list of {@code entities}. * The implementation of the upsert operation depends on the specifics of the {@code } type of entity. * - * @param entities - a list of entities to be updated or created + * @param entities - a list of entities to be updated or created + * @param publishEvents - a flag that indicates whether domain events should be published * @return Future of Void, succeeded if the upsert operation is successful, otherwise failed */ - protected abstract Future upsert(List entities); + protected abstract Future upsert(List entities, boolean publishEvents); /** * Provides a representation of the given {@code entity} to be written to error file containing entities diff --git a/src/main/java/org/folio/services/bulkprocessing/InstanceS3Service.java b/src/main/java/org/folio/services/bulkprocessing/InstanceS3Service.java index 211ab80bb..1d1d7ebe6 100644 --- a/src/main/java/org/folio/services/bulkprocessing/InstanceS3Service.java +++ b/src/main/java/org/folio/services/bulkprocessing/InstanceS3Service.java @@ -99,10 +99,10 @@ protected Future ensureEntitiesWithNonMarcControlledFieldsData(List upsert(List instanceWrappers) { + protected Future upsert(List instanceWrappers, boolean publishEvents) { List instances = instanceWrappers.stream().map(InstanceWrapper::instance).toList(); - return instanceService.createInstances(instances, APPLY_UPSERT, APPLY_OPTIMISTIC_LOCKING) + return instanceService.createInstances(instances, APPLY_UPSERT, APPLY_OPTIMISTIC_LOCKING, publishEvents) .compose(response -> { if (!isCreateSuccessResponse(response)) { String msg = String.format("Failed to update instances, status: '%s', message: '%s'", diff --git a/src/main/java/org/folio/services/domainevent/AbstractDomainEventPublisher.java b/src/main/java/org/folio/services/domainevent/AbstractDomainEventPublisher.java index 0e38c0c16..027f11400 100644 --- a/src/main/java/org/folio/services/domainevent/AbstractDomainEventPublisher.java +++ b/src/main/java/org/folio/services/domainevent/AbstractDomainEventPublisher.java @@ -67,8 +67,10 @@ public Handler publishCreatedOrUpdated(BatchOperationContext batchO log.info("Records created {}, records updated {}", batchOperation.getRecordsToBeCreated().size(), batchOperation.getExistingRecords().size()); - publishRecordsCreated(batchOperation.getRecordsToBeCreated()).compose( - notUsed -> publishUpdated(batchOperation.getExistingRecords())); + if (batchOperation.isPublishEvents()) { + publishRecordsCreated(batchOperation.getRecordsToBeCreated()).compose( + notUsed -> publishUpdated(batchOperation.getExistingRecords())); + } }; } diff --git a/src/main/java/org/folio/services/holding/HoldingsService.java b/src/main/java/org/folio/services/holding/HoldingsService.java index fe718c970..b691084a5 100644 --- a/src/main/java/org/folio/services/holding/HoldingsService.java +++ b/src/main/java/org/folio/services/holding/HoldingsService.java @@ -168,7 +168,7 @@ public Future createHoldings(List holdings, boolean up .compose(ar -> hridManager.populateHridForHoldings(holdings) .compose(NotesValidators::refuseHoldingLongNotes) .compose(result -> buildBatchOperationContext(upsert, holdings, - holdingsRepository, HoldingsRecord::getId)) + holdingsRepository, HoldingsRecord::getId, true)) .compose(batchOperation -> postSync(HOLDINGS_RECORD_TABLE, holdings, MAX_ENTITIES, upsert, optimisticLocking, okapiHeaders, vertxContext, PostHoldingsStorageBatchSynchronousResponse.class) .onSuccess(domainEventPublisher.publishCreatedOrUpdated(batchOperation)))) diff --git a/src/main/java/org/folio/services/instance/InstanceService.java b/src/main/java/org/folio/services/instance/InstanceService.java index 99954c95d..96a3ada2f 100644 --- a/src/main/java/org/folio/services/instance/InstanceService.java +++ b/src/main/java/org/folio/services/instance/InstanceService.java @@ -120,14 +120,15 @@ public Future createInstance(Instance entity) { .map(ResponseHandlerUtil::handleHridError); } - public Future createInstances(List instances, boolean upsert, boolean optimisticLocking) { + public Future createInstances(List instances, boolean upsert, boolean optimisticLocking, + boolean publishEvents) { final String statusUpdatedDate = generateStatusUpdatedDate(); instances.forEach(instance -> instance.setStatusUpdatedDate(statusUpdatedDate)); return hridManager.populateHridForInstances(instances) .compose(NotesValidators::refuseInstanceLongNotes) .compose(notUsed -> buildBatchOperationContext(upsert, instances, - instanceRepository, Instance::getId)) + instanceRepository, Instance::getId, publishEvents)) .compose(batchOperation -> // Can use instances list here directly because the class is stateful postSync(INSTANCE_TABLE, instances, MAX_ENTITIES, upsert, optimisticLocking, okapiHeaders, diff --git a/src/main/java/org/folio/services/item/ItemService.java b/src/main/java/org/folio/services/item/ItemService.java index d6ac207ee..a9a191487 100644 --- a/src/main/java/org/folio/services/item/ItemService.java +++ b/src/main/java/org/folio/services/item/ItemService.java @@ -144,7 +144,7 @@ public Future createItems(List items, boolean upsert, boolean op .compose(NotesValidators::refuseItemLongNotes) .compose(result -> effectiveValuesService.populateEffectiveValues(items)) .compose(this::populateCirculationNoteId) - .compose(result -> buildBatchOperationContext(upsert, items, itemRepository, Item::getId)) + .compose(result -> buildBatchOperationContext(upsert, items, itemRepository, Item::getId, true)) .compose(batchOperation -> postSync(ITEM_TABLE, items, MAX_ENTITIES, upsert, optimisticLocking, okapiHeaders, vertxContext, PostItemStorageBatchSynchronousResponse.class) .onSuccess(domainEventService.publishCreatedOrUpdated(batchOperation))) diff --git a/src/test/java/org/folio/rest/api/InstanceStorageInstancesBulkApiTest.java b/src/test/java/org/folio/rest/api/InstanceStorageInstancesBulkApiTest.java index 0a8ef90fd..6643dc47e 100644 --- a/src/test/java/org/folio/rest/api/InstanceStorageInstancesBulkApiTest.java +++ b/src/test/java/org/folio/rest/api/InstanceStorageInstancesBulkApiTest.java @@ -22,7 +22,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.equalTo; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.Assert.assertEquals; import static org.testcontainers.containers.localstack.LocalStackContainer.Service.S3; import io.vertx.core.json.Json; @@ -77,6 +77,69 @@ public class InstanceStorageInstancesBulkApiTest extends TestBaseWithInventoryUt private final InstanceEventMessageChecks instanceMessageChecks = new InstanceEventMessageChecks(KAFKA_CONSUMER); + @Before + public void setUp() { + StorageTestSuite.deleteAll(TENANT_ID, PRECEDING_SUCCEEDING_TITLE_TABLE); + clearData(); + removeAllEvents(); + } + + @Test + public void shouldUpdateInstancesWithoutErrors() + throws ExecutionException, InterruptedException, TimeoutException, IOException { + shouldUpdateInstances(true); + } + + @Test + public void shouldUpdateInstancesWithoutErrorsAndDoNotPublishDomainEvents() + throws ExecutionException, InterruptedException, TimeoutException, IOException { + shouldUpdateInstances(false); + } + + @Test + public void shouldUpdateInstancesWithErrors() + throws ExecutionException, InterruptedException, TimeoutException, IOException { + // given + String expectedErrorRecordsFileName = BULK_FILE_TO_UPLOAD + "_failedEntities"; + String expectedErrorsFileName = BULK_FILE_TO_UPLOAD + "_errors"; + + List instancesIds = extractInstancesIdsFromFile(BULK_INSTANCES_WITH_INVALID_TYPE_PATH); + FileInputStream inputStream = FileUtils.openInputStream(new File(BULK_INSTANCES_WITH_INVALID_TYPE_PATH)); + String bulkFilePath = s3Client.write(BULK_FILE_TO_UPLOAD, inputStream); + + final IndividualResource existingInstance1 = createInstance(buildInstance(instancesIds.get(0), INSTANCE_TITLE_1)); + final IndividualResource existingInstance2 = createInstance(buildInstance(instancesIds.get(1), INSTANCE_TITLE_2)); + + // when + BulkUpsertResponse bulkResponse = postInstancesBulk(new BulkUpsertRequest() + .withRecordsFileName(bulkFilePath) + ); + + // then + assertThat(bulkResponse.getErrorsNumber(), is(1)); + assertThat(bulkResponse.getErrorRecordsFileName(), is(expectedErrorRecordsFileName)); + assertThat(bulkResponse.getErrorsFileName(), is(expectedErrorsFileName)); + + List filesList = s3Client.list(BULK_FILE_TO_UPLOAD); + assertThat(filesList.size(), is(3)); + assertThat(filesList, containsInAnyOrder(bulkFilePath, expectedErrorRecordsFileName, expectedErrorsFileName)); + List errors = readLinesFromInputStream(s3Client.read(expectedErrorsFileName)); + assertThat(errors.size(), is(1)); + + JsonObject updatedInstance1 = getInstanceById(existingInstance1.getId().toString()); + + instanceMessageChecks.updatedMessagePublished(existingInstance1.getJson(), updatedInstance1); + instanceMessageChecks.noUpdatedMessagePublished(existingInstance2.getId().toString()); + } + + @Test + public void shouldReturnUnprocessableEntityIfRecordsFileNameIsNotSpecified() + throws ExecutionException, InterruptedException, TimeoutException { + CompletableFuture future = getClient().post(instancesBulk(), new BulkUpsertRequest(), TENANT_ID); + Response response = future.get(10, SECONDS); + assertThat(response.getStatusCode(), is(HTTP_UNPROCESSABLE_ENTITY.toInt())); + } + @BeforeClass public static void setUpClass() { localStackContainer = new LocalStackContainer(DockerImageName.parse("localstack/localstack:s3-latest")) @@ -104,21 +167,13 @@ public static void setUpClass() { s3Client.createBucketIfNotExists(); } - @Before - public void setUp() { - StorageTestSuite.deleteAll(TENANT_ID, PRECEDING_SUCCEEDING_TITLE_TABLE); - clearData(); - removeAllEvents(); - } - @AfterClass public static void tearDownClass() { localStackContainer.close(); } - @Test - public void shouldUpdateInstancesWithoutErrors() - throws ExecutionException, InterruptedException, TimeoutException, IOException { + private void shouldUpdateInstances(boolean publishEvents) + throws IOException, InterruptedException, ExecutionException, TimeoutException { // given List instancesIds = extractInstancesIdsFromFile(BULK_INSTANCES_PATH); FileInputStream inputStream = FileUtils.openInputStream(new File(BULK_INSTANCES_PATH)); @@ -135,7 +190,10 @@ public void shouldUpdateInstancesWithoutErrors() precedingSucceedingTitleClient.create(precedingSucceedingTitle2.getJson()); // when - BulkUpsertResponse bulkResponse = postInstancesBulk(new BulkUpsertRequest().withRecordsFileName(bulkFilePath)); + BulkUpsertResponse bulkResponse = postInstancesBulk(new BulkUpsertRequest() + .withRecordsFileName(bulkFilePath) + .withPublishEvents(publishEvents) + ); // then assertThat(bulkResponse.getErrorsNumber(), is(0)); @@ -154,49 +212,13 @@ public void shouldUpdateInstancesWithoutErrors() assertThat(titleJson.getString("title"), notNullValue()); }); - instanceMessageChecks.updatedMessagePublished(existingInstance1.getJson(), updatedInstance1); - instanceMessageChecks.updatedMessagePublished(existingInstance2.getJson(), updatedInstance2); - } - - @Test - public void shouldUpdateInstancesWithErrors() - throws ExecutionException, InterruptedException, TimeoutException, IOException { - // given - String expectedErrorRecordsFileName = BULK_FILE_TO_UPLOAD + "_failedEntities"; - String expectedErrorsFileName = BULK_FILE_TO_UPLOAD + "_errors"; - - List instancesIds = extractInstancesIdsFromFile(BULK_INSTANCES_WITH_INVALID_TYPE_PATH); - FileInputStream inputStream = FileUtils.openInputStream(new File(BULK_INSTANCES_WITH_INVALID_TYPE_PATH)); - String bulkFilePath = s3Client.write(BULK_FILE_TO_UPLOAD, inputStream); - - final IndividualResource existingInstance1 = createInstance(buildInstance(instancesIds.get(0), INSTANCE_TITLE_1)); - final IndividualResource existingInstance2 = createInstance(buildInstance(instancesIds.get(1), INSTANCE_TITLE_2)); - - // when - BulkUpsertResponse bulkResponse = postInstancesBulk(new BulkUpsertRequest().withRecordsFileName(bulkFilePath)); - - // then - assertThat(bulkResponse.getErrorsNumber(), is(1)); - assertThat(bulkResponse.getErrorRecordsFileName(), is(expectedErrorRecordsFileName)); - assertThat(bulkResponse.getErrorsFileName(), is(expectedErrorsFileName)); - - List filesList = s3Client.list(BULK_FILE_TO_UPLOAD); - assertThat(filesList.size(), is(3)); - assertThat(filesList, containsInAnyOrder(bulkFilePath, expectedErrorRecordsFileName, expectedErrorsFileName)); - List errors = readLinesFromInputStream(s3Client.read(expectedErrorsFileName)); - assertThat(errors.size(), is(1)); - - JsonObject updatedInstance1 = getInstanceById(existingInstance1.getId().toString()); - instanceMessageChecks.updatedMessagePublished(existingInstance1.getJson(), updatedInstance1); - instanceMessageChecks.noUpdatedMessagePublished(existingInstance2.getId().toString()); - } - - @Test - public void shouldReturnUnprocessableEntityIfRecordsFileNameIsNotSpecified() - throws ExecutionException, InterruptedException, TimeoutException { - CompletableFuture future = getClient().post(instancesBulk(), new BulkUpsertRequest(), TENANT_ID); - Response response = future.get(10, SECONDS); - assertThat(response.getStatusCode(), is(HTTP_UNPROCESSABLE_ENTITY.toInt())); + if (publishEvents) { + instanceMessageChecks.updatedMessagePublished(existingInstance1.getJson(), updatedInstance1); + instanceMessageChecks.updatedMessagePublished(existingInstance2.getJson(), updatedInstance2); + } else { + instanceMessageChecks.noUpdatedMessagePublished(existingInstance1.getId().toString()); + instanceMessageChecks.noUpdatedMessagePublished(existingInstance2.getId().toString()); + } } private List extractInstancesIdsFromFile(String bulkInstancesFilePath) throws IOException { diff --git a/src/test/java/org/folio/rest/support/BulkProcessingErrorFileWriterTest.java b/src/test/java/org/folio/rest/support/BulkProcessingErrorFileWriterTest.java index 15aada34e..e40578818 100644 --- a/src/test/java/org/folio/rest/support/BulkProcessingErrorFileWriterTest.java +++ b/src/test/java/org/folio/rest/support/BulkProcessingErrorFileWriterTest.java @@ -15,6 +15,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import org.apache.commons.io.FileUtils; +import org.folio.rest.jaxrs.model.BulkUpsertRequest; import org.folio.rest.jaxrs.model.Instance; import org.folio.services.BulkProcessingContext; import org.junit.After; @@ -34,7 +35,8 @@ public class BulkProcessingErrorFileWriterTest { @Before public void setUp() { - bulkContext = new BulkProcessingContext(BULK_INSTANCES_FILE_PATH); + var request = new BulkUpsertRequest().withRecordsFileName(BULK_INSTANCES_FILE_PATH); + bulkContext = new BulkProcessingContext(request); writer = new BulkProcessingErrorFileWriter(vertx, bulkContext); } diff --git a/src/test/java/org/folio/services/BulkProcessingContextTest.java b/src/test/java/org/folio/services/BulkProcessingContextTest.java index 0500d9ec1..63f23b527 100644 --- a/src/test/java/org/folio/services/BulkProcessingContextTest.java +++ b/src/test/java/org/folio/services/BulkProcessingContextTest.java @@ -2,6 +2,7 @@ import static org.junit.Assert.assertEquals; +import org.folio.rest.jaxrs.model.BulkUpsertRequest; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -13,7 +14,8 @@ public class BulkProcessingContextTest { @Test public void shouldReturnFilesPaths() { - BulkProcessingContext context = new BulkProcessingContext(BULK_INSTANCES_FILE_PATH); + var request = new BulkUpsertRequest().withRecordsFileName(BULK_INSTANCES_FILE_PATH); + var context = new BulkProcessingContext(request); assertEquals("parent-folder/bulkInstances_failedEntities", context.getErrorEntitiesFilePath()); assertEquals("parent-folder/bulkInstances_errors", context.getErrorsFilePath());