BooleanMapper extends KeywordMapper { public BooleanMapper(String field, String column, Boolean validated) { super(field, column, validated, Arrays.asList(String.class, Boolean.class)); } BooleanMapper(String field, String column, Boolean validated);   }
@Test public void testConstructorWithAllArgs() { BooleanMapper mapper = booleanMapper().validated(true).column("column").build("field"); assertEquals("Field is not properly set", "field", mapper.field); assertTrue("Validated is not properly set", mapper.validated); assertEquals("Column is not properly set", "column", mapper.column); assertEquals("Mapped columns are not properly set", 1, mapper.mappedColumns.size()); assertTrue("Mapped columns are not properly set", mapper.mappedColumns.contains("column")); }
@Test public void testJsonSerialization() { BooleanMapperBuilder builder = booleanMapper().validated(true).column("column"); testJson(builder, "{type:\"boolean\",validated:true,column:\"column\"}"); }
@Test public void testJsonSerializationDefaults() { BooleanMapperBuilder builder = booleanMapper(); testJson(builder, "{type:\"boolean\"}"); }
@Test public void testIndexedField() { BooleanMapper mapper = booleanMapper().build("field"); Field field = mapper.indexedField("name", "true") .orElseThrow(() -> new AssertionError("Indexed field is not created")); assertEquals("Indexed field value is wrong", "true", field.stringValue()); assertEquals("Indexed field name is wrong", "name", field.name()); assertFalse("Indexed field type is wrong", field.fieldType().stored()); }
@Test public void testSortedField() { BooleanMapper mapper = booleanMapper().build("field"); Field field = mapper.sortedField("name", "true") .orElseThrow(() -> new AssertionError("Sorted field is not created")); assertEquals("Sorted field type is wrong", DocValuesType.SORTED_SET, field.fieldType().docValuesType()); }
@Test public void testExtractAnalyzers() { BooleanMapper mapper = booleanMapper().build("field"); assertEquals("Analyzer must be keyword", Mapper.KEYWORD_ANALYZER, mapper.analyzer); }
@Test public void testToString() { BooleanMapper mapper = booleanMapper().validated(true).build("field"); assertEquals("Method #toString is wrong", "BooleanMapper{field=field, validated=true, column=field}", mapper.toString()); }
@Test public void testConstructorWithoutArgs() { BooleanMapper mapper = booleanMapper().build("field"); assertEquals("Field is not properly set", "field", mapper.field); assertEquals("Validated is not set to default value", Mapper.DEFAULT_VALIDATED, mapper.validated); assertEquals("Column is not set to default value", "field", mapper.column); assertEquals("Mapped columns are not properly set", 1, mapper.mappedColumns.size()); assertTrue("Mapped columns are not properly set", mapper.mappedColumns.contains("field")); }