Search in sources :

Example 1 with GetAllJobDetails

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetAllJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails) JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) User(uk.gov.gchq.gaffer.user.User) JobTracker(uk.gov.gchq.gaffer.jobtracker.JobTracker) Store(uk.gov.gchq.gaffer.store.Store) Test(org.junit.Test)

Example 2 with GetAllJobDetails

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());
    }
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetAllJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails) User(uk.gov.gchq.gaffer.user.User) Store(uk.gov.gchq.gaffer.store.Store) OperationException(uk.gov.gchq.gaffer.operation.OperationException) Test(org.junit.Test)

Example 3 with GetAllJobDetails

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;
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) GetJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails) User(uk.gov.gchq.gaffer.user.User) DataGenerator15(uk.gov.gchq.gaffer.example.gettingstarted.generator.DataGenerator15) GetJobResults(uk.gov.gchq.gaffer.operation.impl.job.GetJobResults) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) GetAllJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails) Graph(uk.gov.gchq.gaffer.graph.Graph) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed)

Example 4 with GetAllJobDetails

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);
}
Also used : GetAllJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.Test)

Example 5 with GetAllJobDetails

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);
}
Also used : GetAllJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.Test)

Aggregations

GetAllJobDetails (uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails)5 Test (org.junit.Test)4 User (uk.gov.gchq.gaffer.user.User)3 JobDetail (uk.gov.gchq.gaffer.jobtracker.JobDetail)2 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)2 Context (uk.gov.gchq.gaffer.store.Context)2 Store (uk.gov.gchq.gaffer.store.Store)2 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)1 DataGenerator15 (uk.gov.gchq.gaffer.example.gettingstarted.generator.DataGenerator15)1 Graph (uk.gov.gchq.gaffer.graph.Graph)1 JobTracker (uk.gov.gchq.gaffer.jobtracker.JobTracker)1 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)1 OperationException (uk.gov.gchq.gaffer.operation.OperationException)1 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)1 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)1 GetJobDetails (uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails)1 GetJobResults (uk.gov.gchq.gaffer.operation.impl.job.GetJobResults)1