use of uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder in project Gaffer by gchq.
the class AbstractLoaderIT method shouldGetElementsWithMatchedVertex.
@TraitRequirement({ StoreTrait.MATCHED_VERTEX, StoreTrait.QUERY_AGGREGATION })
@Test
public void shouldGetElementsWithMatchedVertex() throws Exception {
// Then
final View view = new Builder().edge(TestGroups.EDGE).build();
final GetElements op = new GetElements.Builder().input(new EntitySeed(SOURCE_DIR_1), new EntitySeed(DEST_DIR_2), new EntitySeed(SOURCE_DIR_3)).view(view).build();
final CloseableIterable<? extends Element> results = graph.execute(op, getUser());
assertElementEquals(getQuerySummarisedEdges(view).stream().filter(Edge::isDirected).filter(edge -> {
final List<String> vertices = Lists.newArrayList(SOURCE_DIR_1, SOURCE_DIR_2, SOURCE_DIR_3);
return vertices.contains(edge.getMatchedVertexValue());
}).collect(toList()), results);
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder in project Gaffer by gchq.
the class AbstractLoaderIT method shouldGetElementsWithMatchedVertexFilter.
@TraitRequirement({ StoreTrait.MATCHED_VERTEX, StoreTrait.QUERY_AGGREGATION })
@Test
public void shouldGetElementsWithMatchedVertexFilter() throws Exception {
// Then
final View view = new Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(IdentifierType.ADJACENT_MATCHED_VERTEX.name()).execute(new IsIn(DEST_DIR_1, DEST_DIR_2, DEST_DIR_3)).build()).build()).build();
final GetElements op = new GetElements.Builder().input(new EntitySeed(SOURCE_DIR_1), new EntitySeed(DEST_DIR_2), new EntitySeed(SOURCE_DIR_3)).view(view).build();
// When
final CloseableIterable<? extends Element> results = graph.execute(op, getUser());
// Then
assertElementEquals(getQuerySummarisedEdges(view).stream().filter(Edge::isDirected).filter(edge -> {
final List<String> vertices = Lists.newArrayList(SOURCE_DIR_1, DEST_DIR_2, SOURCE_DIR_3);
return vertices.contains(edge.getMatchedVertexValue());
}).filter(edge -> {
final List<String> vertices = Lists.newArrayList(DEST_DIR_1, DEST_DIR_2, DEST_DIR_3);
return vertices.contains(edge.getAdjacentMatchedVertexValue());
}).collect(toList()), results);
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder in project Gaffer by gchq.
the class AbstractStoreIT method getQuerySummarisedEntities.
public List<Entity> getQuerySummarisedEntities() {
final Schema schema = null != graph ? graph.getSchema() : getStoreSchema();
final View view = new Builder().entities(schema.getEntityGroups()).edges(schema.getEdgeGroups()).build();
return getQuerySummarisedEntities(view);
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder in project Gaffer by gchq.
the class AbstractStoreIT method getQuerySummarisedEdges.
public List<Edge> getQuerySummarisedEdges() {
final Schema schema = null != graph ? graph.getSchema() : getStoreSchema();
final View view = new Builder().entities(schema.getEntityGroups()).edges(schema.getEdgeGroups()).build();
return getQuerySummarisedEdges(view);
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder in project Gaffer by gchq.
the class AbstractLoaderIT method shouldGetAllElementsWithExcludedProperties.
@Test
@TraitRequirement(StoreTrait.QUERY_AGGREGATION)
public void shouldGetAllElementsWithExcludedProperties() throws Exception {
// Given
final View view = new Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().excludeProperties(TestPropertyNames.COUNT).build()).build();
final GetAllElements op = new GetAllElements.Builder().view(view).build();
final CloseableIterable<? extends Element> results = graph.execute(op, getUser());
// When
final List<Element> expected = getQuerySummarisedEdges(view).stream().map(edge -> {
edge.getProperties().remove(TestPropertyNames.COUNT);
return edge;
}).collect(toList());
// Then
assertElementEquals(expected, results);
}
Aggregations