Class NumberFieldBlockLoaderTestCase<T extends Number>


public abstract class NumberFieldBlockLoaderTestCase<T extends Number> extends BlockLoaderTestCase
  • Constructor Details

  • Method Details

    • expected

      protected Object expected(Map<String,Object> fieldMapping, Object value, BlockLoaderTestCase.TestContext testContext)
      Description copied from class: BlockLoaderTestCase
      For a given mapping and input value, compute the value that will be in the block. Values are generated from the DocumentGenerator, and the behavior can be controled by writing a custom DataSourceHandler.
      Specified by:
      expected in class BlockLoaderTestCase
      Parameters:
      fieldMapping - Generated parameters for this field mapping
      value - Generated input value to convert
      testContext - Context information for the current test run
      Returns:
      The value that will be added to the block
    • tryParseString

      protected Number tryParseString(String s)
      Tries to parse a string as a number, matching the behavior used during indexing (doc values) and when reading from _ignored_source via NumberFallbackSyntheticSourceReader. Returns null if the string cannot be parsed as a valid number.

      Both paths use NumberType.parse(XContentParser, boolean). The default implementation uses Double.parseDouble(String), which matches the coercion behavior of most numeric field mappers.

    • tryParseStringFromSource

      protected Number tryParseStringFromSource(String s)
      Tries to parse a string as a number, matching the behavior used when re-parsing from the original stored _source (via the SourceValueFetcher returned from NumberFieldType#sourceValueFetcher). Returns null if the string cannot be parsed as a valid number.

      The stored-source path uses NumberType.parse(Object, boolean).

      This is intentionally separate from tryParseString(String) because the two paths can differ (see LongFieldBlockLoaderTests).

    • convert

      protected abstract T convert(Number value, Map<String,Object> fieldMapping)
    • testBlockLoaderNonLatinDigit

      public void testBlockLoaderNonLatinDigit() throws IOException
      Throws:
      IOException
    • testBlockLoaderNonLatinDigit_parseFromSource

      public void testBlockLoaderNonLatinDigit_parseFromSource() throws IOException
      Throws:
      IOException