Search in sources :

Example 66 with EntityId

use of uk.gov.gchq.gaffer.data.element.id.EntityId 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);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 67 with EntityId

use of uk.gov.gchq.gaffer.data.element.id.EntityId 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);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 68 with EntityId

use of uk.gov.gchq.gaffer.data.element.id.EntityId in project Gaffer by gchq.

the class EntityIdExtractorTest method shouldGetOppositeMatchedVertexFromEdge.

@Test
public void shouldGetOppositeMatchedVertexFromEdge() {
    // Given
    final EntityIdExtractor extractor = new EntityIdExtractor(IdentifierType.ADJACENT_MATCHED_VERTEX);
    final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source("1").dest("2").directed(false).build();
    // When
    final EntityId seed = extractor._apply(edge);
    // Then
    assertEquals("2", seed.getVertex());
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntityIdExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.jupiter.api.Test)

Example 69 with EntityId

use of uk.gov.gchq.gaffer.data.element.id.EntityId in project Gaffer by gchq.

the class EntityIdExtractorTest method shouldGetMatchedVertexFromEdge.

@Test
public void shouldGetMatchedVertexFromEdge() {
    // Given
    final EntityIdExtractor extractor = new EntityIdExtractor(IdentifierType.MATCHED_VERTEX);
    final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source("1").dest("2").directed(false).build();
    // When
    final EntityId seed = extractor._apply(edge);
    // Then
    assertEquals("1", seed.getVertex());
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntityIdExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.jupiter.api.Test)

Example 70 with EntityId

use of uk.gov.gchq.gaffer.data.element.id.EntityId in project Gaffer by gchq.

the class EntityIdExtractorTest method shouldGetDestinationFromEdge.

@Test
public void shouldGetDestinationFromEdge() {
    // Given
    final EntityIdExtractor extractor = new EntityIdExtractor(IdentifierType.DESTINATION);
    final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source("1").dest("2").directed(false).build();
    // When
    final EntityId seed = extractor._apply(edge);
    // Then
    assertEquals("2", seed.getVertex());
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntityIdExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.jupiter.api.Test)

Aggregations

EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)93 Test (org.junit.jupiter.api.Test)60 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)41 HashSet (java.util.HashSet)22 User (uk.gov.gchq.gaffer.user.User)21 JSONSerialisationTest (uk.gov.gchq.gaffer.JSONSerialisationTest)15 Entity (uk.gov.gchq.gaffer.data.element.Entity)15 EdgeId (uk.gov.gchq.gaffer.data.element.id.EdgeId)15 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)15 Edge (uk.gov.gchq.gaffer.data.element.Edge)14 Element (uk.gov.gchq.gaffer.data.element.Element)14 ElementId (uk.gov.gchq.gaffer.data.element.id.ElementId)14 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)13 GetAdjacentIds (uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds)13 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)12 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)10 ArrayList (java.util.ArrayList)8 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)7 Graph (uk.gov.gchq.gaffer.graph.Graph)7 Context (uk.gov.gchq.gaffer.store.Context)7