use of uk.gov.gchq.gaffer.store.Context 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);
}
use of uk.gov.gchq.gaffer.store.Context in project Gaffer by gchq.
the class GetJobDetailsHandlerTest method shouldThrowExceptionIfJobTrackerIsNotConfigured.
@Test
public void shouldThrowExceptionIfJobTrackerIsNotConfigured() {
// Given
final GetJobDetailsHandler handler = new GetJobDetailsHandler();
final GetJobDetails operation = mock(GetJobDetails.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.store.Context in project Gaffer by gchq.
the class CountGroupsHandlerTest method shouldReturnGroupCountsUpToLimit.
@Test
public void shouldReturnGroupCountsUpToLimit() throws OperationException {
// Given
final CountGroupsHandler handler = new CountGroupsHandler();
final Store store = mock(Store.class);
final CountGroups countGroups = mock(CountGroups.class);
final CloseableIterable<Element> elements = getElements();
final Integer limit = 3;
final Context context = new Context();
given(countGroups.getLimit()).willReturn(limit);
given(countGroups.getElements()).willReturn(elements);
// When
final GroupCounts counts = handler.doOperation(countGroups, context, store);
// Then
assertTrue(counts.isLimitHit());
assertEquals(2, counts.getEntityGroups().size());
assertEquals(2, (int) counts.getEntityGroups().get(GROUP1));
assertEquals(1, (int) counts.getEntityGroups().get(GROUP2));
}
use of uk.gov.gchq.gaffer.store.Context in project Gaffer by gchq.
the class CountGroupsHandlerTest method shouldReturnNoCountsIfElementsAreNull.
@Test
public void shouldReturnNoCountsIfElementsAreNull() throws OperationException {
// Given
final CountGroupsHandler handler = new CountGroupsHandler();
final Store store = mock(Store.class);
final CountGroups countGroups = mock(CountGroups.class);
final Context context = new Context();
given(countGroups.getElements()).willReturn(null);
// When
final GroupCounts counts = handler.doOperation(countGroups, context, store);
// Then
assertFalse(counts.isLimitHit());
assertEquals(0, counts.getEntityGroups().size());
assertEquals(0, counts.getEdgeGroups().size());
}
Aggregations