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