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);
}
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);
}
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());
}
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());
}
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);
}
Aggregations