use of uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails in project Gaffer by gchq.
the class GetAllJobDetailsHandlerTest method shouldGetAllJobDetailsByDelegatingToJobTracker.
@Test
public void shouldGetAllJobDetailsByDelegatingToJobTracker() throws OperationException {
// Given
final GetAllJobDetailsHandler handler = new GetAllJobDetailsHandler();
final GetAllJobDetails operation = mock(GetAllJobDetails.class);
final Store store = mock(Store.class);
final JobTracker jobTracker = mock(JobTracker.class);
final User user = mock(User.class);
final CloseableIterable<JobDetail> jobsDetails = mock(CloseableIterable.class);
given(store.getJobTracker()).willReturn(jobTracker);
given(jobTracker.getAllJobs(user)).willReturn(jobsDetails);
// When
final CloseableIterable<JobDetail> results = handler.doOperation(operation, new Context(user), store);
// Then
assertSame(jobsDetails, results);
}
use of uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails in project Gaffer by gchq.
the class GetAllJobDetailsHandlerTest method shouldThrowExceptionIfJobTrackerIsNotConfigured.
@Test
public void shouldThrowExceptionIfJobTrackerIsNotConfigured() {
// Given
final GetAllJobDetailsHandler handler = new GetAllJobDetailsHandler();
final GetAllJobDetails operation = mock(GetAllJobDetails.class);
final Store store = mock(Store.class);
final User user = mock(User.class);
given(store.getJobTracker()).willReturn(null);
// When / Then
try {
handler.doOperation(operation, new Context(user), store);
fail("Exception expected");
} catch (final OperationException e) {
assertNotNull(e.getMessage());
}
}
use of uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails in project Gaffer by gchq.
the class LoadAndQuery15 method run.
public CloseableIterable<?> run() throws OperationException {
// [user] Create a user
// ---------------------------------------------------------
final User user = new User("user01");
// ---------------------------------------------------------
// [graph] create a graph using our schema and store properties
// ---------------------------------------------------------
final Graph graph = new Graph.Builder().addSchemas(getSchemas()).storeProperties(getStoreProperties()).build();
// ---------------------------------------------------------
// [add] add the edges to the graph
// ---------------------------------------------------------
final OperationChain addOpChain = new OperationChain.Builder().first(new GenerateElements.Builder<String>().generator(new DataGenerator15()).objects(DataUtils.loadData(getData())).build()).then(new AddElements()).build();
graph.execute(addOpChain, user);
// ---------------------------------------------------------
// [job] create an operation chain to be executed as a job
// ---------------------------------------------------------
final OperationChain<CloseableIterable<Edge>> job = new OperationChain.Builder().first(new GetEdges.Builder<EntitySeed>().addSeed(new EntitySeed("1")).build()).build();
// ---------------------------------------------------------
// [execute job] execute the job
// ---------------------------------------------------------
final JobDetail initialJobDetail = graph.executeJob(job, user);
final String jobId = initialJobDetail.getJobId();
// ---------------------------------------------------------
log("JOB_DETAIL_START", initialJobDetail.toString());
waitUntilJobHashFinished(user, graph, initialJobDetail);
// [job details] Get the job details
// ---------------------------------------------------------
final JobDetail jobDetail = graph.execute(new GetJobDetails.Builder().jobId(jobId).build(), user);
// ---------------------------------------------------------
log("JOB_DETAIL_FINISH", jobDetail.toString());
// [all job details] Get all job details
// ---------------------------------------------------------
final CloseableIterable<JobDetail> jobDetails = graph.execute(new GetAllJobDetails(), user);
// ---------------------------------------------------------
for (final JobDetail detail : jobDetails) {
log("ALL_JOB_DETAILS", detail.toString());
}
// [get job results] Get the job results
// ---------------------------------------------------------
final CloseableIterable<?> jobResults = graph.execute(new GetJobResults.Builder().jobId(jobId).build(), user);
// ---------------------------------------------------------
for (final Object result : jobResults) {
log("JOB_RESULTS", result.toString());
}
return jobResults;
}
use of uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails in project Gaffer by gchq.
the class GetAllJobDetailsTest method shouldSerialiseAndDeserialiseOperation.
@Test
@Override
public void shouldSerialiseAndDeserialiseOperation() throws SerialisationException {
// Given
final GetAllJobDetails operation = new GetAllJobDetails.Builder().build();
// When
byte[] json = serialiser.serialise(operation, true);
final GetAllJobDetails deserialisedOp = serialiser.deserialise(json, GetAllJobDetails.class);
// Then
assertNotNull(deserialisedOp);
}
use of uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails in project Gaffer by gchq.
the class GetAllJobDetailsTest method builderShouldCreatePopulatedOperation.
@Test
@Override
public void builderShouldCreatePopulatedOperation() {
// When
final GetAllJobDetails op = new GetAllJobDetails.Builder().build();
// Then
assertNotNull(op);
}
Aggregations