Class AbstractBuilderTestCase

java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase
org.elasticsearch.test.ESTestCase
org.elasticsearch.test.AbstractBuilderTestCase
Direct Known Subclasses:
AbstractQueryTestCase, BaseAggregationTestCase

public abstract class AbstractBuilderTestCase extends ESTestCase
  • Field Details

  • Constructor Details

    • AbstractBuilderTestCase

      public AbstractBuilderTestCase()
  • Method Details

    • getIndex

      protected static Index getIndex()
    • getPlugins

      protected Collection<Class<? extends Plugin>> getPlugins()
    • getExtraPlugins

      protected Collection<Class<? extends Plugin>> getExtraPlugins()
      Allows additional plugins other than the required `TestGeoShapeFieldMapperPlugin` Could probably be removed when dependencies against geo_shape is decoupled
    • initializeAdditionalMappings

      protected void initializeAdditionalMappings(MapperService mapperService) throws IOException
      Throws:
      IOException
    • beforeClass

      public static void beforeClass()
    • xContentRegistry

      protected org.elasticsearch.xcontent.NamedXContentRegistry xContentRegistry()
      Description copied from class: ESTestCase
      The NamedXContentRegistry to use for this test. Subclasses should override and use liberally.
      Overrides:
      xContentRegistry in class ESTestCase
    • namedWriteableRegistry

      protected NamedWriteableRegistry namedWriteableRegistry()
    • createUniqueRandomName

      protected static String createUniqueRandomName()
      make sure query names are unique by suffixing them with increasing counter
    • createTestIndexSettings

      protected Settings createTestIndexSettings()
    • indexSettings

      protected static IndexSettings indexSettings()
    • mapperService

      protected static MapperService mapperService()
    • expectedFieldName

      protected static String expectedFieldName(String builderFieldName)
    • afterClass

      public static void afterClass() throws Exception
      Throws:
      Exception
    • beforeTest

      public void beforeTest() throws Exception
      Throws:
      Exception
    • afterTest

      public void afterTest()
    • executeGet

      protected GetResponse executeGet(GetRequest getRequest)
      Override this to handle Client.get(GetRequest) calls from parsers / builders
    • executeMultiTermVectors

      protected MultiTermVectorsResponse executeMultiTermVectors(MultiTermVectorsRequest mtvRequest)
      Override this to handle Client.multiTermVectors(MultiTermVectorsRequest, ActionListener) calls from parsers / builders
    • canSimulateMethod

      protected boolean canSimulateMethod(Method method, Object[] args) throws NoSuchMethodException
      Can the test simulate this Method. If this function returns true simulateMethod(Method, Object[]) should be implemented provide the expected response.
      Parameters:
      method - The method being proxied. In practice method will represent a client call.
      args - Method arguments
      Returns:
      True if simulating the method call is supported
      Throws:
      NoSuchMethodException
    • simulateMethod

      protected Object simulateMethod(Method method, Object[] args)
      Override this to simulate client calls.
    • createSearchExecutionContext

      protected static SearchExecutionContext createSearchExecutionContext(org.apache.lucene.search.IndexSearcher searcher)
      Returns:
      a new SearchExecutionContext with the provided searcher
    • createCoordinatorRewriteContext

      protected static CoordinatorRewriteContext createCoordinatorRewriteContext(DateFieldMapper.DateFieldType dateFieldType, long min, long max)
    • createCoordinatorRewriteContext

      protected static CoordinatorRewriteContext createCoordinatorRewriteContext(DateFieldMapper.DateFieldType dateFieldType, long min, long max, String tier)
    • dataRewriteContext

      protected static DataRewriteContext dataRewriteContext()
    • createShardContextWithNoType

      protected static SearchExecutionContext createShardContextWithNoType()
      Returns:
      a new SearchExecutionContext based on an index with no type registered
    • createSearchExecutionContext

      protected static SearchExecutionContext createSearchExecutionContext()
      Returns:
      a new SearchExecutionContext based on the base test index and queryParserService
    • createQueryRewriteContext

      protected static QueryRewriteContext createQueryRewriteContext()
    • createCircuitBreakerService

      protected static CircuitBreaker createCircuitBreakerService(String limit)
    • createCircuitBreakerService

      protected static CircuitBreaker createCircuitBreakerService()
      Creates a circuit breaker for testing query construction with default limit (10% of heap).
      Returns:
      a configured CircuitBreaker instance
    • createCircuitBreakerService

      protected CircuitBreakerService createCircuitBreakerService(Settings nodeSettings, ClusterSettings clusterSettings)
      Override this method to provide a custom CircuitBreakerService for tests. By default, returns NoneCircuitBreakerService for backwards compatibility.
      Parameters:
      nodeSettings - the node settings
      clusterSettings - the cluster settings
      Returns:
      the CircuitBreakerService to use in tests
    • assertCircuitBreakerTripsOnQueryConstruction

      protected static void assertCircuitBreakerTripsOnQueryConstruction(String breakerLimit, Supplier<QueryBuilder> querySupplier)
      Asserts that building the supplied query trips the circuit breaker with a "Data too large" message.
    • assertCircuitBreakerAccountsForQuery

      protected static void assertCircuitBreakerAccountsForQuery(QueryBuilder queryBuilder) throws IOException
      Asserts that the circuit breaker correctly accounts for the memory used by the given query.
      Throws:
      IOException