use of uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityRangeElementPropertyFilterIterator in project Gaffer by gchq.
the class ByteEntityRangeElementPropertyFilterIteratorTest method shouldOnlyAcceptUndirectedEdges.
@Test
public void shouldOnlyAcceptUndirectedEdges() throws OperationException, AccumuloElementConversionException {
// Given
final ByteEntityRangeElementPropertyFilterIterator filter = new ByteEntityRangeElementPropertyFilterIterator();
final Map<String, String> options = new HashMap<String, String>() {
{
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 boolean expectedResult = element instanceof Edge && !((Edge) element).isDirected();
final Pair<Key> keys = converter.getKeysFromElement(element);
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(), 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 shouldOnlyAcceptDirectedEdges.
@Test
public void shouldOnlyAcceptDirectedEdges() throws OperationException, AccumuloElementConversionException {
// Given
final ByteEntityRangeElementPropertyFilterIterator filter = new ByteEntityRangeElementPropertyFilterIterator();
final Map<String, String> options = new HashMap<String, String>() {
{
put(AccumuloStoreConstants.DIRECTED_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 Edge && ((Edge) element).isDirected();
final Pair<Key> keys = converter.getKeysFromElement(element);
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(), 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 shouldOnlyAcceptOutgoingEdges.
@Test
public void shouldOnlyAcceptOutgoingEdges() 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.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);
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 shouldOnlyAcceptDeduplicatedEdges.
@Test
public void shouldOnlyAcceptDeduplicatedEdges() throws OperationException, AccumuloElementConversionException {
// Given
final ByteEntityRangeElementPropertyFilterIterator filter = new ByteEntityRangeElementPropertyFilterIterator();
final Map<String, String> options = new HashMap<String, String>() {
{
put(AccumuloStoreConstants.OUTGOING_EDGE_ONLY, "true");
put(AccumuloStoreConstants.DEDUPLICATE_UNDIRECTED_EDGES, "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 edges should be excepted
assertEquals("Failed for element: " + element.toString(), element instanceof Edge, 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 shouldOnlyAcceptDeduplicatedDirectedEdges.
@Test
public void shouldOnlyAcceptDeduplicatedDirectedEdges() 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.DIRECTED_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 directed 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));
}
}
}
Aggregations