Search in sources :

Example 11 with EdgeId

use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.

the class EdgeSeedTest method shouldBeRelatedToEntityIdWhenSourceAndVertexAreNull.

@Test
public void shouldBeRelatedToEntityIdWhenSourceAndVertexAreNull() {
    // Given
    final String source = null;
    final String destination = "destination";
    final boolean directed = true;
    final EdgeId seed = new EdgeSeed(source, destination, directed);
    final EntityId relatedSeed = mock(EntityId.class);
    given(relatedSeed.getVertex()).willReturn(source);
    // When
    final boolean isRelated = seed.isRelated((ElementId) relatedSeed).isMatch();
    // Then
    assertTrue(isRelated);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 12 with EdgeId

use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.

the class EdgeSeedTest method shouldBeEqualWhenSourceDestinationAndDirectedEqual.

@Test
public void shouldBeEqualWhenSourceDestinationAndDirectedEqual() {
    // Given
    final String source = "source";
    final String destination = "destination";
    final boolean directed = true;
    final EdgeId seed1 = new EdgeSeed(source, destination, directed);
    final EdgeId seed2 = new EdgeSeed(source, destination, directed);
    // When
    final boolean isEqual = seed1.equals(seed2);
    // Then
    assertTrue(isEqual);
    assertEquals(seed1.hashCode(), seed2.hashCode());
}
Also used : EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 13 with EdgeId

use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.

the class EdgeIdExtractorTest method shouldGetIdentifierFromEdge.

@Test
public void shouldGetIdentifierFromEdge() {
    // Given
    final EdgeIdExtractor extractor = new EdgeIdExtractor();
    final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source("source").dest("destination").directed(true).build();
    // When
    final EdgeId seed = extractor._apply(edge);
    // Then
    assertEquals("source", seed.getSource());
    assertEquals("destination", seed.getDestination());
    assertTrue(seed.isDirected());
}
Also used : EdgeIdExtractor(uk.gov.gchq.gaffer.operation.data.generator.EdgeIdExtractor) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.jupiter.api.Test)

Example 14 with EdgeId

use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.

the class BasicSchemaLoader method createEdges.

@Override
public Map<EdgeId, Edge> createEdges() {
    final Map<EdgeId, Edge> edges = new HashMap<>();
    for (int i = 0; i <= 10; i++) {
        for (int j = 0; j < VERTEX_PREFIXES.length; j++) {
            final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(VERTEX_PREFIXES[0] + i).dest(VERTEX_PREFIXES[j] + i).directed(false).property(TestPropertyNames.COUNT, 1L).build();
            addToMap(edge, edges);
            final Edge edgeDir = new Edge.Builder().group(TestGroups.EDGE).source(VERTEX_PREFIXES[0] + i).dest(VERTEX_PREFIXES[j] + i).directed(true).property(TestPropertyNames.COUNT, 1L).build();
            addToMap(edgeDir, edges);
        }
        final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(SOURCE + i).dest(DEST + i).directed(false).property(TestPropertyNames.COUNT, 1L).build();
        addToMap(edge, edges);
        final Edge edgeDir = new Edge.Builder().group(TestGroups.EDGE).source(SOURCE_DIR + i).dest(DEST_DIR + i).directed(true).property(TestPropertyNames.COUNT, 1L).build();
        addToMap(edgeDir, edges);
    }
    return edges;
}
Also used : HashMap(java.util.HashMap) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) Edge(uk.gov.gchq.gaffer.data.element.Edge)

Example 15 with EdgeId

use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.

the class AggregationSchemaLoader method createEdges.

@Override
public Map<EdgeId, Edge> createEdges() {
    final Map<EdgeId, Edge> edges = new HashMap<>();
    for (int i = 0; i <= 10; i++) {
        for (int j = 0; j < VERTEX_PREFIXES.length; j++) {
            final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(VERTEX_PREFIXES[0] + i).dest(VERTEX_PREFIXES[j] + i).directed(false).property(TestPropertyNames.COUNT, 1L).property(TestPropertyNames.PROP_1, 1).property(TestPropertyNames.PROP_2, 1L).property(TestPropertyNames.PROP_3, "1").property(TestPropertyNames.VISIBILITY, "public").build();
            addToMap(edge, edges);
            final Edge edgeDir = new Edge.Builder().group(TestGroups.EDGE).source(VERTEX_PREFIXES[0] + i).dest(VERTEX_PREFIXES[j] + i).directed(true).property(TestPropertyNames.COUNT, 1L).property(TestPropertyNames.PROP_1, 1).property(TestPropertyNames.PROP_2, 1L).property(TestPropertyNames.PROP_3, "1").property(TestPropertyNames.VISIBILITY, "private").build();
            addToMap(edgeDir, edges);
        }
        final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(SOURCE + i).dest(DEST + i).directed(false).property(TestPropertyNames.COUNT, 1L).property(TestPropertyNames.PROP_1, 1).property(TestPropertyNames.PROP_2, 1L).property(TestPropertyNames.PROP_3, "1").property(TestPropertyNames.VISIBILITY, "public").build();
        addToMap(edge, edges);
        final Edge edgeDir = new Edge.Builder().group(TestGroups.EDGE).source(SOURCE_DIR + i).dest(DEST_DIR + i).directed(true).property(TestPropertyNames.COUNT, 1L).property(TestPropertyNames.PROP_1, 1).property(TestPropertyNames.PROP_2, 1L).property(TestPropertyNames.PROP_3, "1").property(TestPropertyNames.VISIBILITY, "private").build();
        addToMap(edgeDir, edges);
    }
    return edges;
}
Also used : HashMap(java.util.HashMap) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) Edge(uk.gov.gchq.gaffer.data.element.Edge)

Aggregations

EdgeId (uk.gov.gchq.gaffer.data.element.id.EdgeId)40 Test (org.junit.jupiter.api.Test)27 JSONSerialisationTest (uk.gov.gchq.gaffer.JSONSerialisationTest)18 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)15 Edge (uk.gov.gchq.gaffer.data.element.Edge)14 ElementId (uk.gov.gchq.gaffer.data.element.id.ElementId)14 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)8 HashMap (java.util.HashMap)5 Key (org.apache.accumulo.core.data.Key)4 FreqMap (uk.gov.gchq.gaffer.types.FreqMap)4 ArrayList (java.util.ArrayList)3 DirectedType (uk.gov.gchq.gaffer.data.element.id.DirectedType)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 HashSet (java.util.HashSet)2 Element (uk.gov.gchq.gaffer.data.element.Element)2 Entity (uk.gov.gchq.gaffer.data.element.Entity)2 SeedMatching (uk.gov.gchq.gaffer.operation.SeedMatching)2 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)2 Schema (uk.gov.gchq.gaffer.store.schema.Schema)2 Collection (java.util.Collection)1