public ParquetDataProcessor( IFhirSchemaManager <FhirParquetSchemaNode> fhirSchemaManager, IOptions <ArrowConfiguration> arrowConfiguration, ILogger <ParquetDataProcessor> logger) { EnsureArg.IsNotNull(fhirSchemaManager, nameof(fhirSchemaManager)); EnsureArg.IsNotNull(arrowConfiguration, nameof(arrowConfiguration)); EnsureArg.IsNotNull(logger, nameof(logger)); _fhirSchemaManager = fhirSchemaManager; _arrowConfiguration = arrowConfiguration.Value; _logger = logger; try { _parquetConverterWrapper = new ParquetConverterWrapper(_fhirSchemaManager.GetAllSchemas(), arrowConfiguration.Value); } catch (Exception ex) { _logger.LogError("Create ParquetConverterWrapper failed."); throw new ParquetDataProcessorException("Create ParquetConverterWrapper failed. " + ex.Message, ex); } _logger.LogInformation($"ParquetDataProcessor initialized successfully with ArrowConfiguration: {JsonConvert.SerializeObject(arrowConfiguration.Value)}."); }
public void GivenNullOrEmptyInputStream_WhenConvertToParquetStream_ExceptionShouldBeThrown() { var parquetConverterWrapper = new ParquetConverterWrapper(TestConstants.TestSchemaMap); Assert.Throws <ArgumentException>(() => parquetConverterWrapper.ConvertToParquetStream("Patient", null)); Assert.Throws <ArgumentException>(() => parquetConverterWrapper.ConvertToParquetStream("Patient", new MemoryStream(Encoding.UTF8.GetBytes(string.Empty)))); }
public void GivenValidInputData_WhenConvertToParquetStream_CorrectStreamShouldBeReturned() { var parquetConverterWrapper = new ParquetConverterWrapper(TestConstants.TestSchemaMap, new ArrowConfiguration()); var inputStream = new MemoryStream(Encoding.UTF8.GetBytes("{\"resourceType\":\"Patient\",\"id\":\"example\"}")); var outputStream = parquetConverterWrapper.ConvertToParquetStream("Patient", inputStream); Assert.True(outputStream.Length > 0); }
public void GivenUnsupportedResourceType_WhenConvertToParquetStream_ExceptionShouldBeThrown(string resourceType) { var parquetConverterWrapper = new ParquetConverterWrapper(TestConstants.TestSchemaMap); Assert.Throws <ArgumentException>(() => parquetConverterWrapper.ConvertToParquetStream(resourceType, new MemoryStream(Encoding.UTF8.GetBytes("content")))); }
public void GivenValidSchemaMapAndArrowConfiguration_WhenCreateParquetConverterWrapper_ParquetConverterWrapperShouldBeCreated() { _ = new ParquetConverterWrapper(TestConstants.TestSchemaMap); _ = new ParquetConverterWrapper(TestConstants.TestSchemaMap, new ArrowConfiguration()); }