From af5b69d4ee5f96b9e799c7f93b3bc030f26f6acf Mon Sep 17 00:00:00 2001 From: Javokhir Abdullaev <101543142+JavokhirAbdullayev@users.noreply.github.com> Date: Wed, 28 Aug 2024 00:06:45 +0500 Subject: [PATCH] MODINV-709 Job profile with POL/VRN match cascade does not finish properly (#756) * test * test * reorder tests * reorder tests * reorder tests * remove unused import --- .../DataImportConsumerVerticleTest.java | 73 ++++++++++--------- .../MarcHridSetConsumerVerticleTest.java | 1 - .../DataImportKafkaHandlerTest.java | 13 +++- ...arcBibInstanceHridSetKafkaHandlerTest.java | 3 +- .../MarcBibUpdateKafkaHandlerTest.java | 3 +- ...HoldingsRecordHridSetKafkaHandlerTest.java | 3 +- 6 files changed, 53 insertions(+), 43 deletions(-) rename src/test/java/org/folio/inventory/dataimport/{consumers => handlers}/DataImportKafkaHandlerTest.java (96%) rename src/test/java/org/folio/inventory/dataimport/{consumers => handlers}/MarcBibInstanceHridSetKafkaHandlerTest.java (98%) rename src/test/java/org/folio/inventory/dataimport/{consumers => handlers}/MarcBibUpdateKafkaHandlerTest.java (99%) rename src/test/java/org/folio/inventory/dataimport/{consumers => handlers}/MarcHoldingsRecordHridSetKafkaHandlerTest.java (98%) diff --git a/src/test/java/org/folio/inventory/dataimport/consumers/DataImportConsumerVerticleTest.java b/src/test/java/org/folio/inventory/dataimport/consumers/DataImportConsumerVerticleTest.java index f0eba5f25..5f28d6ecd 100644 --- a/src/test/java/org/folio/inventory/dataimport/consumers/DataImportConsumerVerticleTest.java +++ b/src/test/java/org/folio/inventory/dataimport/consumers/DataImportConsumerVerticleTest.java @@ -1,5 +1,29 @@ package org.folio.inventory.dataimport.consumers; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static java.nio.charset.StandardCharsets.UTF_8; +import static net.mguenther.kafka.junit.EmbeddedKafkaCluster.provisionWith; +import static net.mguenther.kafka.junit.EmbeddedKafkaClusterConfig.defaultClusterConfig; +import static org.folio.ActionProfile.Action.CREATE; +import static org.folio.DataImportEventTypes.DI_COMPLETED; +import static org.folio.DataImportEventTypes.DI_INCOMING_MARC_BIB_RECORD_PARSED; +import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_ENV; +import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_HOST; +import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_MAX_REQUEST_SIZE; +import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_PORT; +import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_REPLICATION_FACTOR; +import static org.folio.kafka.KafkaTopicNameHelper.getDefaultNameSpace; +import static org.folio.rest.jaxrs.model.EntityType.INSTANCE; +import static org.folio.rest.jaxrs.model.EntityType.MARC_BIBLIOGRAPHIC; +import static org.folio.rest.jaxrs.model.ProfileType.ACTION_PROFILE; +import static org.folio.rest.jaxrs.model.ProfileType.JOB_PROFILE; +import static org.folio.rest.jaxrs.model.ProfileType.MAPPING_PROFILE; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.when; + import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.common.Slf4jNotifier; import com.github.tomakehurst.wiremock.core.WireMockConfiguration; @@ -13,6 +37,13 @@ import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.VertxUnitRunner; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; import net.mguenther.kafka.junit.EmbeddedKafkaCluster; import net.mguenther.kafka.junit.KeyValue; import net.mguenther.kafka.junit.ObserveKeyValues; @@ -37,38 +68,6 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; - -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static java.nio.charset.StandardCharsets.UTF_8; -import static net.mguenther.kafka.junit.EmbeddedKafkaCluster.provisionWith; -import static net.mguenther.kafka.junit.EmbeddedKafkaClusterConfig.defaultClusterConfig; -import static org.folio.ActionProfile.Action.CREATE; -import static org.folio.DataImportEventTypes.DI_COMPLETED; -import static org.folio.DataImportEventTypes.DI_INCOMING_MARC_BIB_RECORD_PARSED; -import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_ENV; -import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_HOST; -import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_MAX_REQUEST_SIZE; -import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_PORT; -import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_REPLICATION_FACTOR; -import static org.folio.kafka.KafkaTopicNameHelper.getDefaultNameSpace; -import static org.folio.rest.jaxrs.model.EntityType.INSTANCE; -import static org.folio.rest.jaxrs.model.EntityType.MARC_BIBLIOGRAPHIC; -import static org.folio.rest.jaxrs.model.ProfileType.ACTION_PROFILE; -import static org.folio.rest.jaxrs.model.ProfileType.JOB_PROFILE; -import static org.folio.rest.jaxrs.model.ProfileType.MAPPING_PROFILE; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.when; - @RunWith(VertxUnitRunner.class) public class DataImportConsumerVerticleTest { @@ -127,6 +126,7 @@ public class DataImportConsumerVerticleTest { @BeforeClass public static void setUpClass(TestContext context) { Async async = context.async(); + vertx = Vertx.vertx(); cluster = provisionWith(defaultClusterConfig()); cluster.start(); String[] hostAndPort = cluster.getBrokerList().split(":"); @@ -136,7 +136,6 @@ public static void setUpClass(TestContext context) { .kafkaPort(hostAndPort[1]) .build(); - vertx = Vertx.vertx(); EventManager.registerKafkaEventPublisher(kafkaConfig, vertx, 1); DeploymentOptions options = new DeploymentOptions() @@ -202,8 +201,12 @@ public void shouldSendEventWithProcessedEventPayloadWhenProcessingCoreHandlerSuc public static void tearDownClass(TestContext context) { Async async = context.async(); vertx.close(ar -> { - cluster.stop(); - async.complete(); + if (ar.succeeded()) { + cluster.stop(); + async.complete(); + } else { + context.fail(ar.cause()); + } }); } diff --git a/src/test/java/org/folio/inventory/dataimport/consumers/MarcHridSetConsumerVerticleTest.java b/src/test/java/org/folio/inventory/dataimport/consumers/MarcHridSetConsumerVerticleTest.java index 61843652f..fae04fe1d 100644 --- a/src/test/java/org/folio/inventory/dataimport/consumers/MarcHridSetConsumerVerticleTest.java +++ b/src/test/java/org/folio/inventory/dataimport/consumers/MarcHridSetConsumerVerticleTest.java @@ -24,7 +24,6 @@ @RunWith(VertxUnitRunner.class) public class MarcHridSetConsumerVerticleTest { - private static final String TENANT_ID = "diku"; private static final String KAFKA_ENV_NAME = "test-env"; private static Vertx vertx = Vertx.vertx(); diff --git a/src/test/java/org/folio/inventory/dataimport/consumers/DataImportKafkaHandlerTest.java b/src/test/java/org/folio/inventory/dataimport/handlers/DataImportKafkaHandlerTest.java similarity index 96% rename from src/test/java/org/folio/inventory/dataimport/consumers/DataImportKafkaHandlerTest.java rename to src/test/java/org/folio/inventory/dataimport/handlers/DataImportKafkaHandlerTest.java index 89c30d69c..17b5d5386 100644 --- a/src/test/java/org/folio/inventory/dataimport/consumers/DataImportKafkaHandlerTest.java +++ b/src/test/java/org/folio/inventory/dataimport/handlers/DataImportKafkaHandlerTest.java @@ -1,4 +1,4 @@ -package org.folio.inventory.dataimport.consumers; +package org.folio.inventory.dataimport.handlers; import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.common.Slf4jNotifier; @@ -24,6 +24,7 @@ import org.folio.inventory.consortium.cache.ConsortiumDataCache; import org.folio.inventory.dataimport.cache.MappingMetadataCache; import org.folio.inventory.dataimport.cache.ProfileSnapshotCache; +import org.folio.inventory.dataimport.consumers.DataImportKafkaHandler; import org.folio.inventory.storage.Storage; import org.folio.kafka.KafkaConfig; import org.folio.processing.events.EventManager; @@ -135,11 +136,15 @@ public static void setUpClass() { } @AfterClass - public static void afterClass(TestContext context) { + public static void tearDownClass(TestContext context) { Async async = context.async(); vertx.close(ar -> { - cluster.stop(); - async.complete(); + if (ar.succeeded()) { + cluster.stop(); + async.complete(); + } else { + context.fail(ar.cause()); + } }); } diff --git a/src/test/java/org/folio/inventory/dataimport/consumers/MarcBibInstanceHridSetKafkaHandlerTest.java b/src/test/java/org/folio/inventory/dataimport/handlers/MarcBibInstanceHridSetKafkaHandlerTest.java similarity index 98% rename from src/test/java/org/folio/inventory/dataimport/consumers/MarcBibInstanceHridSetKafkaHandlerTest.java rename to src/test/java/org/folio/inventory/dataimport/handlers/MarcBibInstanceHridSetKafkaHandlerTest.java index faed10c4f..1c40d1969 100644 --- a/src/test/java/org/folio/inventory/dataimport/consumers/MarcBibInstanceHridSetKafkaHandlerTest.java +++ b/src/test/java/org/folio/inventory/dataimport/handlers/MarcBibInstanceHridSetKafkaHandlerTest.java @@ -1,4 +1,4 @@ -package org.folio.inventory.dataimport.consumers; +package org.folio.inventory.dataimport.handlers; import io.vertx.core.Future; import io.vertx.core.json.Json; @@ -13,6 +13,7 @@ import org.folio.inventory.common.domain.Failure; import org.folio.inventory.common.domain.Success; import org.folio.inventory.dataimport.cache.MappingMetadataCache; +import org.folio.inventory.dataimport.consumers.MarcBibInstanceHridSetKafkaHandler; import org.folio.inventory.dataimport.handlers.actions.InstanceUpdateDelegate; import org.folio.inventory.domain.instances.Instance; import org.folio.inventory.domain.instances.InstanceCollection; diff --git a/src/test/java/org/folio/inventory/dataimport/consumers/MarcBibUpdateKafkaHandlerTest.java b/src/test/java/org/folio/inventory/dataimport/handlers/MarcBibUpdateKafkaHandlerTest.java similarity index 99% rename from src/test/java/org/folio/inventory/dataimport/consumers/MarcBibUpdateKafkaHandlerTest.java rename to src/test/java/org/folio/inventory/dataimport/handlers/MarcBibUpdateKafkaHandlerTest.java index f00b4f737..655b9d05b 100644 --- a/src/test/java/org/folio/inventory/dataimport/consumers/MarcBibUpdateKafkaHandlerTest.java +++ b/src/test/java/org/folio/inventory/dataimport/handlers/MarcBibUpdateKafkaHandlerTest.java @@ -1,4 +1,4 @@ -package org.folio.inventory.dataimport.consumers; +package org.folio.inventory.dataimport.handlers; import static net.mguenther.kafka.junit.EmbeddedKafkaCluster.provisionWith; import static net.mguenther.kafka.junit.EmbeddedKafkaClusterConfig.defaultClusterConfig; @@ -37,6 +37,7 @@ import org.folio.inventory.common.Context; import org.folio.inventory.common.domain.Success; import org.folio.inventory.dataimport.cache.MappingMetadataCache; +import org.folio.inventory.dataimport.consumers.MarcBibUpdateKafkaHandler; import org.folio.inventory.dataimport.handlers.actions.InstanceUpdateDelegate; import org.folio.inventory.domain.instances.Instance; import org.folio.inventory.domain.instances.InstanceCollection; diff --git a/src/test/java/org/folio/inventory/dataimport/consumers/MarcHoldingsRecordHridSetKafkaHandlerTest.java b/src/test/java/org/folio/inventory/dataimport/handlers/MarcHoldingsRecordHridSetKafkaHandlerTest.java similarity index 98% rename from src/test/java/org/folio/inventory/dataimport/consumers/MarcHoldingsRecordHridSetKafkaHandlerTest.java rename to src/test/java/org/folio/inventory/dataimport/handlers/MarcHoldingsRecordHridSetKafkaHandlerTest.java index 5f7db6661..32276efeb 100644 --- a/src/test/java/org/folio/inventory/dataimport/consumers/MarcHoldingsRecordHridSetKafkaHandlerTest.java +++ b/src/test/java/org/folio/inventory/dataimport/handlers/MarcHoldingsRecordHridSetKafkaHandlerTest.java @@ -1,4 +1,4 @@ -package org.folio.inventory.dataimport.consumers; +package org.folio.inventory.dataimport.handlers; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static org.folio.inventory.dataimport.consumers.MarcHoldingsRecordHridSetKafkaHandler.JOB_EXECUTION_ID_KEY; @@ -36,6 +36,7 @@ import org.folio.HoldingsType; import org.folio.inventory.common.domain.Failure; import org.folio.inventory.dataimport.cache.MappingMetadataCache; +import org.folio.inventory.dataimport.consumers.MarcHoldingsRecordHridSetKafkaHandler; import org.folio.inventory.domain.HoldingsRecordsSourceCollection; import org.folio.inventory.services.HoldingsCollectionService; import org.folio.processing.mapping.defaultmapper.processor.parameters.MappingParameters;