Skip to content

Commit

Permalink
MODINV-986: post-rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PBobylev committed Jun 6, 2024
1 parent 740ccc4 commit d62149d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.apache.logging.log4j.Logger;
import org.folio.DataImportEventTypes;
import org.folio.inventory.consortium.cache.ConsortiumDataCache;
import org.folio.inventory.dataimport.cache.ProfileSnapshotCache;
import org.folio.inventory.dataimport.consumers.DataImportKafkaHandler;
import org.folio.inventory.dataimport.util.ConsumerWrapperUtil;
import org.folio.inventory.support.KafkaConsumerVerticle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.folio.inventory.support;

import static java.lang.Integer.parseInt;
import static java.lang.Long.*;
import static java.lang.String.format;
import static java.lang.String.join;
import static java.lang.System.getProperty;
Expand Down Expand Up @@ -39,15 +38,13 @@ public abstract class KafkaConsumerVerticle extends AbstractVerticle {
private static final String MAX_DISTRIBUTION_NUMBER_TEMPLATE = "inventory.kafka.%s.maxDistributionNumber";
private static final String MAX_DISTRIBUTION_NUMBER_DEFAULT = "100";
private static final String CACHE_EXPIRATION_DEFAULT = "3600";
private static final String METADATA_EXPIRATION_TIME = "inventory.mapping-metadata-cache.expiration.time.seconds";
private static final String PROFILE_SNAPSHOT_CACHE_EXPIRATION_TIME = "inventory.profile-snapshot-cache.expiration.time.seconds";
private final List<KafkaConsumerWrapper<String, String>> consumerWrappers = new ArrayList<>();
private ProfileSnapshotCache profileSnapshotCache;
private KafkaConfig kafkaConfig;
private JsonObject config;
private HttpClient httpClient;
private Storage storage;
private MappingMetadataCache mappingMetadataCache;
private ProfileSnapshotCache profileSnapshotCache;

@Override
public void stop(Promise<Void> stopPromise) {
Expand Down Expand Up @@ -108,11 +105,7 @@ protected Storage getStorage() {
}

protected MappingMetadataCache getMappingMetadataCache() {
if (isNull(mappingMetadataCache)) {
var mappingMetadataExpirationTime = getCacheEnvVariable(METADATA_EXPIRATION_TIME);
mappingMetadataCache = new MappingMetadataCache(vertx, getHttpClient(), parseLong(mappingMetadataExpirationTime));
}
return mappingMetadataCache;
return MappingMetadataCache.getInstance(vertx, getHttpClient());
}

protected ProfileSnapshotCache getProfileSnapshotCache() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Optional;
import java.util.UUID;

import io.vertx.core.json.JsonObject;
import org.folio.inventory.common.Context;
import org.folio.inventory.dataimport.handlers.matching.util.EventHandlingUtil;
import org.folio.MappingMetadataDto;
Expand Down Expand Up @@ -33,6 +32,7 @@ public class MappingMetadataCacheTest {

private static final String TENANT_ID = "diku";
private static final String MAPPING_METADATA_URL = "/mapping-metadata";
private static final String MARC_BIB_RECORD_TYPE = "marc-bib";

private final Vertx vertx = Vertx.vertx();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

import static org.folio.Record.RecordType.MARC_BIB;
import static org.folio.inventory.dataimport.consumers.MarcHoldingsRecordHridSetKafkaHandler.JOB_EXECUTION_ID_KEY;
import static org.folio.inventory.dataimport.util.MappingConstants.MARC_BIB_RECORD_FORMAT;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
Expand Down Expand Up @@ -111,7 +110,7 @@ public void shouldReturnSucceededFutureWithObtainedRecordKey(TestContext context
// given
Async async = context.async();
Map<String, String> payload = new HashMap<>();
payload.put(MARC_BIB_RECORD_FORMAT, Json.encode(record));
payload.put("MARC_BIB", Json.encode(record));
payload.put(JOB_EXECUTION_ID_KEY, UUID.randomUUID().toString());

Event event = new Event().withId("01").withEventPayload(Json.encode(payload));
Expand Down Expand Up @@ -155,7 +154,7 @@ public void shouldReturnFailedIfOLErrorExist(TestContext context) {
// given
Async async = context.async();
Map<String, String> payload = new HashMap<>();
payload.put(MARC_BIB_RECORD_FORMAT, Json.encode(record));
payload.put("MARC_BIB", Json.encode(record));
payload.put(JOB_EXECUTION_ID_KEY, UUID.randomUUID().toString());
payload.put("CURRENT_RETRY_NUMBER", "1");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.folio.inventory.eventhandlers;

import static org.folio.inventory.dataimport.util.MappingConstants.MARC_BIB_RECORD_FORMAT;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
Expand Down Expand Up @@ -108,8 +107,8 @@ record = new JsonObject(TestUtil.readFileFromPath(RECORD_PATH));
@Test
public void shouldProcessEvent() {
HashMap<String, String> eventPayload = new HashMap<>();
eventPayload.put("RECORD_TYPE", MARC_BIB_RECORD_FORMAT);
eventPayload.put(MARC_BIB_RECORD_FORMAT, record.encode());
eventPayload.put("RECORD_TYPE", "MARC_BIB");
eventPayload.put("MARC_BIB", record.encode());
eventPayload.put("MAPPING_RULES", mappingRules.encode());
eventPayload.put("MAPPING_PARAMS", new JsonObject().encode());
eventPayload.put("RELATED_RECORD_VERSION", INSTANCE_VERSION);
Expand Down Expand Up @@ -142,8 +141,8 @@ public void shouldProcessEvent() {
@Test
public void shouldCompleteExceptionallyOnOLNumberExceeded() {
HashMap<String, String> eventPayload = new HashMap<>();
eventPayload.put("RECORD_TYPE", MARC_BIB_RECORD_FORMAT);
eventPayload.put(MARC_BIB_RECORD_FORMAT, record.encode());
eventPayload.put("RECORD_TYPE", "MARC_BIB");
eventPayload.put("MARC_BIB", record.encode());
eventPayload.put("MAPPING_RULES", mappingRules.encode());
eventPayload.put("MAPPING_PARAMS", new JsonObject().encode());
eventPayload.put("RELATED_RECORD_VERSION", INSTANCE_VERSION);
Expand All @@ -166,8 +165,8 @@ public void shouldAddPrecedingAndSucceedingTitlesFromIncomingRecord() throws IOE
record.getParsedRecord().withContent(PARSED_CONTENT_WITH_PRECEDING_SUCCEEDING_TITLES);

HashMap<String, String> eventPayload = new HashMap<>();
eventPayload.put("RECORD_TYPE", MARC_BIB_RECORD_FORMAT);
eventPayload.put(MARC_BIB_RECORD_FORMAT, Json.encode(record));
eventPayload.put("RECORD_TYPE", "MARC_BIB");
eventPayload.put("MARC_BIB", Json.encode(record));
eventPayload.put("MAPPING_RULES", mappingRules.encode());
eventPayload.put("MAPPING_PARAMS", new JsonObject().encode());
eventPayload.put("RELATED_RECORD_VERSION", INSTANCE_VERSION);
Expand All @@ -192,8 +191,8 @@ public void shouldAddPrecedingAndSucceedingTitlesFromIncomingRecord() throws IOE
@Test
public void shouldCompleteExceptionally_whenRecordIsEmpty() {
HashMap<String, String> eventPayload = new HashMap<>();
eventPayload.put("RECORD_TYPE", MARC_BIB_RECORD_FORMAT);
eventPayload.put(MARC_BIB_RECORD_FORMAT, "");
eventPayload.put("RECORD_TYPE", "MARC_BIB");
eventPayload.put("MARC_BIB", "");
eventPayload.put("MAPPING_RULES", mappingRules.encode());
eventPayload.put("MAPPING_PARAMS", new JsonObject().encode());

Expand All @@ -212,8 +211,8 @@ public void shouldSendError() {
}).when(instanceRecordCollection).update(any(), any(), any());

HashMap<String, String> eventPayload = new HashMap<>();
eventPayload.put("RECORD_TYPE", MARC_BIB_RECORD_FORMAT);
eventPayload.put(MARC_BIB_RECORD_FORMAT, record.encode());
eventPayload.put("RECORD_TYPE", "MARC_BIB");
eventPayload.put("MARC_BIB", record.encode());
eventPayload.put("MAPPING_RULES", mappingRules.encode());
eventPayload.put("MAPPING_PARAMS", new JsonObject().encode());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.folio.inventory.dataimport.util.MappingConstants.MARC_BIB_RECORD_FORMAT;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
Expand Down Expand Up @@ -231,8 +229,8 @@ public void shouldSendInstanceUpdatedEvent(TestContext context) throws Interrupt
// given
Async async = context.async();
Map<String, String> payload = new HashMap<>();
payload.put("RECORD_TYPE", MARC_BIB_RECORD_FORMAT);
payload.put(MARC_BIB_RECORD_FORMAT, Json.encode(bibRecord));
payload.put("RECORD_TYPE", "MARC_BIB");
payload.put("MARC_BIB", Json.encode(bibRecord));
payload.put("MAPPING_RULES", bibMappingRules.encode());
payload.put("MAPPING_PARAMS", new JsonObject().encode());
payload.put("PARSED_RECORD_DTO", Json.encode(new ParsedRecordDto()
Expand Down Expand Up @@ -424,7 +422,7 @@ public void shouldSendErrorEventWhenPayloadHasNoMarcRecord(TestContext context)
// given
Async async = context.async();
Map<String, String> payload = new HashMap<>();
payload.put("RECORD_TYPE", MARC_BIB_RECORD_FORMAT);
payload.put("RECORD_TYPE", "MARC_BIB");
payload.put("MAPPING_RULES", bibMappingRules.encode());
payload.put("MAPPING_PARAMS", new JsonObject().encode());

Expand Down

0 comments on commit d62149d

Please sign in to comment.