use of uk.gov.gchq.gaffer.operation.OperationChain 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");
}
}
use of uk.gov.gchq.gaffer.operation.OperationChain in project Gaffer by gchq.
the class AddNamedOperationHandlerTest method shouldNotAllowAdditionOfRecursiveNamedOperation.
@Test
public void shouldNotAllowAdditionOfRecursiveNamedOperation() throws OperationException {
OperationChain singleRecursion = new OperationChain.Builder().first(operation).build();
addNamedOperation.setOperationChain(singleRecursion);
exception.expect(OperationException.class);
handler.doOperation(addNamedOperation, context, store);
}
use of uk.gov.gchq.gaffer.operation.OperationChain in project Gaffer by gchq.
the class AddNamedOperationHandlerTest method shouldNotAllowNamedOperationToBeAddedContainingANamedOperationThatDoesNotExist.
@Test
public void shouldNotAllowNamedOperationToBeAddedContainingANamedOperationThatDoesNotExist() throws OperationException {
NamedOperation op = new NamedOperation("parent", "this is the parent which has not yet been created");
OperationChain opChain = new OperationChain.Builder().first(op).build();
addNamedOperation.setOperationChain(opChain);
addNamedOperation.setOperationName(OPERATION_NAME);
exception.expect(OperationException.class);
handler.doOperation(addNamedOperation, context, store);
}
use of uk.gov.gchq.gaffer.operation.OperationChain in project Gaffer by gchq.
the class JcsJobTrackerIT method shouldAddJobIdToJobTrackerWhenExecute.
@Test
public void shouldAddJobIdToJobTrackerWhenExecute() throws OperationException, IOException, InterruptedException {
// Given
final OperationChain<JobDetail> opChain = new OperationChain.Builder().first(new GetAllEdges()).then(new GetJobDetails()).build();
final User user = new User("user01");
// When
final JobDetail jobDetails = graph.execute(opChain, user);
final String jobId = jobDetails.getJobId();
final JobDetail expectedJobDetail = new JobDetail(jobId, user.getUserId(), opChain, JobStatus.RUNNING, null);
expectedJobDetail.setStartTime(jobDetails.getStartTime());
expectedJobDetail.setEndTime(jobDetails.getEndTime());
// Then
assertEquals(expectedJobDetail, jobDetails);
}
use of uk.gov.gchq.gaffer.operation.OperationChain in project Gaffer by gchq.
the class JcsJobTrackerIT method shouldAddJobIdToJobTrackerWhenExecuteJob.
@Test
public void shouldAddJobIdToJobTrackerWhenExecuteJob() throws OperationException, IOException, InterruptedException {
// Given
final OperationChain<CloseableIterable<Edge>> opChain = new OperationChain<>(new GetAllEdges());
final User user = new User("user01");
// When
JobDetail jobDetails = graph.executeJob(opChain, user);
final String jobId = jobDetails.getJobId();
final JobDetail expectedJobDetail = new JobDetail(jobId, user.getUserId(), opChain, JobStatus.FINISHED, null);
expectedJobDetail.setStartTime(jobDetails.getStartTime());
int count = 0;
while (JobStatus.RUNNING == jobDetails.getStatus() && ++count < 20) {
Thread.sleep(100);
jobDetails = graph.execute(new GetJobDetails.Builder().jobId(jobId).build(), user);
}
expectedJobDetail.setEndTime(jobDetails.getEndTime());
// Then
assertEquals(expectedJobDetail, jobDetails);
}
Aggregations