use of uk.gov.gchq.gaffer.data.element.Edge in project Gaffer by gchq.
the class AbstractAccumuloElementConverterTest method shouldGetFlippedEdgeWithMatchAsSourceFalse.
@Test
public void shouldGetFlippedEdgeWithMatchAsSourceFalse() throws SchemaException, AccumuloElementConversionException, IOException {
// Given
final Edge edge = new Edge(TestGroups.EDGE);
edge.setDestination("2");
edge.setSource("1");
edge.setDirected(true);
edge.putProperty(AccumuloPropertyNames.COLUMN_QUALIFIER, 100);
final Pair<Key> keys = converter.getKeysFromElement(edge);
final Map<String, String> options = new HashMap<>();
options.put(AccumuloStoreConstants.OPERATION_RETURN_MATCHED_SEEDS_AS_EDGE_SOURCE, "true");
// When
final Edge newEdge = (Edge) converter.getElementFromKey(keys.getSecond(), options);
// Then
assertEquals("2", newEdge.getSource());
assertEquals("1", newEdge.getDestination());
assertEquals(true, newEdge.isDirected());
assertEquals(100, newEdge.getProperty(AccumuloPropertyNames.COLUMN_QUALIFIER));
}
use of uk.gov.gchq.gaffer.data.element.Edge in project Gaffer by gchq.
the class AbstractAccumuloElementConverterTest method shouldReturnAccumuloKeyConverterMultipleCQPropertydEdge.
@Test
public void shouldReturnAccumuloKeyConverterMultipleCQPropertydEdge() throws SchemaException, AccumuloElementConversionException, IOException {
// Given
final Edge edge = new Edge(TestGroups.EDGE);
edge.setDestination("2");
edge.setSource("1");
edge.setDirected(true);
edge.putProperty(AccumuloPropertyNames.COLUMN_QUALIFIER, 100);
// When
final Pair<Key> keys = converter.getKeysFromElement(edge);
final Edge newEdge = (Edge) converter.getElementFromKey(keys.getSecond());
// Then
assertEquals("1", newEdge.getSource());
assertEquals("2", newEdge.getDestination());
assertEquals(true, newEdge.isDirected());
assertEquals(100, newEdge.getProperty(AccumuloPropertyNames.COLUMN_QUALIFIER));
}
use of uk.gov.gchq.gaffer.data.element.Edge in project Gaffer by gchq.
the class EdgeSeedExtractorTest method shouldGetIdentifierFromEdge.
@Test
public void shouldGetIdentifierFromEdge() {
// Given
final EdgeSeedExtractor extractor = new EdgeSeedExtractor();
final Edge edge = new Edge(TestGroups.EDGE, "source", "destination", true);
// When
final EdgeSeed seed = extractor.getObject(edge);
// Then
assertEquals("source", seed.getSource());
assertEquals("destination", seed.getDestination());
assertTrue(seed.isDirected());
}
use of uk.gov.gchq.gaffer.data.element.Edge in project Gaffer by gchq.
the class EntitySeedExtractorTest method shouldGetDestinationFromEdge.
@Test
public void shouldGetDestinationFromEdge() {
// Given
final EntitySeedExtractor extractor = new EntitySeedExtractor(IdentifierType.DESTINATION);
final Edge edge = new Edge(TestGroups.EDGE, "source", "destination", false);
// When
final EntitySeed seed = extractor.getObject(edge);
// Then
assertEquals("destination", seed.getVertex());
}
use of uk.gov.gchq.gaffer.data.element.Edge in project Gaffer by gchq.
the class EntitySeedExtractorTest method shouldThrowIllegalArgumentExceptionFromEdgeWhenIdTypeIsDirected.
@Test
public void shouldThrowIllegalArgumentExceptionFromEdgeWhenIdTypeIsDirected() {
// Given
final EntitySeedExtractor extractor = new EntitySeedExtractor(IdentifierType.DIRECTED);
final Edge edge = new Edge(TestGroups.EDGE, "source", "destination", false);
// When / Then
try {
extractor.getObject(edge);
fail("Exception expected");
} catch (final IllegalArgumentException e) {
assertNotNull(e);
}
}
Aggregations