use of uk.gov.gchq.gaffer.data.element.id.EntityId in project Gaffer by gchq.
the class UnwrapEntityIdTest method shouldUnwrapEntityIds.
@Test
public void shouldUnwrapEntityIds() {
final EntityId value = mock(EntityId.class);
final Object vertex = mock(Object.class);
given(value.getVertex()).willReturn(vertex);
final UnwrapEntityId function = new UnwrapEntityId();
final Object result = function.apply(value);
assertSame(vertex, result);
}
use of uk.gov.gchq.gaffer.data.element.id.EntityId in project Gaffer by gchq.
the class GetAdjacentIdsTest method builderShouldCreatePopulatedOperationIncoming.
private void builderShouldCreatePopulatedOperationIncoming() {
EntityId seed = new EntitySeed("A");
GetAdjacentIds op = new GetAdjacentIds.Builder().input(seed).inOutType(IncludeIncomingOutgoingType.INCOMING).view(new View.Builder().edge("testEdgeGroup").build()).build();
assertEquals(IncludeIncomingOutgoingType.INCOMING, op.getIncludeIncomingOutGoing());
assertNotNull(op.getView());
assertThat(op.getInput().iterator().next()).isEqualTo(seed);
}
use of uk.gov.gchq.gaffer.data.element.id.EntityId in project Gaffer by gchq.
the class GetAdjacentIdsTest method shouldSetIncludeIncomingOutgoingTypeToBoth.
@Test
public void shouldSetIncludeIncomingOutgoingTypeToBoth() {
final EntityId elementId = new EntitySeed("identifier");
// When
final GetAdjacentIds op = new GetAdjacentIds.Builder().input(elementId).inOutType(IncludeIncomingOutgoingType.EITHER).build();
// Then
assertEquals(IncludeIncomingOutgoingType.EITHER, op.getIncludeIncomingOutGoing());
}
use of uk.gov.gchq.gaffer.data.element.id.EntityId in project Gaffer by gchq.
the class GetElementsIT method getElements.
private static Collection<Element> getElements(final Collection<ElementId> seeds, final Boolean direction) {
final Set<Element> elements = new HashSet<>(seeds.size());
for (final ElementId seed : seeds) {
if (seed instanceof EntityId) {
final Entity entity = new Entity(TestGroups.ENTITY, ((EntityId) seed).getVertex());
entity.putProperty(TestPropertyNames.COUNT, 1L);
entity.putProperty(TestPropertyNames.SET, CollectionUtil.treeSet("3"));
elements.add(entity);
} else {
if (DirectedType.isEither(((EdgeId) seed).getDirectedType())) {
if (BooleanUtils.isNotTrue(direction)) {
final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(((EdgeId) seed).getSource()).dest(((EdgeId) seed).getDestination()).matchedVertex(((EdgeId) seed).getMatchedVertex()).directed(false).property(TestPropertyNames.INT, 1).property(TestPropertyNames.COUNT, 1L).build();
elements.add(edge);
}
if (BooleanUtils.isNotFalse(direction)) {
final Edge edgeDir = new Edge.Builder().group(TestGroups.EDGE).source(((EdgeId) seed).getSource()).dest(((EdgeId) seed).getDestination()).matchedVertex(((EdgeId) seed).getMatchedVertex()).directed(true).property(TestPropertyNames.INT, 1).property(TestPropertyNames.COUNT, 1L).build();
elements.add(edgeDir);
}
} else {
final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(((EdgeId) seed).getSource()).dest(((EdgeId) seed).getDestination()).directed(((EdgeId) seed).isDirected()).matchedVertex(((EdgeId) seed).getMatchedVertex()).property(TestPropertyNames.INT, 1).property(TestPropertyNames.COUNT, 1L).build();
elements.add(edge);
}
}
}
return elements;
}
use of uk.gov.gchq.gaffer.data.element.id.EntityId in project Gaffer by gchq.
the class GraphHooksIT method shouldResolveNamedViewWithinNamedOperation.
@Test
public void shouldResolveNamedViewWithinNamedOperation() throws OperationException {
// Given
final Edge edge1 = getEdges().get(new EdgeSeed(SOURCE_1, DEST_1, false)).emptyClone();
edge1.putProperty(TestPropertyNames.INT, 100);
final Edge edge2 = edge1.emptyClone();
edge2.putProperty(TestPropertyNames.INT, 101);
graph.execute(new AddElements.Builder().input(edge1, edge2).build(), getUser());
final AddNamedView addNamedView = new AddNamedView.Builder().name("Test View").view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsIn(Arrays.asList((Object) 100))).build()).build()).build()).overwrite(true).build();
graph.execute(addNamedView, getUser());
final AddNamedOperation addNamedOperation = new AddNamedOperation.Builder().operationChain(new OperationChain.Builder().first(new GetAllElements.Builder().view(new NamedView.Builder().name("Test View").build()).build()).build()).description("named operation GetAllElements test query").name("GetAllElements test").labels(Arrays.asList("label 1", "Label 2")).overwrite(true).build();
graph.execute(addNamedOperation, getUser());
final NamedOperation<EntityId, CloseableIterable<? extends Element>> operation = new NamedOperation.Builder<EntityId, CloseableIterable<? extends Element>>().name("GetAllElements test").input(new EntitySeed("10")).build();
// When
final CloseableIterable<? extends Element> results = graph.execute(operation, getUser());
// Then
final List<Element> resultList = Lists.newArrayList(results);
assertThat(resultList).hasSize(1).contains((Element) edge1);
}
Aggregations