use of org.folio.dataimport.util.marc.MarcRecordAnalyzer in project mod-source-record-manager by folio-org.
the class EventDrivenChunkProcessingServiceImplTest method setUp.
@Before
public void setUp() throws IOException {
String rules = TestUtil.readFileFromPath(RULES_PATH);
this.mocks = MockitoAnnotations.openMocks(this);
String[] hostAndPort = kafkaCluster.getBrokerList().split(":");
kafkaConfig = KafkaConfig.builder().kafkaHost(hostAndPort[0]).kafkaPort(hostAndPort[1]).envId(KAFKA_ENV_ID).build();
mappingRuleDao = when(mock(MappingRuleDaoImpl.class).get(any(Record.RecordType.class), anyString())).thenReturn(Future.succeededFuture(Optional.of(new JsonObject(rules)))).getMock();
marcRecordAnalyzer = new MarcRecordAnalyzer();
mappingRuleCache = new MappingRuleCache(mappingRuleDao, vertx);
mappingRuleService = new MappingRuleServiceImpl(mappingRuleDao, mappingRuleCache);
mappingParametersProvider = when(mock(MappingParametersProvider.class).get(anyString(), any(OkapiConnectionParams.class))).thenReturn(Future.succeededFuture(new MappingParameters())).getMock();
mappingMetadataService = new MappingMetadataServiceImpl(mappingParametersProvider, mappingRuleService, mappingRulesSnapshotDao, mappingParamsSnapshotDao);
changeEngineService = new ChangeEngineServiceImpl(jobExecutionSourceChunkDao, jobExecutionService, marcRecordAnalyzer, hrIdFieldService, recordsPublishingService, mappingMetadataService, kafkaConfig);
ReflectionTestUtils.setField(changeEngineService, "maxDistributionNum", 10);
ReflectionTestUtils.setField(changeEngineService, "batchSize", 100);
chunkProcessingService = new EventDrivenChunkProcessingServiceImpl(jobExecutionSourceChunkDao, jobExecutionService, changeEngineService, jobExecutionProgressService);
HashMap<String, String> headers = new HashMap<>();
headers.put(OKAPI_URL_HEADER, "http://localhost:" + snapshotMockServer.port());
headers.put(OKAPI_TENANT_HEADER, TENANT_ID);
headers.put(OKAPI_TOKEN_HEADER, "token");
params = new OkapiConnectionParams(headers, vertx);
WireMock.stubFor(post(RECORDS_SERVICE_URL).willReturn(created().withTransformers(RequestToResponseTransformer.NAME)));
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern("/data-import-profiles/jobProfiles/" + ".*"), true)).willReturn(ok().withBody(JsonObject.mapFrom(jobProfile).encode())));
}
use of org.folio.dataimport.util.marc.MarcRecordAnalyzer in project mod-source-record-manager by folio-org.
the class RecordProcessedEventHandlingServiceImplTest method setUp.
@Before
public void setUp() throws IOException {
String[] hostAndPort = kafkaCluster.getBrokerList().split(":");
kafkaConfig = KafkaConfig.builder().kafkaHost(hostAndPort[0]).kafkaPort(hostAndPort[1]).envId(KAFKA_ENV_ID).build();
String rules = TestUtil.readFileFromPath(RULES_PATH);
MockitoAnnotations.openMocks(this);
mappingRuleCache = new MappingRuleCache(mappingRuleDao, vertx);
marcRecordAnalyzer = new MarcRecordAnalyzer();
mappingRuleService = new MappingRuleServiceImpl(mappingRuleDao, mappingRuleCache);
mappingRuleDao = when(mock(MappingRuleDaoImpl.class).get(any(), anyString())).thenReturn(Future.succeededFuture(Optional.of(new JsonObject(rules)))).getMock();
mappingParametersProvider = when(mock(MappingParametersProvider.class).get(anyString(), any(OkapiConnectionParams.class))).thenReturn(Future.succeededFuture(new MappingParameters())).getMock();
mappingMetadataService = new MappingMetadataServiceImpl(mappingParametersProvider, mappingRuleService, mappingRulesSnapshotDao, mappingParamsSnapshotDao);
changeEngineService = new ChangeEngineServiceImpl(jobExecutionSourceChunkDao, jobExecutionService, marcRecordAnalyzer, hrIdFieldService, recordsPublishingService, mappingMetadataService, kafkaConfig);
ReflectionTestUtils.setField(changeEngineService, "maxDistributionNum", 10);
ReflectionTestUtils.setField(changeEngineService, "batchSize", 100);
chunkProcessingService = new EventDrivenChunkProcessingServiceImpl(jobExecutionSourceChunkDao, jobExecutionService, changeEngineService, jobExecutionProgressService);
recordProcessedEventHandlingService = new RecordProcessedEventHandlingServiceImpl(jobExecutionProgressService, jobExecutionService, journalService, jobMonitoringService);
HashMap<String, String> headers = new HashMap<>();
headers.put(OKAPI_URL_HEADER, "http://localhost:" + snapshotMockServer.port());
headers.put(OKAPI_TENANT_HEADER, TENANT_ID);
headers.put(OKAPI_TOKEN_HEADER, "token");
params = new OkapiConnectionParams(headers, vertx);
WireMock.stubFor(post(RECORDS_SERVICE_URL).willReturn(created().withTransformers(RequestToResponseTransformer.NAME)));
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern("/data-import-profiles/jobProfiles/" + ".*"), true)).willReturn(ok().withBody(JsonObject.mapFrom(jobProfile).encode())));
}
Aggregations