use of org.apache.accumulo.core.data.Value in project Gaffer by gchq.
the class ClassicEdgeDirectedUndirectedFilterIteratorTest method shouldOnlyAcceptUndirectedEdges.
@Test
public void shouldOnlyAcceptUndirectedEdges() throws OperationException, AccumuloElementConversionException {
// Given
final ClassicEdgeDirectedUndirectedFilterIterator filter = new ClassicEdgeDirectedUndirectedFilterIterator();
final Map<String, String> options = new HashMap<String, String>() {
{
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 boolean expectedResult = !edge.isDirected();
final Pair<Key> keys = converter.getKeysFromEdge(edge);
assertEquals("Failed for edge: " + edge.toString(), expectedResult, filter.accept(keys.getFirst(), value));
if (null != keys.getSecond()) {
// self edges are not added the other way round
assertEquals("Failed for edge: " + edge.toString(), expectedResult, filter.accept(keys.getSecond(), value));
}
}
}
use of org.apache.accumulo.core.data.Value in project Gaffer by gchq.
the class ClassicEdgeDirectedUndirectedFilterIteratorTest method shouldOnlyAcceptIncomingEdges.
@Test
public void shouldOnlyAcceptIncomingEdges() throws OperationException, AccumuloElementConversionException {
// Given
final ClassicEdgeDirectedUndirectedFilterIterator filter = new ClassicEdgeDirectedUndirectedFilterIterator();
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 Edge edge : EDGES) {
final Pair<Key> keys = converter.getKeysFromEdge(edge);
assertEquals("Failed for edge: " + edge.toString(), false, filter.accept(keys.getFirst(), value));
if (null != keys.getSecond()) {
// self edges are not added the other way round
final boolean expectedResult = edge.isDirected();
assertEquals("Failed for edge: " + edge.toString(), expectedResult, filter.accept(keys.getSecond(), value));
}
}
}
use of org.apache.accumulo.core.data.Value in project Gaffer by gchq.
the class ClassicEdgeDirectedUndirectedFilterIteratorTest method shouldOnlyAcceptDeduplicatedEdges.
@Test
public void shouldOnlyAcceptDeduplicatedEdges() throws OperationException, AccumuloElementConversionException {
// Given
final ClassicEdgeDirectedUndirectedFilterIterator filter = new ClassicEdgeDirectedUndirectedFilterIterator();
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 Edge edge : EDGES) {
final Pair<Key> keys = converter.getKeysFromEdge(edge);
// First key is deduplicated
assertTrue("Failed for edge: " + edge.toString(), 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.Value in project Gaffer by gchq.
the class ClassicEdgeDirectedUndirectedFilterIteratorTest method shouldOnlyAcceptDeduplicatedDirectedEdges.
@Test
public void shouldOnlyAcceptDeduplicatedDirectedEdges() throws OperationException, AccumuloElementConversionException {
// Given
final ClassicEdgeDirectedUndirectedFilterIterator filter = new ClassicEdgeDirectedUndirectedFilterIterator();
final Map<String, String> options = new HashMap<String, String>() {
{
put(AccumuloStoreConstants.OUTGOING_EDGE_ONLY, "true");
put(AccumuloStoreConstants.DIRECTED_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.Value 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));
}
}
}
Aggregations