use of uk.gov.gchq.koryphe.ValidationResult in project Gaffer by gchq.
the class ViewValidatorTest method shouldValidateAndReturnTrueWhenEdgeTransformerProjectsToUnknownProperty.
@Test
public void shouldValidateAndReturnTrueWhenEdgeTransformerProjectsToUnknownProperty() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().transformer(new ElementTransformer.Builder().select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).execute(new ExampleTransformFunction()).project(TestPropertyNames.PROP_3).build()).build()).build();
final Schema schema = new Schema.Builder().type("int", Integer.class).type("string", String.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.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
assertTrue(result.isValid());
}
use of uk.gov.gchq.koryphe.ValidationResult 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.ValidationResult in project Gaffer by gchq.
the class ViewValidatorTest method shouldValidateAndReturnFalseWhenEdgeTransientPropertyIsInSchema.
@Test
public void shouldValidateAndReturnFalseWhenEdgeTransientPropertyIsInSchema() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().transientProperty(TestPropertyNames.PROP_1, String.class).build()).build();
final Schema schema = new Schema.Builder().type("obj", Object.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().property(TestPropertyNames.PROP_1, "obj").build()).build();
// When
final ValidationResult result = validator.validate(view, schema, ALL_STORE_TRAITS);
// Then
assertFalse(result.isValid());
}
use of uk.gov.gchq.koryphe.ValidationResult in project Gaffer by gchq.
the class ViewValidatorTest method shouldValidateAndReturnFalseForOrFilterWithIncompatibleProperties.
@Test
public void shouldValidateAndReturnFalseForOrFilterWithIncompatibleProperties() {
// 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 Or.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.ValidationResult in project Gaffer by gchq.
the class ViewValidatorTest method shouldValidateAndReturnTrueForAndFilter.
@Test
public void shouldValidateAndReturnTrueForAndFilter() {
// 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 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());
}
Aggregations