use of uk.gov.gchq.gaffer.data.elementdefinition.view.View in project Gaffer by gchq.
the class GetElementsinRangesHandlerTest method shouldHaveNoIncomingEdges.
private void shouldHaveNoIncomingEdges(final AccumuloStore store) throws OperationException {
// Create set to query for
final Set<Pair<ElementSeed>> simpleEntityRanges = new HashSet<>();
final User user = new User();
//get Everything between 0 and 1 (Note we are using strings and string serialisers, with this ordering 0999 is before 1)
simpleEntityRanges.add(new Pair<ElementSeed>(new EntitySeed("0"), new EntitySeed("1")));
final View view = new View.Builder(defaultView).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy().build()).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().groupBy().build()).build();
final GetElementsInRanges<Pair<ElementSeed>, Element> operation = new GetElementsInRanges<>(view, simpleEntityRanges);
//All Edges stored should be outgoing from our provided seeds.
operation.setIncludeIncomingOutGoing(IncludeIncomingOutgoingType.INCOMING);
final GetElementsInRangesHandler handler = new GetElementsInRangesHandler();
final CloseableIterable<Element> elements = handler.doOperation(operation, user, store);
final int count = Iterables.size(elements);
//There should be no incoming edges to the provided range
assertEquals(0, count);
elements.close();
}
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);
}
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);
}
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());
}
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());
}
Aggregations