Search in sources :

Example 1 with CancelScheduledJob

use of uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob in project Gaffer by gchq.

the class CancelScheduledJobTest method builderShouldCreatePopulatedOperation.

@Test
@Override
public void builderShouldCreatePopulatedOperation() {
    // Given
    CancelScheduledJob op = new CancelScheduledJob.Builder().jobId(testJobId).option("testOp", "testOpVal").build();
    // Then
    assertEquals(testJobId, op.getJobId());
    assertEquals(Collections.singletonMap("testOp", "testOpVal"), op.getOptions());
}
Also used : CancelScheduledJob(uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob) Test(org.junit.jupiter.api.Test) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest)

Example 2 with CancelScheduledJob

use of uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob in project Gaffer by gchq.

the class CancelScheduledJobTest method shouldShallowCloneOperation.

@Test
@Override
public void shouldShallowCloneOperation() {
    // Given
    CancelScheduledJob op = new CancelScheduledJob.Builder().jobId(testJobId).option("testOp", "testOpVal").build();
    // When
    CancelScheduledJob clonedOp = op.shallowClone();
    // Then
    assertNotSame(clonedOp, op);
    assertEquals(clonedOp.getJobId(), op.getJobId());
    assertEquals(clonedOp.getOptions(), op.getOptions());
}
Also used : CancelScheduledJob(uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob) Test(org.junit.jupiter.api.Test) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest)

Example 3 with CancelScheduledJob

use of uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob in project Gaffer by gchq.

the class CancelScheduledJobHandlerTest method shouldThrowExceptionIfJobTrackerIsNotConfigured.

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

Example 4 with CancelScheduledJob

use of uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob 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)

Aggregations

Test (org.junit.jupiter.api.Test)4 CancelScheduledJob (uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob)4 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)2 Context (uk.gov.gchq.gaffer.store.Context)2 Store (uk.gov.gchq.gaffer.store.Store)2 User (uk.gov.gchq.gaffer.user.User)2 JobTracker (uk.gov.gchq.gaffer.jobtracker.JobTracker)1