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));
}
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);
}
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();
}
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());
}
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()));
}
Aggregations