use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.
the class AbstractCoreKeyIteratorSettingsFactoryTest method shouldReturnIteratorValidatorIterator.
@Test
public void shouldReturnIteratorValidatorIterator() throws Exception {
// Given
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);
// When
final IteratorSetting iterator = factory.getValidatorIteratorSetting(store);
// Then
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));
}
use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.
the class AbstractCoreKeyIteratorSettingsFactoryTest method shouldReturnPreAggFilterIterator.
@Test
public void shouldReturnPreAggFilterIterator() throws Exception {
// Given
final AccumuloStore store = mock(AccumuloStore.class);
final Schema schema = createSchema();
final View view = new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build()).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);
// When
final IteratorSetting iterator = factory.getElementPreAggregationFilterIteratorSetting(view, store);
// Then
assertEquals(AccumuloStoreConstants.ELEMENT_PRE_AGGREGATION_FILTER_ITERATOR_NAME, iterator.getName());
assertEquals(AccumuloStoreConstants.ELEMENT_PRE_AGGREGATION_FILTER_ITERATOR_PRIORITY, iterator.getPriority());
assertEquals(ElementPreAggregationFilter.class.getName(), iterator.getIteratorClass());
JsonAssert.assertEquals(schema.toCompactJson(), iterator.getOptions().get(AccumuloStoreConstants.SCHEMA).getBytes());
JsonAssert.assertEquals(view.toCompactJson(), iterator.getOptions().get(AccumuloStoreConstants.VIEW).getBytes());
assertEquals(converter.getClass().getName(), iterator.getOptions().get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS));
}
use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.
the class AbstractCoreKeyIteratorSettingsFactoryTest method shouldReturnNullPreAggFilterIfNoPreAggFilters.
@Test
public void shouldReturnNullPreAggFilterIfNoPreAggFilters() throws Exception {
// Given
final AccumuloStore store = mock(AccumuloStore.class);
final Schema schema = createSchema();
final View view = new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().postAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build()).build()).build();
given(store.getSchema()).willReturn(schema);
// When
final IteratorSetting iterator = factory.getElementPreAggregationFilterIteratorSetting(view, store);
// Then
assertNull(iterator);
}
Aggregations