use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.
the class EdgeSeedTest method shouldBeRelatedToEntityIdWhenDestinationAndVertexAreNull.
@Test
public void shouldBeRelatedToEntityIdWhenDestinationAndVertexAreNull() {
// Given
final String source = "source";
final String destination = null;
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.ElementId in project Gaffer by gchq.
the class EdgeSeedTest method shouldBeRelatedToEntityIdWhenSourceEqualsVertex.
@Test
public void shouldBeRelatedToEntityIdWhenSourceEqualsVertex() {
// 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(source);
// When
final boolean isRelated = seed.isRelated((ElementId) relatedSeed).isMatch();
// Then
assertTrue(isRelated);
}
use of uk.gov.gchq.gaffer.data.element.id.ElementId 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.ElementId in project Gaffer by gchq.
the class GetWalksTest method shouldValidateWhenOperationContainsMultipleHops.
@Test
public void shouldValidateWhenOperationContainsMultipleHops() {
// Given
final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new OperationChain.Builder().first(new GetElements.Builder().input((Iterable<? extends ElementId>) null).view(new View.Builder().edge(TestGroups.EDGE).build()).build()).then(new GetElements.Builder().input((Iterable<? extends ElementId>) null).view(new View.Builder().edge(TestGroups.EDGE).build()).build()).build()).build();
// Then
final ValidationResult result = getWalks.validate();
assertFalse(result.isValid());
assertTrue(result.getErrorString().contains("All operations must contain a single hop. Operation ") && result.getErrorString().contains(" contains multiple hops"), result.getErrorString());
}
use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.
the class ToElementIdTest method shouldReturnOriginalValueIfInputIsAnEdge.
@Test
public void shouldReturnOriginalValueIfInputIsAnEdge() {
// Given
final Edge input = new Edge("group");
final ToElementId function = new ToElementId();
// When
final ElementId output = function.apply(input);
// Then
assertSame(input, output);
}
Aggregations