Search in sources :

Example 1 with Divide

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));
}
Also used : Divide(uk.gov.gchq.koryphe.impl.function.Divide)

Example 2 with Divide

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");
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Divide(uk.gov.gchq.koryphe.impl.function.Divide) ElementTransformer(uk.gov.gchq.gaffer.data.element.function.ElementTransformer) Schema(uk.gov.gchq.gaffer.store.schema.Schema) SchemaEntityDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition) Transform(uk.gov.gchq.gaffer.operation.impl.function.Transform) TypeDefinition(uk.gov.gchq.gaffer.store.schema.TypeDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

Divide (uk.gov.gchq.koryphe.impl.function.Divide)2 Test (org.junit.jupiter.api.Test)1 Entity (uk.gov.gchq.gaffer.data.element.Entity)1 ElementTransformer (uk.gov.gchq.gaffer.data.element.function.ElementTransformer)1 Transform (uk.gov.gchq.gaffer.operation.impl.function.Transform)1 Schema (uk.gov.gchq.gaffer.store.schema.Schema)1 SchemaEntityDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition)1 TypeDefinition (uk.gov.gchq.gaffer.store.schema.TypeDefinition)1