Search in sources :

Example 1 with Edge

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));
}
Also used : HashMap(java.util.HashMap) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 2 with Edge

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));
}
Also used : Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 3 with Edge

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());
}
Also used : EdgeSeedExtractor(uk.gov.gchq.gaffer.operation.data.generator.EdgeSeedExtractor) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.Test)

Example 4 with Edge

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());
}
Also used : EntitySeedExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntitySeedExtractor) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.Test)

Example 5 with Edge

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);
    }
}
Also used : EntitySeedExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntitySeedExtractor) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.Test)

Aggregations

Edge (uk.gov.gchq.gaffer.data.element.Edge)362 Element (uk.gov.gchq.gaffer.data.element.Element)183 Test (org.junit.jupiter.api.Test)175 Entity (uk.gov.gchq.gaffer.data.element.Entity)142 ArrayList (java.util.ArrayList)100 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)89 User (uk.gov.gchq.gaffer.user.User)86 HashSet (java.util.HashSet)75 Graph (uk.gov.gchq.gaffer.graph.Graph)75 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)74 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)73 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)56 List (java.util.List)51 Key (org.apache.accumulo.core.data.Key)48 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)47 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)47 Test (org.junit.Test)45 OperationException (uk.gov.gchq.gaffer.operation.OperationException)42 IsMoreThan (uk.gov.gchq.koryphe.impl.predicate.IsMoreThan)40 TestGroups (uk.gov.gchq.gaffer.commonutil.TestGroups)38