diff options
Diffstat (limited to 'config-model/src/test/java/com/yahoo/schema/processing/ImplicitSchemaFieldsTestCase.java')
-rw-r--r-- | config-model/src/test/java/com/yahoo/schema/processing/ImplicitSchemaFieldsTestCase.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/config-model/src/test/java/com/yahoo/schema/processing/ImplicitSchemaFieldsTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/ImplicitSchemaFieldsTestCase.java new file mode 100644 index 00000000000..594124c9500 --- /dev/null +++ b/config-model/src/test/java/com/yahoo/schema/processing/ImplicitSchemaFieldsTestCase.java @@ -0,0 +1,94 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.schema.processing; + +import com.yahoo.schema.Schema; +import com.yahoo.schema.ApplicationBuilder; +import com.yahoo.schema.AbstractSchemaTestCase; +import com.yahoo.schema.derived.DerivedConfiguration; +import com.yahoo.schema.document.SDDocumentType; +import com.yahoo.schema.parser.ParseException; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { + + @Test + public void testRequireThatExtraFieldsAreIncluded() throws IOException, ParseException { + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/nextgen/extrafield.sd"); + assertNotNull(schema); + + SDDocumentType docType = schema.getDocument(); + assertNotNull(docType); + assertNotNull(docType.getField("foo")); + assertNotNull(docType.getField("bar")); + assertEquals(2, docType.getFieldCount()); + } + + @Test + public void testRequireThatSummaryFieldsAreIncluded() throws IOException, ParseException { + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/nextgen/summaryfield.sd"); + assertNotNull(schema); + + SDDocumentType docType = schema.getDocument(); + assertNotNull(docType); + assertNotNull(docType.getField("foo")); + assertNotNull(docType.getField("bar")); + assertNotNull(docType.getField("cox")); + assertNotNull(docType.getField("mytags")); + assertNotNull(docType.getField("alltags")); + assertEquals(5, docType.getFieldCount()); + } + + @Test + public void testRequireThatBoldedSummaryFieldsAreIncluded() throws IOException, ParseException { + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/nextgen/boldedsummaryfields.sd"); + assertNotNull(schema); + + SDDocumentType docType = schema.getDocument(); + assertNotNull(docType); + assertNotNull(docType.getField("foo")); + assertNotNull(docType.getField("bar")); + assertNotNull(docType.getField("baz")); + assertNotNull(docType.getField("cox")); + assertEquals(4, docType.getFieldCount()); + } + + @Test + public void testRequireThatUntransformedSummaryFieldsAreIgnored() throws IOException, ParseException { + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/nextgen/untransformedsummaryfields.sd"); + assertNotNull(schema); + + SDDocumentType docType = schema.getDocument(); + assertNotNull(docType); + assertNotNull(docType.getField("foo")); + assertNotNull(docType.getField("bar")); + assertNotNull(docType.getField("baz")); + assertEquals(3, docType.getFieldCount()); + } + + @Test + public void testRequireThatDynamicSummaryFieldsAreIgnored() throws IOException, ParseException { + Schema schema = ApplicationBuilder.buildFromFile("src/test/examples/nextgen/dynamicsummaryfields.sd"); + assertNotNull(schema); + + SDDocumentType docType = schema.getDocument(); + assertNotNull(docType); + assertNotNull(docType.getField("foo")); + assertNotNull(docType.getField("bar")); + assertEquals(2, docType.getFieldCount()); + } + + @Test + public void testRequireThatDerivedConfigurationWorks() throws IOException, ParseException { + ApplicationBuilder sb = new ApplicationBuilder(); + sb.addSchemaFile("src/test/examples/nextgen/simple.sd"); + sb.build(true); + assertNotNull(sb.getSchema()); + new DerivedConfiguration(sb.getSchema(), sb.getRankProfileRegistry()); + } + +} |