Search in sources :

Example 21 with EdgeId

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

the class GetElementsIT method getElements.

private static Collection<Element> getElements(final Collection<ElementId> seeds, final Boolean direction) {
    final Set<Element> elements = new HashSet<>(seeds.size());
    for (final ElementId seed : seeds) {
        if (seed instanceof EntityId) {
            final Entity entity = new Entity(TestGroups.ENTITY, ((EntityId) seed).getVertex());
            entity.putProperty(TestPropertyNames.COUNT, 1L);
            entity.putProperty(TestPropertyNames.SET, CollectionUtil.treeSet("3"));
            elements.add(entity);
        } else {
            if (DirectedType.isEither(((EdgeId) seed).getDirectedType())) {
                if (BooleanUtils.isNotTrue(direction)) {
                    final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(((EdgeId) seed).getSource()).dest(((EdgeId) seed).getDestination()).matchedVertex(((EdgeId) seed).getMatchedVertex()).directed(false).property(TestPropertyNames.INT, 1).property(TestPropertyNames.COUNT, 1L).build();
                    elements.add(edge);
                }
                if (BooleanUtils.isNotFalse(direction)) {
                    final Edge edgeDir = new Edge.Builder().group(TestGroups.EDGE).source(((EdgeId) seed).getSource()).dest(((EdgeId) seed).getDestination()).matchedVertex(((EdgeId) seed).getMatchedVertex()).directed(true).property(TestPropertyNames.INT, 1).property(TestPropertyNames.COUNT, 1L).build();
                    elements.add(edgeDir);
                }
            } else {
                final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(((EdgeId) seed).getSource()).dest(((EdgeId) seed).getDestination()).directed(((EdgeId) seed).isDirected()).matchedVertex(((EdgeId) seed).getMatchedVertex()).property(TestPropertyNames.INT, 1).property(TestPropertyNames.COUNT, 1L).build();
                elements.add(edge);
            }
        }
    }
    return elements;
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) Entity(uk.gov.gchq.gaffer.data.element.Entity) Element(uk.gov.gchq.gaffer.data.element.Element) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) Edge(uk.gov.gchq.gaffer.data.element.Edge) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) HashSet(java.util.HashSet)

Example 22 with EdgeId

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

the class ExportIT method createEdges.

/**
 * Adds edges dest[X] -> source[X+1]
 *
 * @return map of edges
 */
@Override
protected Map<EdgeId, Edge> createEdges() {
    final Map<EdgeId, Edge> edges = super.createEdges();
    for (int i = 0; i <= 10; i++) {
        final Edge thirdEdge = new Edge.Builder().group(TestGroups.EDGE).source(DEST_DIR + i).dest(SOURCE_DIR + (i + 1)).directed(true).build();
        thirdEdge.putProperty(TestPropertyNames.INT, 1);
        thirdEdge.putProperty(TestPropertyNames.COUNT, 1L);
        addToMap(thirdEdge, edges);
    }
    return edges;
}
Also used : EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) Edge(uk.gov.gchq.gaffer.data.element.Edge)

Example 23 with EdgeId

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

the class ElementIdSerialiserTest method testCanSerialiseEdgeId.

@Test
public void testCanSerialiseEdgeId() throws SerialisationException {
    // Given
    final EdgeId edgeId = new EdgeSeed("source", "destination", true);
    // When
    final byte[] serialisedEdgeId = serialiser.serialise(edgeId);
    final ElementId deserialisedEdgeId = serialiser.deserialise(serialisedEdgeId);
    // Then
    assertEquals(edgeId, deserialisedEdgeId);
}
Also used : EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) Test(org.junit.jupiter.api.Test)

Example 24 with EdgeId

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

the class EntitySeedTest method shouldBeRelatedToEdgeIdWhenSourceAndVertexAreNull.

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

Example 25 with EdgeId

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

the class EntitySeedTest method shouldBeRelatedToEdgeIdWhenDestinationAndVertexAreNull.

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

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