AbstractCoreKeyIteratorSettingsFactory implements IteratorSettingFactory { @Override public IteratorSetting getValidatorIteratorSetting(final AccumuloStore store) { if (!store.getSchema().hasValidation()) { LOGGER.debug("Returning null from getValidatorIteratorSetting as store.getSchema().hasValidation() = {}", store.getSchema().hasValidation()); return null; } final IteratorSetting is = new IteratorSettingBuilder(AccumuloStoreConstants.VALIDATOR_ITERATOR_PRIORITY, AccumuloStoreConstants.VALIDATOR_ITERATOR_NAME, ValidatorFilter.class) .schema(store.getSchema()) .keyConverter(store.getKeyPackage().getKeyConverter()) .build(); LOGGER.debug("Creating IteratorSetting for iterator class {} with priority = {}, " + "schema = {}, keyConverter = {}", ValidatorFilter.class.getName(), AccumuloStoreConstants.VALIDATOR_ITERATOR_PRIORITY, store.getSchema(), store.getKeyPackage().getKeyConverter()); return is; }  @Override IteratorSetting getBloomFilterIteratorSetting(final BloomFilter filter); @Override IteratorSetting getElementPreAggregationFilterIteratorSetting(final View view, final AccumuloStore store); @Override IteratorSetting getElementPostAggregationFilterIteratorSetting(final View view, final AccumuloStore store); @Override IteratorSetting getAggregatorIteratorSetting(final AccumuloStore store); @Override IteratorSetting getRowIDAggregatorIteratorSetting(final AccumuloStore store, final String columnFamily); @Override IteratorSetting getValidatorIteratorSetting(final AccumuloStore store); @Override IteratorSetting getQueryTimeAggregatorIteratorSetting(final View view, final AccumuloStore store); boolean queryTimeAggregatorRequired(final View view, final AccumuloStore store); @Override IteratorSetting getIteratorSetting(final AccumuloStore store, final String iteratorName);  }
@Test public void shouldReturnNullValidatorIteratorIfNoSchemaValidation() throws Exception { final AccumuloStore store = mock(AccumuloStore.class); final Schema schema = createSchema(); given(store.getSchema()).willReturn(schema); final IteratorSetting iterator = factory.getValidatorIteratorSetting(store); assertNull(iterator); }
@Test public void shouldReturnIteratorValidatorIterator() throws Exception { final AccumuloStore store = mock(AccumuloStore.class); final Schema schema = new Schema.Builder() .merge(createSchema()) .type("str", new TypeDefinition.Builder() .validateFunctions(new Exists()) .build()) .build(); final AccumuloKeyPackage keyPackage = mock(AccumuloKeyPackage.class); final AccumuloElementConverter converter = mock(AccumuloElementConverter.class); given(store.getSchema()).willReturn(schema); given(store.getKeyPackage()).willReturn(keyPackage); given(keyPackage.getKeyConverter()).willReturn(converter); final IteratorSetting iterator = factory.getValidatorIteratorSetting(store); assertEquals(AccumuloStoreConstants.VALIDATOR_ITERATOR_NAME, iterator.getName()); assertEquals(AccumuloStoreConstants.VALIDATOR_ITERATOR_PRIORITY, iterator.getPriority()); assertEquals(ValidatorFilter.class.getName(), iterator.getIteratorClass()); JsonAssert.assertEquals(schema.toCompactJson(), iterator.getOptions().get(AccumuloStoreConstants.SCHEMA).getBytes()); assertEquals(converter.getClass().getName(), iterator.getOptions().get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS)); }