use of uk.gov.gchq.koryphe.impl.function.Divide in project gaffer-doc by gchq.
the class DivideExample method divideInputs.
public void divideInputs() {
// ---------------------------------------------------------
final Divide function = new Divide();
// ---------------------------------------------------------
runExample(function, null, new Tuple2<>(6, 2), new Tuple2<>(6, 4), new Tuple2<>(6, 8), new Tuple2<>(null, 2), new Tuple2<>(6, null), new Tuple2<>(6.1, 2.1));
}
use of uk.gov.gchq.koryphe.impl.function.Divide in project Gaffer by gchq.
the class TransformHandlerTest method shouldFailValidationWhenFunctionSignatureIsInvalid.
@Test
public void shouldFailValidationWhenFunctionSignatureIsInvalid() {
// Given
final Schema schema = new Schema.Builder().entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(TestPropertyNames.PROP_1, TestPropertyNames.STRING).build()).type(TestPropertyNames.STRING, new TypeDefinition(String.class)).build();
given(store.getSchema()).willReturn(schema);
final Entity entity = new Entity.Builder().group(TestGroups.ENTITY).property(TestPropertyNames.PROP_1, TestPropertyNames.INT).property(TestPropertyNames.PROP_2, TestPropertyNames.STRING).build();
final Entity entity1 = new Entity.Builder().group(TestGroups.ENTITY).property(TestPropertyNames.PROP_1, TestPropertyNames.INT).build();
final ElementTransformer transformer = new ElementTransformer.Builder().select(TestPropertyNames.PROP_1).execute(new Divide()).project(TestPropertyNames.PROP_3).build();
input.add(entity);
input.add(entity1);
final Transform transform = new Transform.Builder().input(input).entity(TestGroups.ENTITY, transformer).build();
// When / Then
assertThatExceptionOfType(OperationException.class).isThrownBy(() -> handler.doOperation(transform, context, store)).withMessageContaining("Incompatible number of types");
}
Aggregations