Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Commit 342a6cc

Browse files
authored
gh-2153 updated operation chain in job using graph (#2156)
* gh-2154 simplified Job object * gh-2153 updated operation chain in job using graph * gh-2153 added test * gh-2153 removed spaces * gh-2154 removed spaces from tests * gh-2154 updated equals method to throw a GafferRuntimeException * gh-2153 removed unnecessary serialisation * gh-2154 updated test
1 parent 569b74d commit 342a6cc

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

core/graph/src/main/java/uk/gov/gchq/gaffer/graph/Graph.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ public JobDetail executeJob(final Job job, final Context context) throws Operati
271271
graphHook.preExecute(clonedOpChain, clonedContext);
272272
}
273273
updateOperationChainView(clonedOpChain);
274+
job.setOperation(clonedOpChain);
274275
result = store.executeJob(job, context);
275276
for (final GraphHook graphHook : config.getHooks()) {
276277
graphHook.postExecute(result, clonedOpChain, clonedContext);

core/graph/src/test/java/uk/gov/gchq/gaffer/graph/GraphTest.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2284,6 +2284,44 @@ public void shouldNotAddExtraGroupsFromSchemaViewWithUpdateViewHookWhenInBlackli
22842284
((GetElements) ops.get(0)).getView().toCompactJson());
22852285
}
22862286

2287+
@Test
2288+
public void shouldAddSchemaGroupsIfNotIncludedInJob() throws OperationException {
2289+
// given
2290+
final Job job = new Job(null, new OperationChain.Builder().first(new GetAllElements()).build());
2291+
2292+
final Store store = mock(Store.class);
2293+
2294+
given(store.getSchema()).willReturn(new Schema.Builder()
2295+
.entity(TestGroups.ENTITY, new SchemaEntityDefinition())
2296+
.edge(TestGroups.EDGE, new SchemaEdgeDefinition())
2297+
.edge(TestGroups.EDGE_2, new SchemaEdgeDefinition())
2298+
.build());
2299+
given(store.getProperties()).willReturn(new StoreProperties());
2300+
2301+
final Graph graph = new Graph.Builder()
2302+
.config(new GraphConfig.Builder()
2303+
.graphId(GRAPH_ID)
2304+
.build())
2305+
.storeProperties(StreamUtil.storeProps(getClass()))
2306+
.store(store)
2307+
.build();
2308+
2309+
final ArgumentCaptor<Job> jobCaptor = ArgumentCaptor.forClass(Job.class);
2310+
final ArgumentCaptor<Context> contextCaptor = ArgumentCaptor.forClass(Context.class);
2311+
2312+
given(store.executeJob(jobCaptor.capture(), contextCaptor.capture())).willReturn(new JobDetail());
2313+
2314+
// when
2315+
graph.executeJob(job, context);
2316+
2317+
// then
2318+
final GetAllElements operation = (GetAllElements) ((OperationChain) jobCaptor.getValue().getOperation()).getOperations().get(0);
2319+
2320+
assertEquals(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition())
2321+
.edge(TestGroups.EDGE, new ViewElementDefinition())
2322+
.edge(TestGroups.EDGE_2, new ViewElementDefinition()).build(), operation.getView());
2323+
}
2324+
22872325
public static class TestStoreImpl extends Store {
22882326
@Override
22892327
public Set<StoreTrait> getTraits() {

0 commit comments

Comments
 (0)