Search in sources :

Example 26 with View

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

the class ElementValidatorTest method shouldReturnFalseWhenViewValidateWithInvalidElement.

@Test
public void shouldReturnFalseWhenViewValidateWithInvalidElement() {
    // Given
    final View view = mock(View.class);
    final String group = TestGroups.EDGE;
    final Element elm = mock(Element.class);
    final ViewElementDefinition elementDef = mock(ViewElementDefinition.class);
    final ElementFilter filter = mock(ElementFilter.class);
    final ElementValidator validator = new ElementValidator(view);
    given(elm.getGroup()).willReturn(group);
    given(view.getElement(group)).willReturn(elementDef);
    given(elementDef.getPreAggregationFilter()).willReturn(filter);
    given(filter.filter(elm)).willReturn(false);
    // When
    final boolean isValid = validator.validate(elm);
    // Then
    assertFalse(isValid);
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test)

Example 27 with View

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

the class ElementValidatorTest method shouldReturnFalseWhenNoViewElementDefinition.

@Test
public void shouldReturnFalseWhenNoViewElementDefinition() {
    // Given
    final View view = mock(View.class);
    final String group = TestGroups.EDGE;
    final Element elm = mock(Element.class);
    final ElementValidator validator = new ElementValidator(view);
    given(elm.getGroup()).willReturn(group);
    given(view.getElement(group)).willReturn(null);
    // When
    final boolean isValid = validator.validate(elm);
    // Then
    assertFalse(isValid);
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test)

Example 28 with View

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

the class ValidateTest method builderShouldCreatePopulatedOperation.

@Test
@Override
public void builderShouldCreatePopulatedOperation() {
    Element edge = new Edge("testGroup");
    Validate validate = new Validate.Builder().elements(Arrays.asList(edge)).skipInvalidElements(true).view(new View.Builder().edge("testEdgeGroup").build()).option("testOption", "true").build();
    assertEquals("true", validate.getOption("testOption"));
    assertTrue(validate.isSkipInvalidElements());
    assertEquals(edge, validate.getInput().iterator().next());
    assertNotNull(validate.getView());
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) Edge(uk.gov.gchq.gaffer.data.element.Edge) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.Test)

Example 29 with View

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

the class GenerateElementsTest method builderShouldCreatePopulatedOperation.

@Test
@Override
public void builderShouldCreatePopulatedOperation() {
    GenerateElements generateElements = new GenerateElements.Builder<String>().generator(new ElementGeneratorImpl()).objects(Arrays.asList("Test1", "Test2")).view(new View.Builder().edge("TestEdgeGroup").build()).option("testOption", "true").build();
    assertNotNull(generateElements.getView());
    assertEquals("true", generateElements.getOption("testOption"));
    Iterator iter = generateElements.getInput().iterator();
    assertEquals("Test1", iter.next());
    assertEquals("Test2", iter.next());
}
Also used : ElementGeneratorImpl(uk.gov.gchq.gaffer.data.generator.ElementGeneratorImpl) Iterator(java.util.Iterator) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.Test)

Example 30 with View

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

the class AbstractGetIterableOperationTest method shouldCopyFieldsFromGivenOperationWhenConstructing.

@Test
public void shouldCopyFieldsFromGivenOperationWhenConstructing() {
    // Given
    final GetIterableOperation<ElementSeed, ?> operationToCopy = mock(GetIterableOperation.class);
    final View view = mock(View.class);
    final GetOperation.IncludeEdgeType includeEdges = GetOperation.IncludeEdgeType.ALL;
    final boolean includeEntities = true;
    final boolean populateProperties = true;
    final CloseableIterable<ElementSeed> input = mock(CloseableIterable.class);
    given(operationToCopy.getView()).willReturn(view);
    given(operationToCopy.getInput()).willReturn(input);
    // When
    final GetIterableOperationImpl<ElementSeed, Element> operation = new GetIterableOperationImpl<>(operationToCopy);
    // Then
    assertSame(view, operation.getView());
    assertSame(input, operation.getInput());
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) GetIterableOperationImpl(uk.gov.gchq.gaffer.operation.impl.GetIterableOperationImpl) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) 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