Search in sources :

Example 31 with EntitySeed

use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.

the class VisibilityIT method shouldAccessMissingVisibilityGroups.

@Test
@TraitRequirement(StoreTrait.VISIBILITY)
public void shouldAccessMissingVisibilityGroups() throws OperationException, JsonProcessingException {
    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().elements(elements).build();
    graph.execute(addElements, USER_DEFAULT);
    final GetElements<EntitySeed, Element> get = new GetElements.Builder<EntitySeed, Element>().addSeed(new EntitySeed("A")).build();
    final CloseableIterable<Element> iterable = graph.execute(get, USER_DEFAULT);
    final List<Element> results = Lists.newArrayList(iterable);
    // Check for all entities which should be visible
    assertThat("Results do not contain all expected entities.", results, hasSize(1));
    for (final Element e : results) {
        // Check that all visible entities contain the visibility property
        assertTrue("Visibility property should be visible.", e.getProperties().containsKey(TestTypes.VISIBILITY));
        assertThat("Visibility property should contain an empty String.", e.getProperties().get(TestTypes.VISIBILITY).toString(), isEmptyString());
    }
    iterable.close();
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Entity(uk.gov.gchq.gaffer.data.element.Entity) Element(uk.gov.gchq.gaffer.data.element.Element) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) HashSet(java.util.HashSet) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Example 32 with EntitySeed

use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.

the class ExportIT method shouldExportResultsInSet.

@Test
public void shouldExportResultsInSet() throws OperationException, IOException {
    // Given
    final OperationChain<CloseableIterable<?>> exportOpChain = new Builder().first(new GetEdges.Builder<>().addSeed(new EntitySeed(SOURCE_DIR_0)).build()).then(new ExportToSet()).then(new GenerateObjects.Builder<Edge, EntitySeed>().generator(new EntitySeedExtractor()).build()).then(new GetEdges<>()).then(new ExportToSet()).then(new GetSetExport()).build();
    // When
    final CloseableIterable<?> export = graph.execute(exportOpChain, getUser());
    // Then
    assertEquals(2, Lists.newArrayList(export).size());
}
Also used : ExportToSet(uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) GetSetExport(uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport) GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) EntitySeedExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntitySeedExtractor) GetEdges(uk.gov.gchq.gaffer.operation.impl.get.GetEdges) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.Test)

Example 33 with EntitySeed

use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.

the class FilteringIT method testFilteringProperties.

@Test
@TraitRequirement(StoreTrait.PRE_AGGREGATION_FILTERING)
public void testFilteringProperties() throws OperationException {
    // Given
    final List<ElementSeed> seeds = Arrays.asList(new EntitySeed("A3"), new EdgeSeed("A5", "B5", false));
    final GetElements<ElementSeed, Element> getElementsWithoutFiltering = new GetElements.Builder<>().seeds(seeds).build();
    final GetElements<ElementSeed, Element> getElementsWithFiltering = new GetElements.Builder<>().seeds(seeds).view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(IdentifierType.VERTEX.name()).execute(new IsEqual("A5")).build()).build()).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsLessThan(2)).build()).build()).build()).build();
    // When - without filtering
    final List<Element> resultsWithoutFiltering = Lists.newArrayList(graph.execute(getElementsWithoutFiltering, getUser()));
    // When - with filtering
    final List<Element> resultsWithFiltering = Lists.newArrayList(graph.execute(getElementsWithFiltering, getUser()));
    // Then - without filtering
    assertNotNull(resultsWithoutFiltering);
    assertEquals(8, resultsWithoutFiltering.size());
    assertThat(resultsWithoutFiltering, IsCollectionContaining.hasItems(getEdge("A3", "A3", false), getEdge("A3", "B3", false), getEdge("A3", "C3", false), getEdge("A3", "D3", false), getEdge("A5", "B5", false), getEntity("A5"), getEntity("B5")));
    // Then - with filtering
    assertNotNull(resultsWithFiltering);
    assertEquals(6, resultsWithFiltering.size());
    assertThat(resultsWithFiltering, IsCollectionContaining.hasItems(getEdge("A3", "A3", false), getEdge("A3", "B3", false), getEdge("A5", "B5", false), getEdge("A3", "D3", false), getEdge("A3", "C3", false), getEntity("A5")));
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) IsEqual(uk.gov.gchq.gaffer.function.filter.IsEqual) IsLessThan(uk.gov.gchq.gaffer.function.filter.IsLessThan) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Example 34 with EntitySeed

use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.

the class GeneratorsIT method shouldConvertFromDomainObjects.

