Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbarny committed Apr 8, 2024
1 parent 30d83cb commit c0c5333
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
@@ -0,0 +1,30 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

package org.elasticsearch.index.mapper;

import org.elasticsearch.test.ESTestCase;

public class MapperBuilderContextTest extends ESTestCase {

public void testRoot() {
MapperBuilderContext root = MapperBuilderContext.root(false, false);
assertFalse(root.isSourceSynthetic());
assertFalse(root.isDataStream());
assertEquals(MapperService.MergeReason.MAPPING_UPDATE, root.getMergeReason());
}

public void testRootWithMergeReason() {
MapperService.MergeReason mergeReason = randomFrom(MapperService.MergeReason.values());
MapperBuilderContext root = MapperBuilderContext.root(false, false, mergeReason);
assertFalse(root.isSourceSynthetic());
assertFalse(root.isDataStream());
assertEquals(mergeReason, root.getMergeReason());
}

}
Expand Up @@ -29,4 +29,10 @@ public void testAddFieldIfPossibleUnlimited() {
assertTrue(context.decrementFieldBudgetIfPossible(Integer.MAX_VALUE));
}

public void testMergeReasons() {
MapperService.MergeReason mergeReason = randomFrom(MapperService.MergeReason.values());
MapperMergeContext context = MapperMergeContext.root(false, false, mergeReason, Integer.MAX_VALUE);
assertEquals(mergeReason, context.getMapperBuilderContext().getMergeReason());
}

}

0 comments on commit c0c5333

Please sign in to comment.