Search in sources :

Example 1 with GetEntities

use of uk.gov.gchq.gaffer.operation.impl.get.GetEntities in project Gaffer by gchq.

the class AccumuloAggregationIT method shouldHandleAggregatationWhenAllColumnQualifierPropertiesAreGroupByProperties.

@Test
public void shouldHandleAggregatationWhenAllColumnQualifierPropertiesAreGroupByProperties() throws OperationException, UnsupportedEncodingException {
    final Graph graph = createGraphNoVisibility();
    final Entity entity1 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_2, "test 4").build();
    final Entity entity2 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_2, "test 4").build();
    graph.execute(new AddElements(Arrays.asList((Element) entity1, entity2)), USER);
    // Given
    final GetEntities<EntitySeed> getElements = new GetEntities.Builder<EntitySeed>().addSeed(new EntitySeed(VERTEX)).view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy(AccumuloPropertyNames.COLUMN_QUALIFIER, AccumuloPropertyNames.COLUMN_QUALIFIER_2).build()).build()).build();
    // When
    final List<Entity> results = Lists.newArrayList(graph.execute(getElements, USER));
    // Then
    assertNotNull(results);
    assertEquals(1, results.size());
    final Entity expectedEntity = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_2, "test 4").build();
    assertEquals(expectedEntity, results.get(0));
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Entity(uk.gov.gchq.gaffer.data.element.Entity) Graph(uk.gov.gchq.gaffer.graph.Graph) Builder(uk.gov.gchq.gaffer.graph.Graph.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities) Test(org.junit.Test)

Example 2 with GetEntities

use of uk.gov.gchq.gaffer.operation.impl.get.GetEntities in project Gaffer by gchq.

the class AccumuloAggregationIT method shouldHandleAggregatationWhenGroupByPropertiesAreNotSet.

@Test
public void shouldHandleAggregatationWhenGroupByPropertiesAreNotSet() throws OperationException, UnsupportedEncodingException {
    final Graph graph = createGraphNoVisibility();
    final Entity entity1 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity entity2 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    graph.execute(new AddElements(Arrays.asList((Element) entity1, entity2)), USER);
    // Given
    final GetEntities<EntitySeed> getElements = new GetEntities.Builder<EntitySeed>().addSeed(new EntitySeed(VERTEX)).view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy(AccumuloPropertyNames.COLUMN_QUALIFIER, AccumuloPropertyNames.COLUMN_QUALIFIER_2).build()).build()).build();
    // When
    final List<Entity> results = Lists.newArrayList(graph.execute(getElements, USER));
    // Then
    assertNotNull(results);
    assertEquals(1, results.size());
    final Entity expectedEntity = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    assertEquals(expectedEntity, results.get(0));
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Entity(uk.gov.gchq.gaffer.data.element.Entity) Graph(uk.gov.gchq.gaffer.graph.Graph) Builder(uk.gov.gchq.gaffer.graph.Graph.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities) Test(org.junit.Test)

Example 3 with GetEntities

use of uk.gov.gchq.gaffer.operation.impl.get.GetEntities in project Gaffer by gchq.

the class AccumuloAggregationIT method shouldHandleAggregatationWhenGroupByPropertiesAreNull.

@Test
public void shouldHandleAggregatationWhenGroupByPropertiesAreNull() throws OperationException, UnsupportedEncodingException {
    final Graph graph = createGraphNoVisibility();
    final Entity entity1 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, null).property(AccumuloPropertyNames.COLUMN_QUALIFIER_2, null).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, null).property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, null).build();
    final Entity entity2 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    graph.execute(new AddElements(Arrays.asList((Element) entity1, entity2)), USER);
    // Given
    final GetEntities<EntitySeed> getElements = new GetEntities.Builder<EntitySeed>().addSeed(new EntitySeed(VERTEX)).view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy().build()).build()).build();
    // When
    final List<Entity> results = Lists.newArrayList(graph.execute(getElements, USER));
    // Then
    assertNotNull(results);
    assertEquals(1, results.size());
    final Entity expectedEntity = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    assertEquals(expectedEntity, results.get(0));
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Entity(uk.gov.gchq.gaffer.data.element.Entity) Graph(uk.gov.gchq.gaffer.graph.Graph) Builder(uk.gov.gchq.gaffer.graph.Graph.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities) Test(org.junit.Test)

