Search in sources :

Example 31 with ValidationResult

use of uk.gov.gchq.koryphe.ValidationResult in project Gaffer by gchq.

the class ViewValidatorTest method shouldValidateAndReturnTrueWhenEmptyFunctions.

@Test
public void shouldValidateAndReturnTrueWhenEmptyFunctions() {
    // Given
    final ViewValidator validator = new ViewValidator();
    final View view = new View.Builder().build();
    final Schema schema = new Schema();
    // When
    final ValidationResult result = validator.validate(view, schema, ALL_STORE_TRAITS);
    // Then
    assertTrue(result.isValid());
}
Also used : ValidationResult(uk.gov.gchq.koryphe.ValidationResult) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.jupiter.api.Test)

Example 32 with ValidationResult

use of uk.gov.gchq.koryphe.ValidationResult in project Gaffer by gchq.

the class ViewValidatorTest method shouldValidateAndReturnTrueWhenAggregatorSelectionUnknownProperty.

@Test
public void shouldValidateAndReturnTrueWhenAggregatorSelectionUnknownProperty() {
    // Given
    final ViewValidator validator = new ViewValidator();
    final View view = new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().aggregator(new ElementAggregator.Builder().select(TestPropertyNames.PROP_1).execute(new StringConcat()).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());
}
Also used : StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ElementAggregator(uk.gov.gchq.gaffer.data.element.function.ElementAggregator) Test(org.junit.jupiter.api.Test)

Example 33 with ValidationResult

use of uk.gov.gchq.koryphe.ValidationResult in project Gaffer by gchq.

the class ViewValidatorTest method shouldValidateAndReturnFalseWhenTimestampGroupByPropertyUsedInEntity.

@Test
public void shouldValidateAndReturnFalseWhenTimestampGroupByPropertyUsedInEntity() {
    // Given
    final ViewValidator validator = new ViewValidator();
    final View view = new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).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|Timestamp", 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|Timestamp").property(TestPropertyNames.PROP_2, "string|Value").build()).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("vertex").destination("vertex").directed("true").property(TestPropertyNames.PROP_2, "string|Value").build()).build();
    // When
    final ValidationResult result = validator.validate(view, schema, ALL_STORE_TRAITS);
    // Then
    assertFalse(result.isValid());
}
Also used : ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.jupiter.api.Test)

Example 34 with ValidationResult

use of uk.gov.gchq.koryphe.ValidationResult in project Gaffer by gchq.

the class ViewValidatorTest method shouldValidateAndReturnTrueWhenEntityTransientPropertyIsNotInSchema.

@Test
public void shouldValidateAndReturnTrueWhenEntityTransientPropertyIsNotInSchema() {
    // Given
    final ViewValidator validator = new ViewValidator();
    final View view = new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().transientProperty(TestPropertyNames.PROP_1, String.class).build()).build();
    final Schema schema = new Schema.Builder().type("obj", Object.class).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(TestPropertyNames.PROP_2, "obj").build()).build();
    // When
    final ValidationResult result = validator.validate(view, schema, ALL_STORE_TRAITS);
    // Then
    assertTrue(result.isValid());
}
Also used : ValidationResult(uk.gov.gchq.koryphe.ValidationResult) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.jupiter.api.Test)

Example 35 with ValidationResult

use of uk.gov.gchq.koryphe.ValidationResult in project Gaffer by gchq.

the class ViewValidatorTest method shouldValidateAndReturnTrueWhenEdgeTransformerResult.

@Test
public void shouldValidateAndReturnTrueWhenEdgeTransformerResult() {
    // 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("double", Double.class).type("int", Integer.class).type("string", String.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().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());
}
Also used : ValidationResult(uk.gov.gchq.koryphe.ValidationResult) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ExampleTransformFunction(uk.gov.gchq.gaffer.function.ExampleTransformFunction) Test(org.junit.jupiter.api.Test)

Aggregations

ValidationResult (uk.gov.gchq.koryphe.ValidationResult)132 Test (org.junit.jupiter.api.Test)86 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)32 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)27 HashMap (java.util.HashMap)13 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)12 ElementAggregator (uk.gov.gchq.gaffer.data.element.function.ElementAggregator)11 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)11 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)9 ExampleTransformFunction (uk.gov.gchq.gaffer.function.ExampleTransformFunction)9 OperationChainValidator (uk.gov.gchq.gaffer.store.operation.OperationChainValidator)9 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)8 Schema (uk.gov.gchq.gaffer.store.schema.Schema)8 Signature (uk.gov.gchq.koryphe.signature.Signature)8 Map (java.util.Map)7 OperationChainOptimiser (uk.gov.gchq.gaffer.store.optimiser.OperationChainOptimiser)7 Set (java.util.Set)6 Operation (uk.gov.gchq.gaffer.operation.Operation)6 Element (uk.gov.gchq.gaffer.data.element.Element)5 ElementTransformer (uk.gov.gchq.gaffer.data.element.function.ElementTransformer)5