Search in sources :

Example 36 with EntityId

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

the class UnwrapEntityIdTest method shouldUnwrapEntityIds.

@Test
public void shouldUnwrapEntityIds() {
    final EntityId value = mock(EntityId.class);
    final Object vertex = mock(Object.class);
    given(value.getVertex()).willReturn(vertex);
    final UnwrapEntityId function = new UnwrapEntityId();
    final Object result = function.apply(value);
    assertSame(vertex, result);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) Test(org.junit.jupiter.api.Test) FunctionTest(uk.gov.gchq.koryphe.function.FunctionTest)

Example 37 with EntityId

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

the class GetAdjacentIdsTest method builderShouldCreatePopulatedOperationIncoming.

private void builderShouldCreatePopulatedOperationIncoming() {
    EntityId seed = new EntitySeed("A");
    GetAdjacentIds op = new GetAdjacentIds.Builder().input(seed).inOutType(IncludeIncomingOutgoingType.INCOMING).view(new View.Builder().edge("testEdgeGroup").build()).build();
    assertEquals(IncludeIncomingOutgoingType.INCOMING, op.getIncludeIncomingOutGoing());
    assertNotNull(op.getView());
    assertThat(op.getInput().iterator().next()).isEqualTo(seed);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed)

Example 38 with EntityId

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

the class GetAdjacentIdsTest method shouldSetIncludeIncomingOutgoingTypeToBoth.

@Test
public void shouldSetIncludeIncomingOutgoingTypeToBoth() {
    final EntityId elementId = new EntitySeed("identifier");
    // When
    final GetAdjacentIds op = new GetAdjacentIds.Builder().input(elementId).inOutType(IncludeIncomingOutgoingType.EITHER).build();
    // Then
    assertEquals(IncludeIncomingOutgoingType.EITHER, op.getIncludeIncomingOutGoing());
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 39 with EntityId

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

the class GetElementsIT method getElements.

private static Collection<Element> getElements(final Collection<ElementId> seeds, final Boolean direction) {
    final Set<Element> elements = new HashSet<>(seeds.size());
    for (final ElementId seed : seeds) {
        if (seed instanceof EntityId) {
            final Entity entity = new Entity(TestGroups.ENTITY, ((EntityId) seed).getVertex());
            entity.putProperty(TestPropertyNames.COUNT, 1L);
            entity.putProperty(TestPropertyNames.SET, CollectionUtil.treeSet("3"));
            elements.add(entity);
        } else {
            if (DirectedType.isEither(((EdgeId) seed).getDirectedType())) {
                if (BooleanUtils.isNotTrue(direction)) {
                    final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(((EdgeId) seed).getSource()).dest(((EdgeId) seed).getDestination()).matchedVertex(((EdgeId) seed).getMatchedVertex()).directed(false).property(TestPropertyNames.INT, 1).property(TestPropertyNames.COUNT, 1L).build();
                    elements.add(edge);
                }
                if (BooleanUtils.isNotFalse(direction)) {
                    final Edge edgeDir = new Edge.Builder().group(TestGroups.EDGE).source(((EdgeId) seed).getSource()).dest(((EdgeId) seed).getDestination()).matchedVertex(((EdgeId) seed).getMatchedVertex()).directed(true).property(TestPropertyNames.INT, 1).property(TestPropertyNames.COUNT, 1L).build();
                    elements.add(edgeDir);
                }
            } else {
                final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(((EdgeId) seed).getSource()).dest(((EdgeId) seed).getDestination()).directed(((EdgeId) seed).isDirected()).matchedVertex(((EdgeId) seed).getMatchedVertex()).property(TestPropertyNames.INT, 1).property(TestPropertyNames.COUNT, 1L).build();
                elements.add(edge);
            }
        }
    }
    return elements;
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) Entity(uk.gov.gchq.gaffer.data.element.Entity) Element(uk.gov.gchq.gaffer.data.element.Element) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) Edge(uk.gov.gchq.gaffer.data.element.Edge) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) HashSet(java.util.HashSet)

Example 40 with EntityId

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

the class GraphHooksIT method shouldResolveNamedViewWithinNamedOperation.

@Test
public void shouldResolveNamedViewWithinNamedOperation() throws OperationException {
    // Given
    final Edge edge1 = getEdges().get(new EdgeSeed(SOURCE_1, DEST_1, false)).emptyClone();
    edge1.putProperty(TestPropertyNames.INT, 100);
    final Edge edge2 = edge1.emptyClone();
    edge2.putProperty(TestPropertyNames.INT, 101);
    graph.execute(new AddElements.Builder().input(edge1, edge2).build(), getUser());
    final AddNamedView addNamedView = new AddNamedView.Builder().name("Test View").view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsIn(Arrays.asList((Object) 100))).build()).build()).build()).overwrite(true).build();
    graph.execute(addNamedView, getUser());
    final AddNamedOperation addNamedOperation = new AddNamedOperation.Builder().operationChain(new OperationChain.Builder().first(new GetAllElements.Builder().view(new NamedView.Builder().name("Test View").build()).build()).build()).description("named operation GetAllElements test query").name("GetAllElements test").labels(Arrays.asList("label 1", "Label 2")).overwrite(true).build();
    graph.execute(addNamedOperation, getUser());
    final NamedOperation<EntityId, CloseableIterable<? extends Element>> operation = new NamedOperation.Builder<EntityId, CloseableIterable<? extends Element>>().name("GetAllElements test").input(new EntitySeed("10")).build();
    // When
    final CloseableIterable<? extends Element> results = graph.execute(operation, getUser());
    // Then
    final List<Element> resultList = Lists.newArrayList(results);
    assertThat(resultList).hasSize(1).contains((Element) edge1);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) AddNamedView(uk.gov.gchq.gaffer.named.view.AddNamedView) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) NamedView(uk.gov.gchq.gaffer.data.elementdefinition.view.NamedView) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) AddNamedView(uk.gov.gchq.gaffer.named.view.AddNamedView) IsIn(uk.gov.gchq.koryphe.impl.predicate.IsIn) EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) NamedOperation(uk.gov.gchq.gaffer.named.operation.NamedOperation) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) Test(org.junit.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