use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan in project Gaffer by gchq.
the class SchemaElementDefinitionValidatorTest method shouldValidateFunctionSelectionsAndReturnFalseWhenFunctionTypeDoesNotEqualSelectionType.
@Test
public void shouldValidateFunctionSelectionsAndReturnFalseWhenFunctionTypeDoesNotEqualSelectionType() {
// Given
final SchemaElementDefinition elementDef = mock(SchemaElementDefinition.class);
given(elementDef.getPropertyClass("selection")).willReturn((Class) String.class);
final IsMoreThan function = new IsMoreThan(5);
final ElementFilter elementFilter = new ElementFilter.Builder().select("selection").execute(function).build();
final SchemaElementDefinitionValidator validator = new SchemaElementDefinitionValidator();
// When
final ValidationResult result = validator.validateFunctionArgumentTypes(elementFilter, elementDef);
// Then
assertFalse(result.isValid());
assertEquals("Validation errors: \nControl value class java.lang.Integer is not compatible" + " with the input type: class java.lang.String", result.getErrorString());
}
use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan 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());
}
use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan 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());
}
use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan in project Gaffer by gchq.
the class ViewValidatorTest method shouldValidateAndReturnTrueWithMatchedVertexFilter.
@Test
public void shouldValidateAndReturnTrueWithMatchedVertexFilter() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(IdentifierType.MATCHED_VERTEX.name()).execute(new IsMoreThan("testValue1")).build()).postAggregationFilter(new ElementFilter.Builder().select(IdentifierType.ADJACENT_MATCHED_VERTEX.name()).execute(new IsMoreThan("testValue2")).build()).postTransformFilter(new ElementFilter.Builder().select(IdentifierType.MATCHED_VERTEX.name()).execute(new IsMoreThan("testValue3")).build()).build()).build();
Schema schema = new Schema.Builder().type("double", Double.class).type("int", Integer.class).type("string", String.class).type("true", Boolean.class).type("vertex", String.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("vertex").destination("vertex").directed("true").property(TestPropertyNames.PROP_1, "double").property(TestPropertyNames.PROP_2, "int").property(TestPropertyNames.PROP_3, "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.IsMoreThan in project Gaffer by gchq.
the class FilterTest method builderShouldCreatePopulatedOperation.
@Test
@Override
public void builderShouldCreatePopulatedOperation() {
// Given
final Filter filter = new Filter.Builder().input(new Entity("road"), new Edge("railway")).entity("road", new ElementFilter.Builder().select("count").execute(new IsMoreThan(10)).build()).entity("road2", new ElementFilter.Builder().select("count").execute(new IsMoreThan(20)).build()).build();
// Then
assertNotNull(filter.getInput());
}
Aggregations