IndexSettings should not be Null in Mapper.BuildContext
Rename method name Change validation Closes #20174
This commit is contained in:
parent
75c9e4f418
commit
ddced5df1a
|
@ -39,7 +39,7 @@ public abstract class Mapper implements ToXContent, Iterable<Mapper> {
|
|||
private final ContentPath contentPath;
|
||||
|
||||
public BuilderContext(Settings indexSettings, ContentPath contentPath) {
|
||||
assert indexSettings != null;
|
||||
Objects.requireNonNull(indexSettings, "indexSettings is required");
|
||||
this.contentPath = contentPath;
|
||||
this.indexSettings = indexSettings;
|
||||
}
|
||||
|
|
|
@ -24,20 +24,19 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
public class MapperTests extends ESTestCase {
|
||||
|
||||
public void testBuilderContextWithIndexSettings() {
|
||||
public void testSuccessfulBuilderContext() {
|
||||
Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
|
||||
Mapper.BuilderContext context = new Mapper.BuilderContext(settings, new ContentPath(1));
|
||||
ContentPath contentPath = new ContentPath(1);
|
||||
Mapper.BuilderContext context = new Mapper.BuilderContext(settings, contentPath);
|
||||
|
||||
assertNotNull(context.indexSettings());
|
||||
assertThat(context.indexSettings(), equalTo(settings));
|
||||
assertEquals(settings, context.indexSettings());
|
||||
assertEquals(contentPath, context.path());
|
||||
}
|
||||
|
||||
public void testBuilderContextWithIndexSettingsAsNull() {
|
||||
AssertionError e = expectThrows(AssertionError.class, () -> new Mapper.BuilderContext(null, new ContentPath(1)));
|
||||
NullPointerException e = expectThrows(NullPointerException.class, () -> new Mapper.BuilderContext(null, new ContentPath(1)));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue