use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.
the class AbstractStoreIT method createDefaultEdges.
public static Map<EdgeId, Edge> createDefaultEdges() {
final Map<EdgeId, Edge> edges = new HashMap<>();
for (int i = 0; i <= 10; i++) {
for (int j = 0; j < VERTEX_PREFIXES.length; j++) {
final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(VERTEX_PREFIXES[0] + i).dest(VERTEX_PREFIXES[j] + i).directed(false).property(TestPropertyNames.INT, 1).property(TestPropertyNames.COUNT, 1L).build();
addToMap(edge, edges);
final Edge edgeDir = new Edge.Builder().group(TestGroups.EDGE).source(VERTEX_PREFIXES[0] + i).dest(VERTEX_PREFIXES[j] + i).directed(true).property(TestPropertyNames.INT, 1).property(TestPropertyNames.COUNT, 1L).build();
addToMap(edgeDir, edges);
}
final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(SOURCE + i).dest(DEST + i).directed(false).property(TestPropertyNames.INT, 1).property(TestPropertyNames.COUNT, 1L).build();
addToMap(edge, edges);
final Edge edgeDir = new Edge.Builder().group(TestGroups.EDGE).source(SOURCE_DIR + i).dest(DEST_DIR + i).directed(true).build();
edgeDir.putProperty(TestPropertyNames.INT, 1);
edgeDir.putProperty(TestPropertyNames.COUNT, 1L);
addToMap(edgeDir, edges);
}
return edges;
}
use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.
the class EdgeSeedTest method shouldBeRelatedToEdgeId.
@Test
public void shouldBeRelatedToEdgeId() {
// Given
final String source = "source";
final String destination = "destination";
final boolean directed = true;
final EdgeId seed1 = new EdgeSeed(source, destination, directed);
final EdgeId seed2 = new EdgeSeed(source, destination, directed);
// When
final boolean isRelated = seed1.isRelated(seed2).isMatch();
// Then
assertTrue(isRelated);
}
use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.
the class EdgeSeedTest method shouldNotBeRelatedToEntityIdWhenIdentifierNotEqualToSourceOrDestination.
@Test
public void shouldNotBeRelatedToEntityIdWhenIdentifierNotEqualToSourceOrDestination() {
// Given
final String source = "source";
final String destination = "destination";
final boolean directed = true;
final EdgeId seed = new EdgeSeed(source, destination, directed);
final EntityId unrelatedSeed = mock(EntityId.class);
given(unrelatedSeed.getVertex()).willReturn("other identifier");
// When
final boolean isRelated = seed.isRelated((ElementId) unrelatedSeed).isMatch();
// Then
assertFalse(isRelated);
}
use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.
the class EdgeSeedTest method shouldBeEqualWhenUndirectedAndSourceAndDestinationFlipped.
@Test
public void shouldBeEqualWhenUndirectedAndSourceAndDestinationFlipped() {
// Given
final String source = "source";
final String destination = "destination";
final EdgeId seed1 = new EdgeSeed(source, destination, false);
final EdgeId seed2 = new EdgeSeed(destination, source, false);
// When
final boolean isEqual = seed1.equals(seed2);
// Then
assertTrue(isEqual);
assertEquals(seed1.hashCode(), seed2.hashCode());
}
use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.
the class EdgeSeedTest method shouldBeRelatedToEntityIdWhenDestinationEqualsVertex.
@Test
public void shouldBeRelatedToEntityIdWhenDestinationEqualsVertex() {
// Given
final String source = "source";
final String destination = "destination";
final boolean directed = true;
final EdgeId seed = new EdgeSeed(source, destination, directed);
final EntityId relatedSeed = mock(EntityId.class);
given(relatedSeed.getVertex()).willReturn(destination);
// When
final boolean isRelated = seed.isRelated((ElementId) relatedSeed).isMatch();
// Then
assertTrue(isRelated);
}
Aggregations