use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.
the class ElementIdSerialiserTest method testCanSerialiseEntityId.
@Test
public void testCanSerialiseEntityId() throws SerialisationException {
// Given
final EntityId entityId = new EntitySeed("vertex");
// When
final byte[] serialisedEntityId = serialiser.serialise(entityId);
final ElementId deserialisedEntityId = serialiser.deserialise(serialisedEntityId);
// Then
assertEquals(entityId, deserialisedEntityId);
}
use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.
the class ToElementIdTest method shouldReturnEntitySeedIfInputIsAnObject.
@Test
public void shouldReturnEntitySeedIfInputIsAnObject() {
// Given
final Object input = "item";
final ToElementId function = new ToElementId();
// When
final ElementId output = function.apply(input);
// Then
assertEquals(new EntitySeed(input), output);
}
use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.
the class FilteringIT method testPostAggregationFilteringProperties.
@Test
@TraitRequirement({ StoreTrait.POST_AGGREGATION_FILTERING, StoreTrait.INGEST_AGGREGATION })
public void testPostAggregationFilteringProperties() throws OperationException {
// Given
final List<ElementId> seeds = Arrays.asList(new EntitySeed("A3"), new EdgeSeed("A5", "B5", false));
final GetElements getElementsWithoutFiltering = new GetElements.Builder().input(seeds).build();
final GetElements getElementsWithFiltering = new GetElements.Builder().input(seeds).view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().postAggregationFilter(new ElementFilter.Builder().select(IdentifierType.VERTEX.name()).execute(new IsEqual("A5")).build()).build()).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().postAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsLessThan(2)).build()).build()).build()).build();
// When - without filtering
final List<Element> resultsWithoutFiltering = Lists.newArrayList(graph.execute(getElementsWithoutFiltering, getUser()));
// When - with filtering
final List<Element> resultsWithFiltering = Lists.newArrayList(graph.execute(getElementsWithFiltering, getUser()));
// Then - without filtering
List<Element> expectedResults = Arrays.asList(getEdge("A3", "A3", false), getEdge("A3", "B3", false), getEdge("A3", "C3", false), getEdge("A3", "D3", false), getEdge("A5", "B5", false), getEdge("A3", "A3", true), getEdge("A3", "B3", true), getEdge("A3", "C3", true), getEdge("A3", "D3", true), getEntity("A3"), getEntity("A5"), getEntity("B5"));
ElementUtil.assertElementEquals(expectedResults, resultsWithoutFiltering);
// Then - with filtering
List<Element> expectedFilteredResults = Arrays.asList(getEdge("A3", "A3", false), getEdge("A3", "B3", false), getEdge("A5", "B5", false), getEdge("A3", "D3", false), getEdge("A3", "C3", false), getEdge("A3", "A3", true), getEdge("A3", "B3", true), getEdge("A3", "C3", true), getEdge("A3", "D3", true), getEntity("A5"));
ElementUtil.assertElementEquals(expectedFilteredResults, resultsWithFiltering);
}
use of uk.gov.gchq.gaffer.data.element.id.ElementId 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);
}
use of uk.gov.gchq.gaffer.data.element.id.ElementId 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);
}
Aggregations