Search in sources :

Example 6 with JobTracker

use of uk.gov.gchq.gaffer.jobtracker.JobTracker in project Gaffer by gchq.

the class CancelScheduledJobHandlerTest method shouldThrowExceptionWithNoJobId.

@Test
public void shouldThrowExceptionWithNoJobId() {
    // Given
    CancelScheduledJob operation = new CancelScheduledJob.Builder().jobId(null).build();
    CancelScheduledJobHandler handler = new CancelScheduledJobHandler();
    final Store store = mock(Store.class);
    final User user = mock(User.class);
    given(store.getJobTracker()).willReturn(new JobTracker());
    // When / Then
    assertThatExceptionOfType(OperationException.class).isThrownBy(() -> handler.doOperation(operation, new Context(user), store)).withMessage("job id must be specified");
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) User(uk.gov.gchq.gaffer.user.User) JobTracker(uk.gov.gchq.gaffer.jobtracker.JobTracker) Store(uk.gov.gchq.gaffer.store.Store) CancelScheduledJob(uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob) Test(org.junit.jupiter.api.Test)

Example 7 with JobTracker

use of uk.gov.gchq.gaffer.jobtracker.JobTracker in project Gaffer by gchq.

the class GetJobDetailsHandlerTest method shouldGetJobDetailsByDelegatingToJobTrackerWithOperationJobId.

@Test
public void shouldGetJobDetailsByDelegatingToJobTrackerWithOperationJobId() throws OperationException {
    // Given
    final String jobId = "jobId";
    final GetJobDetailsHandler handler = new GetJobDetailsHandler();
    final GetJobDetails operation = new GetJobDetails.Builder().jobId(jobId).build();
    final Store store = mock(Store.class);
    final JobTracker jobTracker = mock(JobTracker.class);
    final User user = mock(User.class);
    final JobDetail jobsDetail = mock(JobDetail.class);
    final Context context = new Context(user);
    given(store.getJobTracker()).willReturn(jobTracker);
    given(jobTracker.getJob(jobId, user)).willReturn(jobsDetail);
    // When
    final JobDetail result = handler.doOperation(operation, context, store);
    // Then
    assertSame(jobsDetail, result);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetJobDetails(uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails) 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.jupiter.api.Test)

Aggregations

JobTracker (uk.gov.gchq.gaffer.jobtracker.JobTracker)7 Test (org.junit.jupiter.api.Test)5 User (uk.gov.gchq.gaffer.user.User)5 Context (uk.gov.gchq.gaffer.store.Context)4 Store (uk.gov.gchq.gaffer.store.Store)4 JobDetail (uk.gov.gchq.gaffer.jobtracker.JobDetail)3 GetJobDetails (uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)1 ValidateOperationChain (uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain)1 CancelScheduledJob (uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob)1 GetAllJobDetails (uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails)1 StringSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser)1 StringToStringSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser)1 GetSchema (uk.gov.gchq.gaffer.store.operation.GetSchema)1 OperationChainValidator (uk.gov.gchq.gaffer.store.operation.OperationChainValidator)1 OperationHandler (uk.gov.gchq.gaffer.store.operation.handler.OperationHandler)1 OutputOperationHandler (uk.gov.gchq.gaffer.store.operation.handler.OutputOperationHandler)1 Schema (uk.gov.gchq.gaffer.store.schema.Schema)1 SchemaEdgeDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition)1