Search in sources :

Example 21 with IsEqual

use of uk.gov.gchq.koryphe.impl.predicate.IsEqual in project gaffer-doc by gchq.

the class IsEqualExample method isEqualToString5.

public void isEqualToString5() {
    // ---------------------------------------------------------
    final IsEqual function = new IsEqual("5");
    // ---------------------------------------------------------
    runExample(function, null, 5, 5L, "5", '5');
}
Also used : IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual)

Example 22 with IsEqual

use of uk.gov.gchq.koryphe.impl.predicate.IsEqual in project gaffer-doc by gchq.

the class IsEqualExample method isEqualLong5.

public void isEqualLong5() {
    // ---------------------------------------------------------
    final IsEqual function = new IsEqual(5L);
    // ---------------------------------------------------------
    runExample(function, null, 5, 5L, "5", '5');
}
Also used : IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual)

Example 23 with IsEqual

use of uk.gov.gchq.koryphe.impl.predicate.IsEqual in project gaffer-doc by gchq.

the class OrExample method isLessThan2EqualTo5OrIsMoreThan10.

public void isLessThan2EqualTo5OrIsMoreThan10() {
    // ---------------------------------------------------------
    final Or function = new Or<>(new IsLessThan(2), new IsEqual(5), new IsMoreThan(10));
    // ---------------------------------------------------------
    runExample(function, "When using an Or predicate with a single selected value you can just use the constructor new Or(predicates))'", 1, 2, 3, 5, 15, 1L, 3L, 5L);
}
Also used : Or(uk.gov.gchq.koryphe.impl.predicate.Or) IsLessThan(uk.gov.gchq.koryphe.impl.predicate.IsLessThan) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual)

Example 24 with IsEqual

use of uk.gov.gchq.koryphe.impl.predicate.IsEqual in project Gaffer by gchq.

the class ViewValidatorTest method shouldValidateAndReturnFalseForNotFilterWithIncompatibleProperties.

@Test
public void shouldValidateAndReturnFalseForNotFilterWithIncompatibleProperties() {
    // Given
    final ViewValidator validator = new ViewValidator();
    final View view = new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).execute(new Not<>(new Or.Builder<>().select(0).execute(new IsMoreThan("abcd")).select(1).execute(new IsEqual("some other value")).build())).build()).build()).build();
    final Schema schema = new Schema.Builder().type("int", Integer.class).type("string", String.class).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(TestPropertyNames.PROP_1, "int").property(TestPropertyNames.PROP_2, "string").build()).build();
    // When
    final ValidationResult result = validator.validate(view, schema, ALL_STORE_TRAITS);
    // Then
    assertFalse(result.isValid());
}
Also used : ValidationResult(uk.gov.gchq.koryphe.ValidationResult) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) Not(uk.gov.gchq.koryphe.impl.predicate.Not) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) Test(org.junit.jupiter.api.Test)

Example 25 with IsEqual

use of uk.gov.gchq.koryphe.impl.predicate.IsEqual in project Gaffer by gchq.

the class ViewValidatorTest method shouldValidateAndReturnFalseForAndFilterWithIncompatibleProperties.

@Test
public void shouldValidateAndReturnFalseForAndFilterWithIncompatibleProperties() {
    // Given
    final ViewValidator validator = new ViewValidator();
    final View view = new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).execute(new And.Builder().select(0).execute(new IsMoreThan(2)).select(1).execute(new IsEqual("some other value")).build()).build()).build()).build();
    final Schema schema = new Schema.Builder().type("obj", Object.class).type("string", String.class).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(TestPropertyNames.PROP_1, "obj").property(TestPropertyNames.PROP_2, "string").build()).build();
    // When
    final ValidationResult result = validator.validate(view, schema, ALL_STORE_TRAITS);
    // Then
    assertFalse(result.isValid());
}
Also used : ValidationResult(uk.gov.gchq.koryphe.ValidationResult) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) And(uk.gov.gchq.koryphe.impl.predicate.And) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) Test(org.junit.jupiter.api.Test)

Aggregations

IsEqual (uk.gov.gchq.koryphe.impl.predicate.IsEqual)32 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)20 Test (org.junit.jupiter.api.Test)18 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)16 Element (uk.gov.gchq.gaffer.data.element.Element)12 IsMoreThan (uk.gov.gchq.koryphe.impl.predicate.IsMoreThan)10 Test (org.junit.Test)7 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)7 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)7 Entity (uk.gov.gchq.gaffer.data.element.Entity)6 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)6 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)6 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)6 ValidationResult (uk.gov.gchq.koryphe.ValidationResult)6 IsLessThan (uk.gov.gchq.koryphe.impl.predicate.IsLessThan)6 Or (uk.gov.gchq.koryphe.impl.predicate.Or)6 Graph (uk.gov.gchq.gaffer.graph.Graph)5 ElementId (uk.gov.gchq.gaffer.data.element.id.ElementId)4 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)4 User (uk.gov.gchq.gaffer.user.User)4