Search in sources :

Example 21 with EntityId

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

the class EdgeSeedTest method shouldBeRelatedToEntityIdWhenSourceAndVertexAreNull.

@Test
public void shouldBeRelatedToEntityIdWhenSourceAndVertexAreNull() {
    // Given
    final String source = null;
    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(source);
    // 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 22 with EntityId

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

the class GetWalksTest method builderShouldCreatePopulatedOperation.

@Test
@Override
public void builderShouldCreatePopulatedOperation() {
    // Given
    final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new GetElements()).resultsLimit(100).build();
    // Then
    Assertions.<EntityId>assertThat(getWalks.getInput()).hasSize(2).containsOnly(new EntitySeed("1"), new EntitySeed("2"));
    assertThat(getWalks.getResultsLimit()).isEqualTo(100);
    assertThat(getWalks.getOperations()).hasSize(1);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 23 with EntityId

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

the class EntityIdExtractorTest method shouldGetSourceFromEdge.

@Test
public void shouldGetSourceFromEdge() {
    // Given
    final EntityIdExtractor extractor = new EntityIdExtractor(IdentifierType.SOURCE);
    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 24 with EntityId

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

the class EntityIdExtractorTest method shouldGetIdentifierFromEntity.

@Test
public void shouldGetIdentifierFromEntity() {
    // Given
    final EntityIdExtractor extractor = new EntityIdExtractor();
    final Entity entity = new Entity.Builder().group(TestGroups.ENTITY).vertex("identifier").build();
    // When
    final EntityId seed = extractor._apply(entity);
    // Then
    assertSame("identifier", seed.getVertex());
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntityIdExtractor(uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor) Entity(uk.gov.gchq.gaffer.data.element.Entity) Test(org.junit.jupiter.api.Test)

Example 25 with EntityId

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

the class ToEntityIdTest method shouldReturnEntitySeedIfInputIsAnObject.

@Test
public void shouldReturnEntitySeedIfInputIsAnObject() {
    // Given
    final Object input = "item";
    final ToEntityId function = new ToEntityId();
    // When
    final EntityId output = function.apply(input);
    // Then
    assertEquals(new EntitySeed(input), output);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) 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