public void SolrFieldParsing() { var schemaParser = new SolrSchemaParser(); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml"); var schemaDoc = schemaParser.Parse(xml); Assert.AreEqual(4, schemaDoc.SolrFields.Count); Assert.AreEqual("id", schemaDoc.SolrFields[0].Name); Assert.IsTrue(schemaDoc.SolrFields[0].IsRequired); Assert.IsFalse(schemaDoc.SolrFields[2].IsRequired); Assert.IsTrue(schemaDoc.SolrFields[3].IsMultiValued); Assert.IsFalse(schemaDoc.SolrFields[0].IsMultiValued); Assert.IsTrue(schemaDoc.SolrFields[2].IsIndexed); Assert.IsFalse(schemaDoc.SolrFields[3].IsIndexed); Assert.IsTrue(schemaDoc.SolrFields[0].IsStored); Assert.IsFalse(schemaDoc.SolrFields[3].IsStored); Assert.IsFalse(schemaDoc.SolrFields[1].IsDocValues); Assert.IsFalse(schemaDoc.SolrFields[2].IsDocValues); Assert.IsTrue(schemaDoc.SolrFields[3].IsDocValues); Assert.AreEqual("string", schemaDoc.SolrFields[0].Type.Name); }
public void UniqueKeyNotPresent() { var schemaParser = new SolrSchemaParser(); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaNoUniqueKey.xml"); SolrSchema schemaDoc = schemaParser.Parse(xml); Assert.IsNull(schemaDoc.UniqueKey); }
public void UniqueKeyPresent() { var schemaParser = new SolrSchemaParser(); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml"); SolrSchema schemaDoc = schemaParser.Parse(xml); Assert.AreEqual("id", schemaDoc.UniqueKey); }
public void UniqueKeyEmptyManagedSchema() { var schemaParser = new SolrSchemaParser(); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrManagedSchemaEmptyUniqueKey.xml"); SolrSchema schemaDoc = schemaParser.Parse(xml); Assert.Null(schemaDoc.UniqueKey); }
public void SolrDynamicFieldParsing() { var schemaParser = new SolrSchemaParser(); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml"); SolrSchema schemaDoc = schemaParser.Parse(xml); Assert.AreEqual(1, schemaDoc.SolrDynamicFields.Count); Assert.AreEqual("*_s", schemaDoc.SolrDynamicFields[0].Name); }
public void SolrDynamicFieldParsingManagedSchema() { var schemaParser = new SolrSchemaParser(); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrManagedSchemaBasic.xml"); SolrSchema schemaDoc = schemaParser.Parse(xml); Assert.Single(schemaDoc.SolrDynamicFields); Assert.Equal("*_s", schemaDoc.SolrDynamicFields[0].Name); }
public void SolrCopyFieldParsing() { var schemaParser = new SolrSchemaParser(); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml"); SolrSchema schemaDoc = schemaParser.Parse(xml); Assert.AreEqual(1, schemaDoc.SolrCopyFields.Count); Assert.AreEqual("name", schemaDoc.SolrCopyFields[0].Source); Assert.AreEqual("nameSort", schemaDoc.SolrCopyFields[0].Destination); }
public void SolrFieldTypeParsing() { var schemaParser = new SolrSchemaParser(); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml"); SolrSchema schemaDoc = schemaParser.Parse(xml); Assert.AreEqual(2, schemaDoc.SolrFieldTypes.Count); Assert.AreEqual("string", schemaDoc.SolrFieldTypes[0].Name); Assert.AreEqual("solr.StrField", schemaDoc.SolrFieldTypes[0].Type); }
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 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 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); }