use of uk.gov.gchq.gaffer.spark.data.generator.RowToElementGenerator in project Gaffer by gchq.
the class GetGraphFrameOfElementsHandlerTest method shouldGetCorrectElementsInGraphFrameWithRepeatedElements.
@Test
public void shouldGetCorrectElementsInGraphFrameWithRepeatedElements() throws OperationException {
// Given
final Graph graph = getGraph("/schema-GraphFrame/elements.json", getSimpleElements());
graph.execute(new AddElements.Builder().input(getSimpleElements()).build(), new User());
final GetGraphFrameOfElements gfOperation = new GetGraphFrameOfElements.Builder().view(new View.Builder().edge(TestGroups.EDGE).edge(TestGroups.EDGE_2).entity(TestGroups.ENTITY).entity(TestGroups.ENTITY_2).build()).build();
final OperationChain<Iterable<? extends Element>> opChain = new OperationChain.Builder().first(gfOperation).then(new Map.Builder<>().first(new GraphFrameToIterableRow()).then(new RowToElementGenerator()).build()).build();
// When
final Iterable<? extends Element> results = graph.execute(opChain, new User());
// Then
assertElementEquals(getSimpleElements(), results);
}
use of uk.gov.gchq.gaffer.spark.data.generator.RowToElementGenerator in project Gaffer by gchq.
the class GetGraphFrameOfElementsHandlerTest method shouldGetCorrectElementsInGraphFrameWithLoops.
@Test
public void shouldGetCorrectElementsInGraphFrameWithLoops() throws OperationException {
// Given
final Graph graph = getGraph("/schema-GraphFrame/elementsComplex.json", getElements());
final Edge edge1 = new Edge.Builder().group(TestGroups.EDGE).source("B").dest("1").directed(true).property("columnQualifier", 1).property("property1", 2).property("property2", 3.0F).property("property3", 4.0D).property("property4", 5L).property("count", 100L).build();
final Edge edge2 = new Edge.Builder().group(TestGroups.EDGE).source("C").dest("1").directed(true).property("columnQualifier", 6).property("property1", 7).property("property2", 8.0F).property("property3", 9.0D).property("property4", 10L).property("count", 200L).build();
graph.execute(new AddElements.Builder().input(edge1, edge2).build(), new User());
final GetGraphFrameOfElements gfOperation = new GetGraphFrameOfElements.Builder().view(new View.Builder().edge(TestGroups.EDGE).edge(TestGroups.EDGE_2).entity(TestGroups.ENTITY).entity(TestGroups.ENTITY_2).build()).build();
final OperationChain<Iterable<? extends Element>> opChain = new OperationChain.Builder().first(gfOperation).then(new Map.Builder<>().first(new GraphFrameToIterableRow()).then(new RowToElementGenerator()).build()).build();
// When
final Iterable<? extends Element> results = graph.execute(opChain, new User());
// Then
final List<Element> expected = getElements();
expected.add(edge1);
expected.add(edge2);
assertElementEquals(expected, results);
}
use of uk.gov.gchq.gaffer.spark.data.generator.RowToElementGenerator in project Gaffer by gchq.
the class GetGraphFrameOfElementsHandlerTest method shouldGetCorrectElementsInGraphFrameWithVertexProperty.
@Test
public void shouldGetCorrectElementsInGraphFrameWithVertexProperty() throws OperationException {
// Given
final List<Element> elements = getSimpleElements();
for (final Element element : elements) {
element.putProperty("vertex", "value");
}
final Graph graph = getGraph("/schema-GraphFrame/elementsWithVertexProperty.json", elements);
final GetGraphFrameOfElements gfOperation = new GetGraphFrameOfElements.Builder().view(new View.Builder().edge(TestGroups.EDGE).edge(TestGroups.EDGE_2).entity(TestGroups.ENTITY).entity(TestGroups.ENTITY_2).build()).build();
final OperationChain<Iterable<? extends Element>> opChain = new OperationChain.Builder().first(gfOperation).then(new Map.Builder<>().first(new GraphFrameToIterableRow()).then(new RowToElementGenerator()).build()).build();
// When
final Iterable<? extends Element> results = graph.execute(opChain, new User());
// Then
assertElementEquals(getSimpleElements(), results);
}
use of uk.gov.gchq.gaffer.spark.data.generator.RowToElementGenerator in project Gaffer by gchq.
the class GetGraphFrameOfElementsHandlerTest method shouldBehaviourInGraphFrameWithNoEntities.
@Test
public void shouldBehaviourInGraphFrameWithNoEntities() throws OperationException {
// Given
final Graph graph = getGraph("/schema-GraphFrame/elements.json", getSimpleElements());
final GetGraphFrameOfElements gfOperation = new GetGraphFrameOfElements.Builder().view(new View.Builder().edge(TestGroups.EDGE).edge(TestGroups.EDGE_2).build()).build();
final OperationChain<Iterable<? extends Element>> opChain = new OperationChain.Builder().first(gfOperation).then(new Map.Builder<>().first(new GraphFrameToIterableRow()).then(new RowToElementGenerator()).build()).build();
// When
final Iterable<? extends Element> results = graph.execute(opChain, new User());
// Then
assertElementEquals(getSimpleElements().stream().filter(e -> e instanceof Edge).collect(Collectors.toList()), results);
}
use of uk.gov.gchq.gaffer.spark.data.generator.RowToElementGenerator in project Gaffer by gchq.
the class GetGraphFrameOfElementsHandlerTest method shouldGetCorrectElementsInGraphFrame.
@Test
public void shouldGetCorrectElementsInGraphFrame() throws OperationException {
// Given
final Graph graph = getGraph("/schema-GraphFrame/elements.json", getSimpleElements());
final GetGraphFrameOfElements gfOperation = new GetGraphFrameOfElements.Builder().view(new View.Builder().edge(TestGroups.EDGE).edge(TestGroups.EDGE_2).entity(TestGroups.ENTITY).entity(TestGroups.ENTITY_2).build()).build();
final OperationChain<Iterable<? extends Element>> opChain = new OperationChain.Builder().first(gfOperation).then(new Map.Builder<>().first(new GraphFrameToIterableRow()).then(new RowToElementGenerator()).build()).build();
// When
final Iterable<? extends Element> results = graph.execute(opChain, new User());
// Then
assertElementEquals(getSimpleElements(), results);
}
Aggregations