use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.
the class OperationChainTest method shouldBuildOperationChain.
@Test
public void shouldBuildOperationChain() {
// Given
final AddElements addElements = mock(AddElements.class);
final GetElements getAdj1 = mock(GetElements.class);
final GetElements getAdj2 = mock(GetElements.class);
final GetElements<EntitySeed, Element> getRelElements = mock(GetElements.class);
// When
final OperationChain<CloseableIterable<Element>> opChain = new Builder().first(addElements).then(getAdj1).then(getAdj2).then(getRelElements).build();
// Then
assertArrayEquals(new Operation[] { addElements, getAdj1, getAdj2, getRelElements }, opChain.getOperationArray());
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.
the class OperationChainTest method shouldReturnReadableStringForToString.
@Test
public void shouldReturnReadableStringForToString() {
// Given
final AddElements addElements = new AddElements();
final GetAdjacentEntitySeeds getAdj1 = new GetAdjacentEntitySeeds();
final GetAdjacentEntitySeeds getAdj2 = new GetAdjacentEntitySeeds();
final GetElements<EntitySeed, Element> getRelElements = new GetElements<>();
final OperationChain<CloseableIterable<Element>> opChain = new Builder().first(addElements).then(getAdj1).then(getAdj2).then(getRelElements).build();
// When
final String toString = opChain.toString();
// Then
final String expectedToString = "OperationChain[AddElements->GetAdjacentEntitySeeds->GetAdjacentEntitySeeds->GetElements]";
assertEquals(expectedToString, toString);
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.
the class AddNamedOperationHandlerTest method shouldNotAllowUpdateToNamedOperationIfItCausesRecursion.
@Test
public void shouldNotAllowUpdateToNamedOperationIfItCausesRecursion() throws OperationException {
String innocentOpName = "innocent";
OperationChain innocent = new OperationChain.Builder().first(new GetElements<>()).build();
addNamedOperation.setOperationName(innocentOpName);
addNamedOperation.setOperationChain(innocent);
handler.doOperation(addNamedOperation, context, store);
OperationChain parent = new OperationChain.Builder().first(new NamedOperation(innocentOpName, "call down to currently innocent named op")).build();
addNamedOperation.setOperationChain(parent);
addNamedOperation.setOperationName(OPERATION_NAME);
handler.doOperation(addNamedOperation, context, store);
OperationChain recursive = new OperationChain.Builder().first(new NamedOperation(OPERATION_NAME, "")).build();
addNamedOperation.setOperationName(innocentOpName);
addNamedOperation.setOperationChain(recursive);
addNamedOperation.setOverwriteFlag(true);
exception.expect(OperationException.class);
handler.doOperation(addNamedOperation, context, store);
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetElements 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.operation.impl.get.GetElements 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);
}
}
Aggregations