use of uk.gov.gchq.gaffer.data.element.id.EdgeId 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.EdgeId in project Gaffer by gchq.
the class ExportIT method createEdges.
/**
* Adds edges dest[X] -> source[X+1]
*
* @return map of edges
*/
@Override
protected Map<EdgeId, Edge> createEdges() {
final Map<EdgeId, Edge> edges = super.createEdges();
for (int i = 0; i <= 10; i++) {
final Edge thirdEdge = new Edge.Builder().group(TestGroups.EDGE).source(DEST_DIR + i).dest(SOURCE_DIR + (i + 1)).directed(true).build();
thirdEdge.putProperty(TestPropertyNames.INT, 1);
thirdEdge.putProperty(TestPropertyNames.COUNT, 1L);
addToMap(thirdEdge, edges);
}
return edges;
}
use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.
the class ElementIdSerialiserTest method testCanSerialiseEdgeId.
@Test
public void testCanSerialiseEdgeId() throws SerialisationException {
// Given
final EdgeId edgeId = new EdgeSeed("source", "destination", true);
// When
final byte[] serialisedEdgeId = serialiser.serialise(edgeId);
final ElementId deserialisedEdgeId = serialiser.deserialise(serialisedEdgeId);
// Then
assertEquals(edgeId, deserialisedEdgeId);
}
use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.
the class EntitySeedTest method shouldBeRelatedToEdgeIdWhenSourceAndVertexAreNull.
@Test
public void shouldBeRelatedToEdgeIdWhenSourceAndVertexAreNull() {
// Given
final String source = null;
final String destination = "destination";
final EntityId seed = new EntitySeed(destination);
final EdgeId relatedSeed = mock(EdgeId.class);
given(relatedSeed.getSource()).willReturn(source);
given(relatedSeed.getDestination()).willReturn(destination);
// Then
assertTrue(seed.isRelated((ElementId) relatedSeed).isMatch());
}
use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.
the class EntitySeedTest method shouldBeRelatedToEdgeIdWhenDestinationAndVertexAreNull.
@Test
public void shouldBeRelatedToEdgeIdWhenDestinationAndVertexAreNull() {
// Given
final String source = "source";
final String destination = null;
final EntityId seed = new EntitySeed(destination);
final EdgeId relatedSeed = mock(EdgeId.class);
given(relatedSeed.getSource()).willReturn(source);
given(relatedSeed.getDestination()).willReturn(destination);
// Then
assertTrue(seed.isRelated((ElementId) relatedSeed).isMatch());
}
Aggregations