Example 4 with GetEntities

use of uk.gov.gchq.gaffer.operation.impl.get.GetEntities in project Gaffer by gchq.

the class OperationChainLimiterTest method shouldAcceptOperationChainWhenUserHasAuthScoreGreaterThanChainScore.

@Test
public void shouldAcceptOperationChainWhenUserHasAuthScoreGreaterThanChainScore() {
    // Given
    final OperationChain opChain = new OperationChain.Builder().first(new GetEntities()).build();
    final User user = new User.Builder().opAuths("User").build();
    // When
    OPERATION_CHAIN_LIMITER.preExecute(opChain, user);
// Then - no exceptions
}
Also used : User(uk.gov.gchq.gaffer.user.User) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities) Test(org.junit.Test)

Example 5 with GetEntities

use of uk.gov.gchq.gaffer.operation.impl.get.GetEntities in project Gaffer by gchq.

the class AddNamedOperationHandlerTest method shouldAllowForNonRecursiveNamedOperationsToBeNested.

@Test
public void shouldAllowForNonRecursiveNamedOperationsToBeNested() {
    try {
        OperationChain child = new OperationChain.Builder().first(new AddElements()).build();
        addNamedOperation.setOperationChain(child);
        addNamedOperation.setOperationName("child");
        handler.doOperation(addNamedOperation, context, store);
        OperationChain parent = new OperationChain.Builder().first(new NamedOperation("child", "")).then(new GetElements<>()).build();
        addNamedOperation.setOperationChain(parent);
        addNamedOperation.setOperationName("parent");
        handler.doOperation(addNamedOperation, context, store);
        OperationChain grandparent = new OperationChain.Builder().first(new AddElements()).then(new NamedOperation("parent", "")).then(new NamedOperation("child", "")).then(new GetEntities<>()).build();
        addNamedOperation.setOperationChain(grandparent);
        addNamedOperation.setOperationName("grandparent");
        handler.doOperation(addNamedOperation, context, store);
        assert (cacheContains("grandparent"));
    } catch (final Exception e) {
        fail("Expected test to pass without error");
    }
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) ExtendedNamedOperation(uk.gov.gchq.gaffer.named.operation.ExtendedNamedOperation) NamedOperation(uk.gov.gchq.gaffer.named.operation.NamedOperation) CacheOperationFailedException(uk.gov.gchq.gaffer.named.operation.cache.CacheOperationFailedException) OperationException(uk.gov.gchq.gaffer.operation.OperationException) ExpectedException(org.junit.rules.ExpectedException) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities) Test(org.junit.Test)

Aggregations

GetEntities (uk.gov.gchq.gaffer.operation.impl.get.GetEntities)14 Test (org.junit.Test)10 Entity (uk.gov.gchq.gaffer.data.element.Entity)9 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)9 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)8 Graph (uk.gov.gchq.gaffer.graph.Graph)7 Builder (uk.gov.gchq.gaffer.graph.Graph.Builder)6 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)3 ArrayList (java.util.ArrayList)2 Concat (uk.gov.gchq.gaffer.function.transform.Concat)2 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)2 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)2 User (uk.gov.gchq.gaffer.user.User)2 HyperLogLogPlus (com.clearspring.analytics.stream.cardinality.HyperLogLogPlus)1 ExpectedException (org.junit.rules.ExpectedException)1 Edge (uk.gov.gchq.gaffer.data.element.Edge)1 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)1 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)1 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)1 DataGenerator9 (uk.gov.gchq.gaffer.example.gettingstarted.generator.DataGenerator9)1