Search in sources :

Example 1 with Entity

use of uk.gov.gchq.gaffer.data.element.Entity 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 Entity

use of uk.gov.gchq.gaffer.data.element.Entity 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 Entity

use of uk.gov.gchq.gaffer.data.element.Entity 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 Entity

use of uk.gov.gchq.gaffer.data.element.Entity in project Gaffer by gchq.

the class AccumuloAggregationIT method shouldHandleAggregatationWhenNoAggregatorsAreProvided.

@Test
public void shouldHandleAggregatationWhenNoAggregatorsAreProvided() throws OperationException, UnsupportedEncodingException {
    final Graph graph = createGraphNoAggregators();
    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, null).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity entity3 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test1a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity entity4 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test1b").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity entity5 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test1a").build();
    final Entity entity6 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test1b").build();
    final Entity entity7 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_2, "test2a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").build();
    graph.execute(new AddElements(Arrays.asList((Element) entity1, entity2, entity3, entity4, entity5, entity6, entity7)), USER);
    // Duplicate the entities to check they are not aggregated
    graph.execute(new AddElements(Arrays.asList((Element) entity1, entity2, entity3, entity4, entity5, entity6, entity7)), USER);
    // Given
    final GetAllEntities getAllEntities = new GetAllEntities();
    // When
    final List<Entity> results = Lists.newArrayList(graph.execute(getAllEntities, USER));
    // Then
    assertNotNull(results);
    assertEquals(14, results.size());
    final Entity expectedEntity1 = 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 expectedEntity2 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test1a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity expectedEntity3 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test1b").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity expectedEntity4 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_2, "test2a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").build();
    assertThat(results, IsCollectionContaining.hasItems(expectedEntity1, expectedEntity2, expectedEntity3, expectedEntity4));
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Entity(uk.gov.gchq.gaffer.data.element.Entity) GetAllEntities(uk.gov.gchq.gaffer.operation.impl.get.GetAllEntities) Graph(uk.gov.gchq.gaffer.graph.Graph) Builder(uk.gov.gchq.gaffer.graph.Graph.Builder) Test(org.junit.Test)

Example 5 with Entity

use of uk.gov.gchq.gaffer.data.element.Entity in project Gaffer by gchq.

the class AbstractAccumuloElementConverterTest method shouldReturnAccumuloKeyConverterMultipleCQPropertiesEntity.

@Test
public void shouldReturnAccumuloKeyConverterMultipleCQPropertiesEntity() throws SchemaException, AccumuloElementConversionException, IOException {
    // Given
    final Entity entity = new Entity(TestGroups.ENTITY);
    entity.setVertex("3");
    entity.putProperty(AccumuloPropertyNames.COLUMN_QUALIFIER, 100);
    // When
    final Pair<Key> keys = converter.getKeysFromElement(entity);
    final Entity newEntity = (Entity) converter.getElementFromKey(keys.getFirst());
    // Then
    assertEquals("3", newEntity.getVertex());
    assertEquals(100, newEntity.getProperty(AccumuloPropertyNames.COLUMN_QUALIFIER));
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Aggregations

Entity (uk.gov.gchq.gaffer.data.element.Entity)373 Test (org.junit.jupiter.api.Test)204 Element (uk.gov.gchq.gaffer.data.element.Element)176 Edge (uk.gov.gchq.gaffer.data.element.Edge)132 ArrayList (java.util.ArrayList)91 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)70 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)69 User (uk.gov.gchq.gaffer.user.User)68 Graph (uk.gov.gchq.gaffer.graph.Graph)60 HashSet (java.util.HashSet)52 Test (org.junit.Test)52 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)47 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)39 List (java.util.List)32 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)32 IsMoreThan (uk.gov.gchq.koryphe.impl.predicate.IsMoreThan)31 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)30 Schema (uk.gov.gchq.gaffer.store.schema.Schema)29 TestGroups (uk.gov.gchq.gaffer.commonutil.TestGroups)28 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)28