public IObjectMapper GetOrCreateMapper() { if (_mapper != null) { return(_mapper); } _mapper = MapperContext.ObjectMapperFactory.Create(this); MapperKey.MappingData = null; if (_mapper == null) { return(null); } if (MapperContext.UserConfigurations.ValidateMappingPlans) { // TODO: Test coverage for validation of standalone child mappers MappingValidator.Validate(_mapper.MapperData); } StaticMapperCache <TSource, TTarget> .AddIfAppropriate(_mapper, this); return(_mapper); }
public void Mapping_CanCreate() { Mapping mapping = NewMapping(NewBinding <Person, PersonDto>()); var actual = MappingValidator.IsValid(mapping); Assert.AreEqual(true, actual); }
public void ValidatingRuleSetReturnsValidationResults() { var mappingManager = new MappingManager(); var mappingValidationManager = new MappingValidator(mappingManager, new[] { new DummyValidationRuleError() }); var validationResults = mappingValidationManager.EnumerateValidationResults(typeof(SchemaMappingTestDocument), new SolrSchema()).ToList(); Assert.AreEqual(1, validationResults.Count); }
public void ValidateWithEmptyIdAndName1() { var mapping = new Dictionary <MappingInfo, MappingInfo> { { new MappingInfo(string.Empty, string.Empty), new MappingInfo(string.Empty, "Name") }, }; var validator = new MappingValidator(mapping, "Tester") { JiraConnector = ConnectorMock, Logger = LoggerMock };; Assert.IsFalse(validator.Validate(), "Incorrect validator processing."); }
public void ValidateWithEmptyName() { var mapping = new Dictionary <MappingInfo, MappingInfo> { { new MappingInfo("Scope:0", string.Empty), new MappingInfo("0", string.Empty) }, { new MappingInfo("Scope:1", string.Empty), new MappingInfo("1", string.Empty) }, }; var validator = new MappingValidator(mapping, "Tester") { JiraConnector = ConnectorMock, Logger = LoggerMock };; Assert.IsTrue(validator.Validate(), "Incorrect validator processing."); }
public MappingValidatorTests() { _fhirTemplateFactory = CollectionFhirTemplateFactory.Default; _collectionTemplateFactory = new CollectionContentTemplateFactory( new JsonPathContentTemplateFactory(), new IotJsonPathContentTemplateFactory(), new IotCentralJsonPathContentTemplateFactory()); _iotConnectorValidator = new MappingValidator( _collectionTemplateFactory, _fhirTemplateFactory, new R4FhirLookupTemplateProcessor()); }
public void StringMappedToStringShouldNotReturnError() { var mappingTypesCompatibleRule = new MappingTypesAreCompatibleWithSolrTypesRule(new[] { new StringSolrFieldTypeChecker() }); var mgr = new MappingManager(); var schemaManager = new MappingValidator(mgr, new[] { mappingTypesCompatibleRule }); var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaMappingTypes.xml"); var solrSchemaParser = new SolrSchemaParser(); var schema = solrSchemaParser.Parse(schemaXmlDocument); var validationResults = schemaManager.EnumerateValidationResults(typeof(SchemaMappingTestDocument), schema).ToList(); Assert.Equal(0, validationResults.Count); }
public void MultivaluedSolrFieldMappedToCollectionShouldNotReturnError() { var mgr = new MappingManager(); mgr.Add(typeof(SchemaMappingTestDocument).GetProperty("NameCollection"), "name"); var schemaManager = new MappingValidator(mgr, new[] { new MultivaluedMappedToCollectionRule() }); var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaMultiValuedName.xml"); var solrSchemaParser = new SolrSchemaParser(); var schema = solrSchemaParser.Parse(schemaXmlDocument); var validationResults = schemaManager.EnumerateValidationResults(typeof(SchemaMappingTestDocument), schema).ToList(); Assert.AreEqual(0, validationResults.Count); }
public ISolrOperations <T> GetServer(ISolrConnection connection) { var basicServer = GetBasicServer(connection); MappingValidator = new MappingValidator(MappingManager, new IValidationRule[] { new MappedPropertiesIsInSolrSchemaRule(), new RequiredFieldsAreMappedRule(), new UniqueKeyMatchesMappingRule(), new MultivaluedMappedToCollectionRule() }); ISolrOperations <T> server = new SolrServer <T>(basicServer, MappingManager, MappingValidator); return(server); }
public void NonMatchingUniqueKeyMappingShouldReturnError() { var mgr = new MappingManager(); mgr.Add(typeof(SchemaMappingTestDocument).GetProperty("Name"), "name"); mgr.SetUniqueKey(typeof(SchemaMappingTestDocument).GetProperty("Name")); var schemaManager = new MappingValidator(mgr, new[] { new UniqueKeyMatchesMappingRule() }); var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml"); var solrSchemaParser = new SolrSchemaParser(); var schema = solrSchemaParser.Parse(schemaXmlDocument); var validationResults = schemaManager.EnumerateValidationResults(typeof(SchemaMappingTestDocument), schema).ToList(); Assert.AreEqual(1, validationResults.Count); }
public static ISolrOperations <T> GetServer <T>(ISolrConnection connection) { IReadOnlyMappingManager mapper = new MemoizingMappingManager(new AttributesMappingManager()); IReadOnlyMappingManager mappingManager = mapper; IMappingValidator mappingValidator = new MappingValidator(mapper, new IValidationRule[] { new MappedPropertiesIsInSolrSchemaRule(), new RequiredFieldsAreMappedRule(), new UniqueKeyMatchesMappingRule(), new MultivaluedMappedToCollectionRule() }); var basicServer = GetBasicServer <T>(connection); ISolrOperations <T> server = new SolrServer <T>(basicServer, mappingManager, mappingValidator); return(server); }
public void RequiredSolrFieldForWhichNoCopyFieldExistsShouldReturnError() { var mgr = new MappingManager(); mgr.Add(typeof(SchemaMappingTestDocument).GetProperty("ID"), "id"); mgr.SetUniqueKey(typeof(SchemaMappingTestDocument).GetProperty("ID")); var schemaManager = new MappingValidator(mgr, new[] { new RequiredFieldsAreMappedRule() }); var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml"); var solrSchemaParser = new SolrSchemaParser(); var schema = solrSchemaParser.Parse(schemaXmlDocument); var validationResults = schemaManager.EnumerateValidationResults(typeof(SchemaMappingTestDocument), schema).ToList(); Assert.Equal(1, validationResults.Count); }
public void CollectionMappedToNonMultiValuedFolrFieldShouldReturnError() { var mgr = new MappingManager(); mgr.Add(typeof(SchemaMappingTestDocument).GetProperty("NameCollection"), "author"); var schemaManager = new MappingValidator(mgr, new[] { new MultivaluedMappedToCollectionRule() }); var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaMultiValuedName.xml"); var solrSchemaParser = new SolrSchemaParser(); var schema = solrSchemaParser.Parse(schemaXmlDocument); var validationResults = schemaManager.EnumerateValidationResults(typeof(SchemaMappingTestDocument), schema).ToList(); Assert.Single(validationResults); testOutputHelper.WriteLine(validationResults[0].Message); }
public void MappedPropertyForWhichSolrFieldExistsInSchemaShouldNotReturnError() { var mgr = new MappingManager(); mgr.Add(typeof(SchemaMappingTestDocument).GetProperty("ID"), "id"); mgr.SetUniqueKey(typeof(SchemaMappingTestDocument).GetProperty("ID")); mgr.Add(typeof(SchemaMappingTestDocument).GetProperty("Name"), "name"); var schemaManager = new MappingValidator(mgr, new[] { new MappedPropertiesIsInSolrSchemaRule() }); var schemaXmlDocument = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml"); var solrSchemaParser = new SolrSchemaParser(); var schema = solrSchemaParser.Parse(schemaXmlDocument); var validationResults = schemaManager.EnumerateValidationResults(typeof(SchemaMappingTestDocument), schema).ToList(); Assert.Empty(validationResults); }
public void ThrowNowIfMappingPlanIsIncomplete() => MappingValidator.Validate(ConfigInfo);
void IMapper.ThrowNowIfAnyMappingPlanIsIncomplete() => MappingValidator.Validate(this);