use of uk.gov.gchq.gaffer.operation.impl.get.GetElements 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.operation.impl.get.GetElements in project Gaffer by gchq.
the class VisibilityIT method shouldAccessMissingVisibilityGroups.
@Test
@TraitRequirement(StoreTrait.VISIBILITY)
public void shouldAccessMissingVisibilityGroups() throws OperationException {
final Set<Element> elements = new HashSet<>();
final Entity entity1 = new Entity(TestGroups.ENTITY, "A");
// Do NOT add an explicit visibility property
// entity1.putProperty(AccumuloPropertyNames.VISIBILITY, "");
elements.add(entity1);
final AddElements addElements = new AddElements.Builder().input(elements).build();
graph.execute(addElements, getUser());
final GetElements get = new GetElements.Builder().input(new EntitySeed("A")).build();
final CloseableIterable<? extends Element> iterable = graph.execute(get, getUser());
final List<Element> results = Lists.newArrayList(iterable);
// Check for all entities which should be visible
assertThat(results).withFailMessage("Results do not contain all expected entities.").hasSize(1);
for (final Element e : results) {
// Check that all visible entities contain the visibility property
assertThat(e.getProperties()).as("Visibility property should be visible.").containsKey(TestTypes.VISIBILITY);
assertThat(e.getProperties().get(TestTypes.VISIBILITY).toString()).withFailMessage("Visibility property should contain an empty String.").isEmpty();
}
iterable.close();
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.
the class VisibilityIT method shouldAccessMultipleVisibilityGroups_or.
@Test
@TraitRequirement(StoreTrait.VISIBILITY)
public void shouldAccessMultipleVisibilityGroups_or() throws OperationException {
final Set<Element> elements = new HashSet<>();
final Entity entity1 = new Entity(TestGroups.ENTITY, "B");
entity1.putProperty(TestTypes.VISIBILITY, "vis1|vis2");
elements.add(entity1);
final AddElements addElements = new AddElements.Builder().input(elements).build();
graph.execute(addElements, new User());
final GetElements get = new GetElements.Builder().input(new EntitySeed("B")).build();
final CloseableIterable<? extends Element> iterable = graph.execute(get, new User(User.UNKNOWN_USER_ID, Sets.newHashSet("vis1")));
final List<Element> results = Lists.newArrayList(iterable);
assertThat(results).withFailMessage("Results do not contain all expected entities.").hasSize(1);
for (final Element e : results) {
assertThat(e.getProperties()).containsKey(TestTypes.VISIBILITY);
}
iterable.close();
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.
the class VisibilityIT method shouldAccessMissingVisibilityGroupsWithNoVisibilityPropertyInSchema.
@Test
@TraitRequirement(StoreTrait.VISIBILITY)
public void shouldAccessMissingVisibilityGroupsWithNoVisibilityPropertyInSchema() throws OperationException {
graph = createGraphWithNoVisibility();
final Set<Element> elements = new HashSet<>();
final Entity entity1 = new Entity(TestGroups.ENTITY, "A");
elements.add(entity1);
final AddElements addElements = new AddElements.Builder().input(elements).build();
graph.execute(addElements, getUser());
final GetElements get = new GetElements.Builder().input(new EntitySeed("A")).build();
final CloseableIterable<? extends Element> iterable = graph.execute(get, getUser());
final List<Element> results = Lists.newArrayList(iterable);
// Check for all entities which should be visible
assertThat(results).withFailMessage("Results do not contain all expected entities.").hasSize(1);
for (final Element e : results) {
// Check that all visible entities do not contain the visibility property
assertThat(e.getProperties()).as("Visibility property should not be visible.").doesNotContainKey(TestTypes.VISIBILITY);
}
iterable.close();
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.
the class VisibilityIT method shouldAccessNullVisibilityGroups.
@Test
@TraitRequirement(StoreTrait.VISIBILITY)
public void shouldAccessNullVisibilityGroups() throws OperationException {
final Set<Element> elements = new HashSet<>();
final Entity entity1 = new Entity(TestGroups.ENTITY, "A");
entity1.putProperty(TestTypes.VISIBILITY, null);
elements.add(entity1);
final AddElements addElements = new AddElements.Builder().input(elements).build();
graph.execute(addElements, getUser());
final GetElements get = new GetElements.Builder().input(new EntitySeed("A"), new EntitySeed("B")).build();
final CloseableIterable<? extends Element> iterable = graph.execute(get, getUser());
final List<Element> results = Lists.newArrayList(iterable);
// Check for all entities which should be visible
assertThat(results).withFailMessage("Results do not contain all expected entities.").hasSize(1);
for (final Element e : results) {
// Check that all visible entities contain the visibility property
assertThat(e.getProperties()).as("Visibility property should be visible.").containsKey(TestTypes.VISIBILITY);
assertThat(e.getProperties().get(TestTypes.VISIBILITY).toString()).withFailMessage("Visibility property should contain an empty String.").isEmpty();
}
iterable.close();
}
Aggregations