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;
}
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));
}
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));
}
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));
}
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);
}
Aggregations