use of uk.gov.gchq.gaffer.function.context.ConsumerProducerFunctionContext in project Gaffer by gchq.
the class ViewIT method shouldDeserialiseJsonView.
@Test
public void shouldDeserialiseJsonView() throws IOException {
// Given
// When
View view = loadView();
// Then
final ViewElementDefinition edge = view.getEdge(TestGroups.EDGE);
final ElementTransformer transformer = edge.getTransformer();
assertNotNull(transformer);
final List<ConsumerProducerFunctionContext<String, TransformFunction>> contexts = transformer.getFunctions();
assertEquals(1, contexts.size());
final List<String> selection = contexts.get(0).getSelection();
assertEquals(2, selection.size());
assertEquals(TestPropertyNames.PROP_1, selection.get(0));
assertEquals(IdentifierType.SOURCE.name(), selection.get(1));
final List<String> projection = contexts.get(0).getProjection();
assertEquals(1, projection.size());
assertEquals(TestPropertyNames.TRANSIENT_1, projection.get(0));
assertTrue(contexts.get(0).getFunction() instanceof ExampleTransformFunction);
final ElementFilter postFilter = edge.getPostTransformFilter();
assertNotNull(postFilter);
final List<ConsumerFunctionContext<String, FilterFunction>> filterContexts = postFilter.getFunctions();
assertEquals(1, contexts.size());
final List<String> postFilterSelection = filterContexts.get(0).getSelection();
assertEquals(1, postFilterSelection.size());
assertEquals(TestPropertyNames.TRANSIENT_1, postFilterSelection.get(0));
assertTrue(filterContexts.get(0).getFunction() instanceof ExampleFilterFunction);
}
use of uk.gov.gchq.gaffer.function.context.ConsumerProducerFunctionContext in project Gaffer by gchq.
the class Transformer method cloneFunctions.
/**
* Create a deep copy of the {@link uk.gov.gchq.gaffer.function.context.ConsumerProducerFunctionContext}s executed by this
* <code>Transformer</code>.
*
* @return Deep copy of {@link uk.gov.gchq.gaffer.function.context.ConsumerProducerFunctionContext}s.
*/
protected List<ConsumerProducerFunctionContext<R, TransformFunction>> cloneFunctions() {
final List<ConsumerProducerFunctionContext<R, TransformFunction>> functionClones = new ArrayList<>();
for (final ConsumerProducerFunctionContext<R, TransformFunction> function : functions) {
ConsumerProducerFunctionContext<R, TransformFunction> cloneContext = new ConsumerProducerFunctionContext<>();
cloneContext.setSelection(function.getSelection());
cloneContext.setProjection(function.getProjection());
TransformFunction af = function.getFunction();
if (af != null) {
cloneContext.setFunction(af.statelessClone());
}
functionClones.add(cloneContext);
}
return functionClones;
}
Aggregations