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"));
}
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);
}
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());
}
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");
}
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());
}
Aggregations