Search in sources :

Example 51 with EntityId

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

the class OperationUtilTest method shouldConvertIterableToEntityIds.

@Test
public void shouldConvertIterableToEntityIds() {
    // Given
    final Iterable<Object> input = Arrays.asList(1, "2", new EntitySeed("3"), new Entity("group", "4"), null);
    // When
    final Iterable<? extends ElementId> output = OperationUtil.toEntityIds(input);
    // Then
    final ArrayList<EntityId> expected = Lists.newArrayList(new EntitySeed(1), new EntitySeed("2"), new EntitySeed("3"), new Entity("group", "4"), null);
    assertEquals(expected, Lists.newArrayList(output));
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) Entity(uk.gov.gchq.gaffer.data.element.Entity) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Test(org.junit.jupiter.api.Test)

Example 52 with EntityId

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

Example 53 with EntityId

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

the class GetAdjacentIdsTest method shouldSerialiseAndDeserialiseOperationWithEntityIds.

@Test
public void shouldSerialiseAndDeserialiseOperationWithEntityIds() throws SerialisationException {
    // Given
    final EntityId entitySeed = new EntitySeed("identifier");
    final GetAdjacentIds op = new GetAdjacentIds.Builder().input(entitySeed).build();
    // When
    byte[] json = JSONSerialiser.serialise(op, true);
    final GetAdjacentIds deserialisedOp = JSONSerialiser.deserialise(json, GetAdjacentIds.class);
    // Then
    final Iterator itr = deserialisedOp.getInput().iterator();
    assertThat(itr.next()).isEqualTo(entitySeed);
    assertThat(itr).isExhausted();
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Iterator(java.util.Iterator) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 54 with EntityId

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

the class GetAdjacentIdsTest method shouldSetDirectedTypeToBoth.

@Test
public void shouldSetDirectedTypeToBoth() {
    // Given
    final EntityId elementId1 = new EntitySeed("identifier");
    // When
    final GetAdjacentIds op = new GetAdjacentIds.Builder().input(elementId1).directedType(DirectedType.EITHER).build();
    // Then
    assertEquals(DirectedType.EITHER, op.getDirectedType());
}
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 55 with EntityId

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

the class GetAdjacentIdsTest method shouldShallowCloneOperation.

@Test
@Override
public void shouldShallowCloneOperation() {
    // Given
    EntityId input = new EntitySeed("A");
    View view = new View.Builder().edge("testEdgeGroup").build();
    GetAdjacentIds getAdjacentIds = new GetAdjacentIds.Builder().input(input).inOutType(IncludeIncomingOutgoingType.INCOMING).directedType(DirectedType.DIRECTED).view(view).build();
    // When
    GetAdjacentIds clone = getAdjacentIds.shallowClone();
    // Then
    assertNotSame(getAdjacentIds, clone);
    assertEquals(DirectedType.DIRECTED, clone.getDirectedType());
    assertEquals(IncludeIncomingOutgoingType.INCOMING, clone.getIncludeIncomingOutGoing());
    assertEquals(view, clone.getView());
    assertEquals(Lists.newArrayList(input), Lists.newArrayList(clone.getInput()));
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.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