use of uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityRangeElementPropertyFilterIterator in project Gaffer by gchq.
the class ByteEntityRangeElementPropertyFilterIteratorTest method shouldOnlyAcceptIncomingEdges.
@Test
public void shouldOnlyAcceptIncomingEdges() throws OperationException, AccumuloElementConversionException {
// Given
final ByteEntityRangeElementPropertyFilterIterator filter = new ByteEntityRangeElementPropertyFilterIterator();
final Map<String, String> options = new HashMap<String, String>() {
{
put(AccumuloStoreConstants.DIRECTED_EDGE_ONLY, "true");
put(AccumuloStoreConstants.INCOMING_EDGE_ONLY, "true");
}
};
filter.validateOptions(options);
// value should not be used
final Value value = null;
// When / Then
for (final Element element : ELEMENTS) {
final Pair<Key> keys = converter.getKeysFromElement(element);
assertEquals("Failed for element: " + element.toString(), false, filter.accept(keys.getFirst(), value));
if (null != keys.getSecond()) {
// self elements are not added the other way round
final boolean expectedResult = element instanceof Edge && ((Edge) element).isDirected();
assertEquals("Failed for element: " + element.toString(), expectedResult, filter.accept(keys.getSecond(), value));
}
}
}
use of uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityRangeElementPropertyFilterIterator in project Gaffer by gchq.
the class ByteEntityRangeElementPropertyFilterIteratorTest method shouldOnlyAcceptDeduplicatedUndirectedEdges.
@Test
public void shouldOnlyAcceptDeduplicatedUndirectedEdges() throws OperationException, AccumuloElementConversionException {
// Given
final ByteEntityRangeElementPropertyFilterIterator filter = new ByteEntityRangeElementPropertyFilterIterator();
final Map<String, String> options = new HashMap<String, String>() {
{
put(AccumuloStoreConstants.DEDUPLICATE_UNDIRECTED_EDGES, "true");
put(AccumuloStoreConstants.UNDIRECTED_EDGE_ONLY, "true");
put(AccumuloStoreConstants.OUTGOING_EDGE_ONLY, "true");
}
};
filter.validateOptions(options);
// value should not be used
final Value value = null;
// When / Then
for (final Element element : ELEMENTS) {
final Pair<Key> keys = converter.getKeysFromElement(element);
// First key is deduplicated, but only undirected edges should be excepted
final boolean expectedResult = element instanceof Edge && !((Edge) element).isDirected();
assertEquals("Failed for element: " + element.toString(), expectedResult, filter.accept(keys.getFirst(), value));
if (null != keys.getSecond()) {
// self elements are not added the other way round
assertEquals("Failed for element: " + element.toString(), false, filter.accept(keys.getSecond(), value));
}
}
}
use of uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityRangeElementPropertyFilterIterator in project Gaffer by gchq.
the class ByteEntityRangeElementPropertyFilterIteratorTest method shouldAcceptOnlyEntities.
@Test
public void shouldAcceptOnlyEntities() throws OperationException, AccumuloElementConversionException {
// Given
final ByteEntityRangeElementPropertyFilterIterator filter = new ByteEntityRangeElementPropertyFilterIterator();
final Map<String, String> options = new HashMap<String, String>() {
{
put(AccumuloStoreConstants.NO_EDGES, "true");
put(AccumuloStoreConstants.INCLUDE_ENTITIES, "true");
put(AccumuloStoreConstants.OUTGOING_EDGE_ONLY, "true");
}
};
filter.validateOptions(options);
// value should not be used
final Value value = null;
// When / Then
for (final Element element : ELEMENTS) {
final boolean expectedResult = element instanceof Entity;
final Pair<Key> keys = converter.getKeysFromElement(element);
assertEquals("Failed for element: " + element.toString(), expectedResult, filter.accept(keys.getFirst(), value));
if (null != keys.getSecond()) {
// entities and self edges are not added the other way round
assertEquals("Failed for element: " + element.toString(), expectedResult, filter.accept(keys.getSecond(), value));
}
}
}
Aggregations