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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations