Search in sources :

Example 1 with Not

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

the class NotExample method areNotEqual.

public void areNotEqual() {
    // ---------------------------------------------------------
    final Not function = new Not<>(new AreEqual());
    // ---------------------------------------------------------
    runExample(function, null, new Tuple2<>(1, 1.0), new Tuple2<>(1, 2), new Tuple2<>(2.5, 2.5), new Tuple2<>("", null), new Tuple2<>("abc", "abc"));
}
Also used : Not(uk.gov.gchq.koryphe.impl.predicate.Not) AreEqual(uk.gov.gchq.koryphe.impl.predicate.AreEqual)

Example 2 with Not

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

the class ElementFilterTest method shouldExecuteNotPredicates.

@Test
public void shouldExecuteNotPredicates() {
    final ElementFilter filter = new ElementFilter.Builder().select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).execute(new Not<>(new Or.Builder<>().select(0).execute(new IsMoreThan(2)).select(1).execute(new IsEqual("some value")).build())).build();
    final Entity element1 = makeEntity(3, "some value");
    final Entity element2 = makeEntity(1, "some value");
    final Entity element3 = makeEntity(3, "some invalid value");
    final Entity element4 = makeEntity(1, "some invalid value");
    // When
    final boolean result1 = filter.test(element1);
    final boolean result2 = filter.test(element2);
    final boolean result3 = filter.test(element3);
    final boolean result4 = filter.test(element4);
    // Then
    assertFalse(result1);
    assertFalse(result2);
    assertFalse(result3);
    assertTrue(result4);
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Not(uk.gov.gchq.koryphe.impl.predicate.Not) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 3 with Not

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

the class ViewValidatorTest method shouldValidateAndReturnTrueForNotFilter.

@Test
public void shouldValidateAndReturnTrueForNotFilter() {
    // 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 IsEqual("some value")).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
    assertTrue(result.isValid(), result.getErrorString());
}
Also used : Not(uk.gov.gchq.koryphe.impl.predicate.Not) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) Test(org.junit.jupiter.api.Test)

Example 4 with Not

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

the class NotExample method doesNotExist.

public void doesNotExist() {
    // ---------------------------------------------------------
    final Not function = new Not<>(new Exists());
    // ---------------------------------------------------------
    runExample(function, null, 1, null, "", "abc");
}
Also used : Not(uk.gov.gchq.koryphe.impl.predicate.Not) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists)

Example 5 with Not

use of uk.gov.gchq.koryphe.impl.predicate.Not 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)

Aggregations

Not (uk.gov.gchq.koryphe.impl.predicate.Not)6 Test (org.junit.jupiter.api.Test)3 IsEqual (uk.gov.gchq.koryphe.impl.predicate.IsEqual)3 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)2 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)2 ValidationResult (uk.gov.gchq.koryphe.ValidationResult)2 IsMoreThan (uk.gov.gchq.koryphe.impl.predicate.IsMoreThan)2 List (java.util.List)1 Predicate (java.util.function.Predicate)1 FilterPredicate (org.apache.parquet.filter2.predicate.FilterPredicate)1 JSONSerialisationTest (uk.gov.gchq.gaffer.JSONSerialisationTest)1 Entity (uk.gov.gchq.gaffer.data.element.Entity)1 AgeOff (uk.gov.gchq.koryphe.impl.predicate.AgeOff)1 And (uk.gov.gchq.koryphe.impl.predicate.And)1 AreEqual (uk.gov.gchq.koryphe.impl.predicate.AreEqual)1 Exists (uk.gov.gchq.koryphe.impl.predicate.Exists)1 Or (uk.gov.gchq.koryphe.impl.predicate.Or)1 TupleAdaptedPredicate (uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicate)1