@Test
public void shouldConvertFromDomainObjects() throws OperationException, UnsupportedEncodingException {
    // Given
    final OperationChain<Void> opChain = new OperationChain.Builder().first(new GenerateElements.Builder<DomainObject>().generator(new BasicGenerator()).objects(Arrays.asList(new EntityDomainObject(NEW_VERTEX, "1", null), new EdgeDomainObject(NEW_SOURCE, NEW_DEST, false, 1, 1L))).build()).then(new AddElements()).build();
    // When - add
    graph.execute(opChain, getUser());
    // Then - check they were added correctly
    final List<Element> results = Lists.newArrayList(graph.execute(new GetElements.Builder<>().addSeed(new EntitySeed(NEW_VERTEX)).addSeed(new EdgeSeed(NEW_SOURCE, NEW_DEST, false)).build(), getUser()));
    final Edge expectedEdge = new Edge(TestGroups.EDGE, NEW_SOURCE, NEW_DEST, false);
    expectedEdge.putProperty(TestPropertyNames.INT, 1);
    expectedEdge.putProperty(TestPropertyNames.COUNT, 1L);
    final Entity expectedEntity = new Entity(TestGroups.ENTITY, NEW_VERTEX);
    expectedEntity.putProperty(TestPropertyNames.STRING, "1");
    assertNotNull(results);
    assertEquals(2, results.size());
    assertThat(results, IsCollectionContaining.hasItems(expectedEntity, expectedEdge));
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Entity(uk.gov.gchq.gaffer.data.element.Entity) BasicGenerator(uk.gov.gchq.gaffer.integration.generators.BasicGenerator) Element(uk.gov.gchq.gaffer.data.element.Element) EntityDomainObject(uk.gov.gchq.gaffer.integration.domain.EntityDomainObject) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) EdgeDomainObject(uk.gov.gchq.gaffer.integration.domain.EdgeDomainObject) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.Test)

Example 35 with EntitySeed

use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.

the class GeneratorsIT method shouldConvertToDomainObjects.

@Test
public void shouldConvertToDomainObjects() throws OperationException, UnsupportedEncodingException {
    // Given
    final OperationChain<CloseableIterable<DomainObject>> opChain = new OperationChain.Builder().first(new GetElements.Builder<>().addSeed(new EntitySeed(SOURCE_1)).build()).then(new GenerateObjects.Builder<Element, DomainObject>().generator(new BasicGenerator()).outputType(new TypeReference<CloseableIterable<DomainObject>>() {
    }).build()).build();
    // When
    final List<DomainObject> results = Lists.newArrayList(graph.execute(opChain, getUser()));
    final EntityDomainObject entityDomainObject = new EntityDomainObject(SOURCE_1, "3", null);
    final EdgeDomainObject edgeDomainObject = new EdgeDomainObject(SOURCE_1, DEST_1, false, 1, 1L);
    // Then
    assertNotNull(results);
    assertEquals(2, results.size());
    assertThat(results, IsCollectionContaining.hasItems(entityDomainObject, edgeDomainObject));
}
Also used : BasicGenerator(uk.gov.gchq.gaffer.integration.generators.BasicGenerator) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) EntityDomainObject(uk.gov.gchq.gaffer.integration.domain.EntityDomainObject) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) EdgeDomainObject(uk.gov.gchq.gaffer.integration.domain.EdgeDomainObject) GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) EdgeDomainObject(uk.gov.gchq.gaffer.integration.domain.EdgeDomainObject) DomainObject(uk.gov.gchq.gaffer.integration.domain.DomainObject) EntityDomainObject(uk.gov.gchq.gaffer.integration.domain.EntityDomainObject) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.junit.Test)

Aggregations

EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)107 Test (org.junit.Test)51 Element (uk.gov.gchq.gaffer.data.element.Element)50 User (uk.gov.gchq.gaffer.user.User)43 HashSet (java.util.HashSet)34 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)33 Entity (uk.gov.gchq.gaffer.data.element.Entity)28 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)28 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)26 Edge (uk.gov.gchq.gaffer.data.element.Edge)22 Graph (uk.gov.gchq.gaffer.graph.Graph)22 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)21 ArrayList (java.util.ArrayList)20 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)14 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)12 GetEntities (uk.gov.gchq.gaffer.operation.impl.get.GetEntities)12 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)11 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)11 GetEdges (uk.gov.gchq.gaffer.operation.impl.get.GetEdges)11 Pair (uk.gov.gchq.gaffer.accumulostore.utils.Pair)9