use of uk.gov.gchq.gaffer.store.Store 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.store.Store 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.store.Store in project Gaffer by gchq.
the class GetJobDetailsHandlerTest method shouldGetJobDetailsByDelegatingToJobTrackerWithContextJobId.
@Test
public void shouldGetJobDetailsByDelegatingToJobTrackerWithContextJobId() throws OperationException {
// Given
final String jobId = "jobId";
final GetJobDetailsHandler handler = new GetJobDetailsHandler();
final GetJobDetails operation = new GetJobDetails();
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, jobId);
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.Store in project Gaffer by gchq.
the class GraphConfigurationServiceTest method setup.
@Before
public void setup() {
final Store store = mock(Store.class);
final Schema schema = mock(Schema.class);
final Set<StoreTrait> traits = new HashSet<>(Arrays.asList(STORE_AGGREGATION, PRE_AGGREGATION_FILTERING, POST_TRANSFORMATION_FILTERING, POST_AGGREGATION_FILTERING, TRANSFORMATION, STORE_VALIDATION));
given(store.getSchema()).willReturn(schema);
final Graph graph = new Graph.Builder().store(store).build();
final Set<Class<? extends Operation>> operations = new HashSet<>();
operations.add(AddElements.class);
given(graphFactory.getGraph()).willReturn(graph);
given(graph.getSupportedOperations()).willReturn(operations);
given(graph.isSupported(AddElements.class)).willReturn(true);
given(userFactory.createUser()).willReturn(new User());
given(graph.getStoreTraits()).willReturn(traits);
}
use of uk.gov.gchq.gaffer.store.Store in project Gaffer by gchq.
the class CountGroupsHandlerTest method shouldReturnGroupCountsWithoutLimit.
@Test
public void shouldReturnGroupCountsWithoutLimit() 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 Context context = new Context();
given(countGroups.getLimit()).willReturn(null);
given(countGroups.getElements()).willReturn(elements);
// When
final GroupCounts counts = handler.doOperation(countGroups, context, store);
// Then
assertFalse(counts.isLimitHit());
assertEquals(2, counts.getEntityGroups().size());
assertEquals(3, (int) counts.getEntityGroups().get(GROUP1));
assertEquals(1, (int) counts.getEntityGroups().get(GROUP2));
assertEquals(2, counts.getEdgeGroups().size());
assertEquals(1, (int) counts.getEdgeGroups().get(GROUP1));
assertEquals(3, (int) counts.getEdgeGroups().get(GROUP2));
}
Aggregations