Search in sources :

Example 36 with ElementId

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

the class AbstractExamplesFactory method getElements.

public GetElements getElements() {
    final GetElements op = new GetElements();
    final List<ElementId> seeds = new ArrayList<>();
    if (hasEntities()) {
        seeds.add(getEntityId(1));
    } else if (hasEdges()) {
        seeds.add(new EntitySeed(getEdgeId(1, 2).getSource()));
    }
    if (hasEdges()) {
        seeds.add(getEdgeId(1, 2));
    }
    op.setInput(seeds);
    populateOperation(op);
    return op;
}
Also used : ArrayList(java.util.ArrayList) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId)

Example 37 with ElementId

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

the class OperationUtilTest method shouldConvertFromElementIds.

@Test
public void shouldConvertFromElementIds() {
    // Given
    final Iterable<ElementId> input = Arrays.asList(new EntitySeed(1), new EntitySeed("2"), new EntitySeed("3"), new Entity("group", "4"), new EdgeSeed("5", 6), new Edge("group", 7L, 8, true), null);
    // When
    final Iterable<?> output = OperationUtil.fromElementIds(input);
    // Then
    final ArrayList<Serializable> expected = Lists.newArrayList(1, "2", "3", "4", new EdgeSeed("5", 6), new Edge("group", 7L, 8, true), null);
    assertEquals(expected, Lists.newArrayList(output));
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Serializable(java.io.Serializable) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) Test(org.junit.jupiter.api.Test)

Example 38 with ElementId

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

the class OperationUtilTest method shouldConvertIterableToElementIds.

@Test
public void shouldConvertIterableToElementIds() {
    // Given
    final Iterable<Object> input = Arrays.asList(1, "2", new EntitySeed("3"), new Entity("group", "4"), new EdgeSeed("5", 6), new Edge("group", 7L, 8, true), null);
    // When
    final Iterable<? extends ElementId> output = OperationUtil.toElementIds(input);
    // Then
    final ArrayList<ElementId> expected = Lists.newArrayList(new EntitySeed(1), new EntitySeed("2"), new EntitySeed("3"), new Entity("group", "4"), new EdgeSeed("5", 6), new Edge("group", 7L, 8, true), null);
    assertEquals(expected, Lists.newArrayList(output));
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) Test(org.junit.jupiter.api.Test)

Example 39 with ElementId

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

the class OperationUtilTest method shouldConvertFromEntityIds.

@Test
public void shouldConvertFromEntityIds() {
    // Given
    final Iterable<ElementId> input = Arrays.asList(new EntitySeed(1), new EntitySeed("2"), new EntitySeed("3"), new Entity("group", "4"), null);
    // When
    final Iterable<?> output = OperationUtil.fromElementIds(input);
    // Then
    final ArrayList<? extends Serializable> expected = Lists.newArrayList(1, "2", "3", "4", null);
    assertEquals(expected, Lists.newArrayList(output));
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) Test(org.junit.jupiter.api.Test)

Example 40 with ElementId

use of uk.gov.gchq.gaffer.data.element.id.ElementId 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)

Aggregations

ElementId (uk.gov.gchq.gaffer.data.element.id.ElementId)58 Test (org.junit.jupiter.api.Test)32 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)29 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)19 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)19 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)17 Edge (uk.gov.gchq.gaffer.data.element.Edge)14 Element (uk.gov.gchq.gaffer.data.element.Element)14 EdgeId (uk.gov.gchq.gaffer.data.element.id.EdgeId)14 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)14 HashSet (java.util.HashSet)11 Entity (uk.gov.gchq.gaffer.data.element.Entity)9 User (uk.gov.gchq.gaffer.user.User)9 ArrayList (java.util.ArrayList)7 IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)7 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)7 Test (org.junit.Test)6 JSONSerialisationTest (uk.gov.gchq.gaffer.JSONSerialisationTest)6 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)5 Key (org.apache.accumulo.core.data.Key)4