Search in sources :

Example 91 with View

use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.

the class ViewValidatorTest method shouldValidateAndReturnFalseWhenEdgeTransformerSelectionMissingProperty.

@Test
public void shouldValidateAndReturnFalseWhenEdgeTransformerSelectionMissingProperty() {
    // Given
    final ViewValidator validator = new ViewValidator();
    final View view = new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().transientProperty(TestPropertyNames.PROP_3, String.class).transformer(new ElementTransformer.Builder().select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).project(TestPropertyNames.PROP_3).execute(new ExampleTransformFunction()).build()).build()).build();
    final Schema schema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().property(TestPropertyNames.PROP_1, "obj").build()).build();
    // When
    final boolean isValid = validator.validate(view, schema, false);
    // Then
    assertFalse(isValid);
}
Also used : ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ExampleTransformFunction(uk.gov.gchq.gaffer.function.ExampleTransformFunction) Test(org.junit.Test)

Example 92 with View

use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.

the class ViewValidatorTest method shouldValidateAndReturnFalseWhenPostTransformerSelectionDoesNotExist.

@Test
public void shouldValidateAndReturnFalseWhenPostTransformerSelectionDoesNotExist() {
    // Given
    final ViewValidator validator = new ViewValidator();
    final View view = new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().transientProperty(TestPropertyNames.PROP_3, String.class).transformer(new ElementTransformer.Builder().select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).project(TestPropertyNames.PROP_3).execute(new ExampleTransformFunction()).build()).postTransformFilter(new ElementFilter.Builder().select(TestPropertyNames.TRANSIENT_1).execute(new ExampleFilterFunction()).build()).build()).build();
    final Schema schema = new Schema.Builder().type("obj", Object.class).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(TestPropertyNames.PROP_1, "obj").property(TestPropertyNames.PROP_2, "obj").build()).build();
    // When
    final boolean isValid = validator.validate(view, schema, false);
    // Then
    assertFalse(isValid);
}
Also used : ElementTransformer(uk.gov.gchq.gaffer.data.element.function.ElementTransformer) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) ExampleFilterFunction(uk.gov.gchq.gaffer.function.ExampleFilterFunction) ExampleTransformFunction(uk.gov.gchq.gaffer.function.ExampleTransformFunction) Test(org.junit.Test)

Example 93 with View

use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.

the class ViewValidatorTest method shouldValidateAndReturnFalseWhenGroupByPropertyNotInSchema.

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

Example 94 with View

use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.

the class ViewValidatorTest method shouldValidateAndReturnFalseWhenEntityTransformerProjectsToMissingProperty.

@Test
public void shouldValidateAndReturnFalseWhenEntityTransformerProjectsToMissingProperty() {
    // 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).project(TestPropertyNames.PROP_3).execute(new ExampleTransformFunction()).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 boolean isValid = validator.validate(view, schema, false);
    // Then
    assertFalse(isValid);
}
Also used : View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ExampleTransformFunction(uk.gov.gchq.gaffer.function.ExampleTransformFunction) Test(org.junit.Test)

Example 95 with View

use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.

the class ViewValidatorTest method shouldValidateAndReturnTrueWhenEdgeTransformerIsValid.

@Test
public void shouldValidateAndReturnTrueWhenEdgeTransformerIsValid() {
    // 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).project(TestPropertyNames.PROP_3).execute(new ExampleTransformFunction()).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 boolean isValid = validator.validate(view, schema, false);
    // Then
    assertTrue(isValid);
}
Also used : View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ExampleTransformFunction(uk.gov.gchq.gaffer.function.ExampleTransformFunction) Test(org.junit.Test)

Aggregations

View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)107 Test (org.junit.Test)70 Element (uk.gov.gchq.gaffer.data.element.Element)42 User (uk.gov.gchq.gaffer.user.User)38 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)32 HashSet (java.util.HashSet)29 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)28 Graph (uk.gov.gchq.gaffer.graph.Graph)20 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)19 ArrayList (java.util.ArrayList)16 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)14 Edge (uk.gov.gchq.gaffer.data.element.Edge)13 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)13 Schema (uk.gov.gchq.gaffer.store.schema.Schema)13 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)12 IsLessThan (uk.gov.gchq.gaffer.function.filter.IsLessThan)11 SQLContext (org.apache.spark.sql.SQLContext)10 ExampleTransformFunction (uk.gov.gchq.gaffer.function.ExampleTransformFunction)9 IsMoreThan (uk.gov.gchq.gaffer.function.filter.IsMoreThan)9 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)8