use of uk.gov.gchq.koryphe.ValidationResult in project Gaffer by gchq.
the class ViewValidatorTest method shouldValidateAndReturnTrueWhenEntityTransformerProjectsToUnknownProperty.
@Test
public void shouldValidateAndReturnTrueWhenEntityTransformerProjectsToUnknownProperty() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().entity(TestGroups.ENTITY, 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("string", Object.class).type("int", Object.class).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(TestPropertyNames.PROP_1, "string").property(TestPropertyNames.PROP_2, "int").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 shouldValidateAndReturnTrueWhenEntityFilterSelectionUnknownProperty.
@Test
public void shouldValidateAndReturnTrueWhenEntityFilterSelectionUnknownProperty() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().transientProperty(TestPropertyNames.PROP_3, String.class).preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new ExampleFilterFunction()).build()).build()).build();
final Schema schema = new Schema.Builder().entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().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 shouldValidateAndReturnTrueWhenEdgeFilterSelectionUnknownProperty.
@Test
public void shouldValidateAndReturnTrueWhenEdgeFilterSelectionUnknownProperty() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().transientProperty(TestPropertyNames.PROP_3, String.class).preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new ExampleFilterFunction()).build()).build()).build();
final Schema schema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().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 shouldValidateAndReturnTrueWhenGroupByPropertiesInSchema.
@Test
public void shouldValidateAndReturnTrueWhenGroupByPropertiesInSchema() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy(TestPropertyNames.PROP_1).build()).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().groupBy(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).build()).build();
final Schema schema = new Schema.Builder().type("vertex", String.class).type("string|ColumnQualifier", new TypeDefinition.Builder().clazz(String.class).build()).type("string|Value", new TypeDefinition.Builder().clazz(String.class).build()).type("true", Boolean.class).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().vertex("vertex").property(TestPropertyNames.PROP_1, "string|ColumnQualifier").property(TestPropertyNames.PROP_2, "string|ColumnQualifier").property(TestPropertyNames.PROP_3, "string|Value").groupBy(TestPropertyNames.PROP_1).build()).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("vertex").destination("vertex").directed("true").property(TestPropertyNames.PROP_1, "string|ColumnQualifier").property(TestPropertyNames.PROP_2, "string|ColumnQualifier").property(TestPropertyNames.PROP_3, "string|Value").groupBy(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).build()).visibilityProperty(TestPropertyNames.PROP_2).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 shouldValidateAndReturnTrueForOrFilter.
@Test
public void shouldValidateAndReturnTrueForOrFilter() {
// 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 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