Search in sources :

Example 11 with ElementId

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);
}
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 12 with ElementId

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);
}
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 13 with ElementId

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);
}
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 14 with ElementId

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());
}
Also used : GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 15 with ElementId

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

Aggregations

ElementId (uk.gov.gchq.gaffer.data.element.id.ElementId)58 Test (org.junit.jupiter.api.Test)32 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)29 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)19 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)19 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)17 Edge (uk.gov.gchq.gaffer.data.element.Edge)14 Element (uk.gov.gchq.gaffer.data.element.Element)14 EdgeId (uk.gov.gchq.gaffer.data.element.id.EdgeId)14 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)14 HashSet (java.util.HashSet)11 Entity (uk.gov.gchq.gaffer.data.element.Entity)9 User (uk.gov.gchq.gaffer.user.User)9 ArrayList (java.util.ArrayList)7 IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)7 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)7 Test (org.junit.Test)6 JSONSerialisationTest (uk.gov.gchq.gaffer.JSONSerialisationTest)6 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)5 Key (org.apache.accumulo.core.data.Key)4