use of uk.gov.gchq.gaffer.graph.hook.AddOperationsToChain in project Gaffer by gchq.
the class GraphConfigTest method getTestObject.
@Override
protected GraphConfig getTestObject() {
final String graphId = "graphId";
final GraphLibrary library = new HashMapGraphLibrary();
final View view = new View.Builder().globalElements(new GlobalViewElementDefinition.Builder().groupBy().build()).build();
final GraphHook hook1 = new AddOperationsToChain();
final GraphHook hook2 = new OperationChainLimiter();
return new GraphConfig.Builder().graphId(graphId).library(library).description("testGraphConfig").addHook(hook1).addHook(hook2).view(view).build();
}
use of uk.gov.gchq.gaffer.graph.hook.AddOperationsToChain in project Gaffer by gchq.
the class GraphConfigTest method shouldDeserialisationJson.
@Test
public void shouldDeserialisationJson() throws IOException {
// Given
final GraphConfig config = JSONSerialiser.deserialise(StreamUtil.graphConfig(getClass()), GraphConfig.class);
// Then
assertEquals("graphId1", config.getGraphId());
assertEquals(HashMapGraphLibrary.class, config.getLibrary().getClass());
final List<GraphHook> graphHooks = config.getHooks();
assertThat(graphHooks).hasSize(1);
final AddOperationsToChain addOperationsToChain = (AddOperationsToChain) graphHooks.get(0);
for (final Class op : new Class[] { ToSet.class, ToArray.class, ToList.class, ExportToSet.class }) {
assertEquals(RESULT_LIMIT, (int) ((Limit) addOperationsToChain.getBefore().get(op.getName()).get(0)).getResultLimit());
}
for (final Class op : new Class[] { GetElements.class, GetAllElements.class, GetAdjacentIds.class }) {
assertEquals(RESULT_LIMIT, (int) ((Limit) addOperationsToChain.getAfter().get(op.getName()).get(0)).getResultLimit());
}
}
use of uk.gov.gchq.gaffer.graph.hook.AddOperationsToChain in project Gaffer by gchq.
the class GetWalksIT method shouldGetPathsWithSimpleGraphHook_2.
@Test
public void shouldGetPathsWithSimpleGraphHook_2() throws Exception {
// Given
final AddOperationsToChain graphHook = new AddOperationsToChain();
final java.util.Map<String, List<Operation>> graphHookConfig = new HashMap<>();
graphHookConfig.put(GetElements.class.getName(), Lists.newArrayList(new Limit.Builder<>().resultLimit(1).build()));
graphHook.setAfter(graphHookConfig);
final GraphConfig config = new GraphConfig.Builder().addHook(graphHook).graphId("integrationTest").build();
createGraph(config);
addDefaultElements();
final GetElements operation = new GetElements.Builder().directedType(DirectedType.DIRECTED).view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().properties(TestPropertyNames.COUNT).build()).build()).inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING).build();
final GetWalks op = new GetWalks.Builder().input(seedA).operations(operation, operation).build();
// When
final Iterable<Walk> results = graph.execute(op, getUser());
// Then
assertThat(getPaths(results)).isEqualTo("ABC");
}
use of uk.gov.gchq.gaffer.graph.hook.AddOperationsToChain in project Gaffer by gchq.
the class GetWalksIT method shouldGetPathsWithSimpleGraphHook_1.
@Test
public void shouldGetPathsWithSimpleGraphHook_1() throws Exception {
// Given
final AddOperationsToChain graphHook = new AddOperationsToChain();
graphHook.setEnd(Lists.newArrayList(new Limit.Builder<>().resultLimit(1).build()));
final GraphConfig config = new GraphConfig.Builder().addHook(graphHook).graphId("integrationTest").build();
createGraph(config);
addDefaultElements();
final GetElements operation = new GetElements.Builder().directedType(DirectedType.DIRECTED).view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().properties(TestPropertyNames.COUNT).build()).build()).inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING).build();
final GetWalks op = new GetWalks.Builder().input(seedA).operations(operation, operation).build();
// When
final Iterable<Walk> results = graph.execute(op, getUser());
// Then
assertThat(Lists.newArrayList(results)).hasSize(1);
}
Aggregations