use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class ProxyStoreBasicIT method shouldAddElementsViaAJob.
@Test
public void shouldAddElementsViaAJob() throws Exception {
// Add elements
final AddElements add = new AddElements.Builder().elements(DEFAULT_ELEMENTS).build();
JobDetail jobDetail = graph.executeJob(new OperationChain<>(add), USER);
// Wait until the job status is not RUNNING
while (JobStatus.RUNNING.equals(jobDetail.getStatus())) {
jobDetail = graph.execute(new GetJobDetails.Builder().jobId(jobDetail.getJobId()).build(), USER);
Thread.sleep(100);
}
// Get elements
final GetElements<EntitySeed, Element> getElements = new GetElements.Builder<EntitySeed, Element>().view(new View.Builder().entity(TestGroups.ENTITY).build()).addSeed(new EntitySeed("1")).build();
CloseableIterable<Element> results = graph.execute(getElements, USER);
// Then
assertEquals(2, Iterables.size(results));
assertThat(results, hasItem(DEFAULT_ELEMENTS[0]));
assertThat(results, hasItem(DEFAULT_ELEMENTS[2]));
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class BloomFilter18IT method seek.
private void seek(final FileSKVIterator reader, final EntitySeed seed, final RangeFactory rangeFactory) throws IOException, RangeFactoryException {
final View view = new View.Builder().edge(TestGroups.EDGE).entity(TestGroups.ENTITY).build();
final GetElements<ElementSeed, ?> operation = new GetElements<>(view);
final List<Range> range = rangeFactory.getRange(seed, operation);
for (final Range ran : range) {
reader.seek(ran, new ArrayList<ByteSequence>(), false);
}
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class BloomFilterIT method seek.
private void seek(final FileSKVIterator reader, final EntitySeed seed, final RangeFactory rangeFactory) throws IOException, RangeFactoryException {
final View view = new View.Builder().edge(TestGroups.EDGE).entity(TestGroups.ENTITY).build();
final GetElements<ElementSeed, ?> operation = new GetElements<>(view);
final List<Range> range = rangeFactory.getRange(seed, operation);
for (final Range ran : range) {
reader.seek(ran, new ArrayList<ByteSequence>(), false);
}
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class AccumuloAggregationIT method shouldOnlyAggregateVisibilityWhenGroupByIsNull.
@Test
public void shouldOnlyAggregateVisibilityWhenGroupByIsNull() throws OperationException, UnsupportedEncodingException {
final Graph graph = createGraph();
final Entity entity1 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "value 3a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "value 4").property(AccumuloPropertyNames.VISIBILITY, PUBLIC_VISIBILITY).build();
final Entity entity2 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "value 3a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "value 4").property(AccumuloPropertyNames.VISIBILITY, PRIVATE_VISIBILITY).build();
final Entity entity3 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "value 3b").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "value 4").property(AccumuloPropertyNames.VISIBILITY, PRIVATE_VISIBILITY).build();
graph.execute(new AddElements(Arrays.asList((Element) entity1, entity2, entity3)), USER);
// Given
final GetEntities<EntitySeed> getElements = new GetEntities.Builder<EntitySeed>().addSeed(new EntitySeed(VERTEX)).view(new View()).build();
// When
final List<Entity> results = Lists.newArrayList(graph.execute(getElements, USER));
// Then
assertNotNull(results);
assertEquals(2, results.size());
final Entity expectedSummarisedEntity = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "value 3a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "value 4").property(AccumuloPropertyNames.VISIBILITY, PRIVATE_VISIBILITY + "," + PUBLIC_VISIBILITY).build();
assertThat(results, IsCollectionContaining.hasItems(expectedSummarisedEntity, entity3));
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class StoreTest method shouldThrowExceptionIfOperationViewIsInvalid.
@Test
public void shouldThrowExceptionIfOperationViewIsInvalid() throws OperationException, StoreException {
// Given
// Given
final Schema schema = createSchemaMock();
final StoreProperties properties = mock(StoreProperties.class);
final AddElements addElements = new AddElements();
final View view = mock(View.class);
final ViewValidator viewValidator = mock(ViewValidator.class);
final StoreImpl store = new StoreImpl(viewValidator);
addElements.setView(view);
given(schema.validate()).willReturn(true);
given(viewValidator.validate(view, schema, true)).willReturn(false);
store.initialise(schema, properties);
// When / Then
try {
store.execute(addElements, user);
fail("Exception expected");
} catch (final SchemaException e) {
verify(viewValidator).validate(view, schema, true);
assertTrue(e.getMessage().contains("View"));
}
}
Aggregations