public void SolrFieldParsing() { var schemaParser = new SolrSchemaParser(); var xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaBasic.xml"); SolrSchema 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 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 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 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 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 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.AreEqual(0, validationResults.Count); }
public void MatchingUniqueKeyMappingShouldNotReturnError() { var mgr = new MappingManager(); mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("ID"), "id"); mgr.SetUniqueKey(typeof (SchemaMappingTestDocument).GetProperty("ID")); 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(0, 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.AreEqual(1, validationResults.Count); }
public void MappedPropertyForWhichDynamicFieldExistsInSchemaShouldNotReturnError() { var mgr = new MappingManager(); mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("ID"), "id"); mgr.SetUniqueKey(typeof (SchemaMappingTestDocument).GetProperty("ID")); mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("Name"), "name"); mgr.Add(typeof (SchemaMappingTestDocument).GetProperty("Producer"), "producer_s"); 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.AreEqual(0, validationResults.Count); }
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 UniqueKeyEmpty() { var schemaParser = new SolrSchemaParser(); XmlDocument xml = EmbeddedResource.GetEmbeddedXml(GetType(), "Resources.solrSchemaEmptyUniqueKey.xml"); SolrSchema schemaDoc = schemaParser.Parse(xml); Assert.IsNull(schemaDoc.UniqueKey); }