use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.
the class ClassicEdgeDirectedUndirectedFilterIteratorTest method shouldOnlyAcceptDeduplicatedUndirectedEdges.
@Test
public void shouldOnlyAcceptDeduplicatedUndirectedEdges() throws OperationException, AccumuloElementConversionException {
// Given
final ClassicEdgeDirectedUndirectedFilterIterator filter = new ClassicEdgeDirectedUndirectedFilterIterator();
final Map<String, String> options = new HashMap<String, String>() {
{
put(AccumuloStoreConstants.DEDUPLICATE_UNDIRECTED_EDGES, "true");
put(AccumuloStoreConstants.UNDIRECTED_EDGE_ONLY, "true");
}
};
filter.validateOptions(options);
// value should not be used
final Value value = null;
// When / Then
for (final Edge edge : EDGES) {
final Pair<Key> keys = converter.getKeysFromEdge(edge);
// First key is deduplicated
assertEquals("Failed for edge: " + edge.toString(), !edge.isDirected(), filter.accept(keys.getFirst(), value));
if (null != keys.getSecond()) {
// self edges are not added the other way round
assertFalse("Failed for edge: " + edge.toString(), filter.accept(keys.getSecond(), value));
}
}
}
use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.
the class ElementPostAggregationFilterTest method shouldAcceptElementWhenViewValidatorAcceptsElement.
@Test
public void shouldAcceptElementWhenViewValidatorAcceptsElement() throws Exception {
// Given
final AbstractElementFilter filter = new ElementPostAggregationFilter();
final Map<String, String> options = new HashMap<>();
options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
options.put(AccumuloStoreConstants.VIEW, getViewJson());
options.put(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, ByteEntityAccumuloElementConverter.class.getName());
filter.validateOptions(options);
final ByteEntityAccumuloElementConverter converter = new ByteEntityAccumuloElementConverter(getSchema());
final Element element = new Edge(TestGroups.EDGE, "source", "dest", true);
final Pair<Key> key = converter.getKeysFromElement(element);
final Value value = converter.getValueFromElement(element);
// When
final boolean accept = filter.accept(key.getFirst(), value);
// Then
assertTrue(accept);
}
use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.
the class ElementPostAggregationFilterTest method shouldNotAcceptElementWhenViewValidatorDoesNotAcceptElement.
@Test
public void shouldNotAcceptElementWhenViewValidatorDoesNotAcceptElement() throws Exception {
// Given
final AbstractElementFilter filter = new ElementPostAggregationFilter();
final Map<String, String> options = new HashMap<>();
options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
options.put(AccumuloStoreConstants.VIEW, getEmptyViewJson());
options.put(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, ByteEntityAccumuloElementConverter.class.getName());
filter.validateOptions(options);
final ByteEntityAccumuloElementConverter converter = new ByteEntityAccumuloElementConverter(getSchema());
final Element element = new Edge(TestGroups.EDGE, "source", "dest", true);
final Pair<Key> key = converter.getKeysFromElement(element);
final Value value = converter.getValueFromElement(element);
// When
final boolean accept = filter.accept(key.getFirst(), value);
// Then
assertFalse(accept);
}
use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.
the class ElementPreAggregationFilterTest method shouldAcceptElementWhenViewValidatorAcceptsElement.
@Test
public void shouldAcceptElementWhenViewValidatorAcceptsElement() throws Exception {
// Given
final AbstractElementFilter filter = new ElementPreAggregationFilter();
final Map<String, String> options = new HashMap<>();
options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
options.put(AccumuloStoreConstants.VIEW, getViewJson());
options.put(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, ByteEntityAccumuloElementConverter.class.getName());
filter.validateOptions(options);
final ByteEntityAccumuloElementConverter converter = new ByteEntityAccumuloElementConverter(getSchema());
final Element element = new Edge(TestGroups.EDGE, "source", "dest", true);
final Pair<Key> key = converter.getKeysFromElement(element);
final Value value = converter.getValueFromElement(element);
// When
final boolean accept = filter.accept(key.getFirst(), value);
// Then
assertTrue(accept);
}
use of org.apache.accumulo.core.data.Key in project Gaffer by gchq.
the class ValidatorFilterTest method shouldAcceptElementWhenSchemaValidatorAcceptsElement.
@Test
public void shouldAcceptElementWhenSchemaValidatorAcceptsElement() throws Exception {
// Given
final ValidatorFilter filter = new ValidatorFilter();
final Map<String, String> options = new HashMap<>();
options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
options.put(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, ByteEntityAccumuloElementConverter.class.getName());
filter.validateOptions(options);
final ByteEntityAccumuloElementConverter converter = new ByteEntityAccumuloElementConverter(getSchema());
final Element element = new Edge(TestGroups.EDGE, "source", "dest", true);
final Pair<Key> key = converter.getKeysFromElement(element);
final Value value = converter.getValueFromElement(element);
// When
final boolean accept = filter.accept(key.getFirst(), value);
// Then
assertTrue(accept);
}
Aggregations