Search in sources :

Example 1 with MappingParametersProvider

use of org.folio.services.mappers.processor.MappingParametersProvider 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())));
}
Also used : HashMap(java.util.HashMap) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) MappingRuleDaoImpl(org.folio.dao.MappingRuleDaoImpl) JsonObject(io.vertx.core.json.JsonObject) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) OkapiConnectionParams(org.folio.dataimport.util.OkapiConnectionParams) MappingParametersProvider(org.folio.services.mappers.processor.MappingParametersProvider) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) MappingParameters(org.folio.processing.mapping.defaultmapper.processor.parameters.MappingParameters) MarcRecordAnalyzer(org.folio.dataimport.util.marc.MarcRecordAnalyzer) Before(org.junit.Before)

Example 2 with MappingParametersProvider

use of org.folio.services.mappers.processor.MappingParametersProvider 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())));
}
Also used : HashMap(java.util.HashMap) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) MappingRuleDaoImpl(org.folio.dao.MappingRuleDaoImpl) JsonObject(io.vertx.core.json.JsonObject) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) OkapiConnectionParams(org.folio.dataimport.util.OkapiConnectionParams) MappingParametersProvider(org.folio.services.mappers.processor.MappingParametersProvider) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) MappingParameters(org.folio.processing.mapping.defaultmapper.processor.parameters.MappingParameters) MarcRecordAnalyzer(org.folio.dataimport.util.marc.MarcRecordAnalyzer) Before(org.junit.Before)

Aggregations

RegexPattern (com.github.tomakehurst.wiremock.matching.RegexPattern)2 UrlPathPattern (com.github.tomakehurst.wiremock.matching.UrlPathPattern)2 JsonObject (io.vertx.core.json.JsonObject)2 HashMap (java.util.HashMap)2 MappingRuleDaoImpl (org.folio.dao.MappingRuleDaoImpl)2 OkapiConnectionParams (org.folio.dataimport.util.OkapiConnectionParams)2 MarcRecordAnalyzer (org.folio.dataimport.util.marc.MarcRecordAnalyzer)2 MappingParameters (org.folio.processing.mapping.defaultmapper.processor.parameters.MappingParameters)2 MappingParametersProvider (org.folio.services.mappers.processor.MappingParametersProvider)2 Before (org.junit.Before)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2