use of uk.gov.gchq.gaffer.operation.OperationChain.Builder in project Gaffer by gchq.
the class CountGroupsIT method shouldCountGroupsOfElementsWhenMoreElementsThanLimit.
@Test
public void shouldCountGroupsOfElementsWhenMoreElementsThanLimit() throws OperationException, InterruptedException {
// Given
final User user = new User();
final int limit = 5;
final Entity entity = new Entity(TestGroups.ENTITY_2, VERTEX);
entity.putProperty(TestPropertyNames.INT, 100);
// When
final GroupCounts counts = graph.execute(new Builder().first(new GetAllElements<>()).then(new CountGroups(limit)).build(), user);
// Then
int totalCount = (null != counts.getEntityGroups().get(TestGroups.ENTITY) ? counts.getEntityGroups().get(TestGroups.ENTITY) : 0);
totalCount += (null != counts.getEdgeGroups().get(TestGroups.EDGE) ? counts.getEdgeGroups().get(TestGroups.EDGE) : 0);
assertEquals(limit, totalCount);
}
use of uk.gov.gchq.gaffer.operation.OperationChain.Builder in project Gaffer by gchq.
the class ExportIT method shouldExportResultsInSet.
@Test
public void shouldExportResultsInSet() throws OperationException, IOException {
// Given
final OperationChain<CloseableIterable<?>> exportOpChain = new Builder().first(new GetEdges.Builder<>().addSeed(new EntitySeed(SOURCE_DIR_0)).build()).then(new ExportToSet()).then(new GenerateObjects.Builder<Edge, EntitySeed>().generator(new EntitySeedExtractor()).build()).then(new GetEdges<>()).then(new ExportToSet()).then(new GetSetExport()).build();
// When
final CloseableIterable<?> export = graph.execute(exportOpChain, getUser());
// Then
assertEquals(2, Lists.newArrayList(export).size());
}
use of uk.gov.gchq.gaffer.operation.OperationChain.Builder in project Gaffer by gchq.
the class OperationChainTest method shouldBuildOperationChain.
@Test
public void shouldBuildOperationChain() {
// Given
final AddElements addElements = mock(AddElements.class);
final GetElements getAdj1 = mock(GetElements.class);
final GetElements getAdj2 = mock(GetElements.class);
final GetElements<EntitySeed, Element> getRelElements = mock(GetElements.class);
// When
final OperationChain<CloseableIterable<Element>> opChain = new Builder().first(addElements).then(getAdj1).then(getAdj2).then(getRelElements).build();
// Then
assertArrayEquals(new Operation[] { addElements, getAdj1, getAdj2, getRelElements }, opChain.getOperationArray());
}
use of uk.gov.gchq.gaffer.operation.OperationChain.Builder in project Gaffer by gchq.
the class OperationChainTest method shouldSerialiseAndDeserialiseOperationChain.
@Test
public void shouldSerialiseAndDeserialiseOperationChain() throws SerialisationException {
// Given
final OperationChain<Object> opChain = new Builder().first(new OperationImpl<>()).then(new OperationImpl<>()).build();
// When
byte[] json = serialiser.serialise(opChain, true);
final OperationChain deserialisedOp = serialiser.deserialise(json, OperationChain.class);
// Then
assertNotNull(deserialisedOp);
assertEquals(2, deserialisedOp.getOperations().size());
assertEquals(OperationImpl.class, deserialisedOp.getOperations().get(0).getClass());
assertEquals(OperationImpl.class, deserialisedOp.getOperations().get(1).getClass());
}
use of uk.gov.gchq.gaffer.operation.OperationChain.Builder in project Gaffer by gchq.
the class OperationChainTest method shouldReturnReadableStringForToString.
@Test
public void shouldReturnReadableStringForToString() {
// Given
final AddElements addElements = new AddElements();
final GetAdjacentEntitySeeds getAdj1 = new GetAdjacentEntitySeeds();
final GetAdjacentEntitySeeds getAdj2 = new GetAdjacentEntitySeeds();
final GetElements<EntitySeed, Element> getRelElements = new GetElements<>();
final OperationChain<CloseableIterable<Element>> opChain = new Builder().first(addElements).then(getAdj1).then(getAdj2).then(getRelElements).build();
// When
final String toString = opChain.toString();
// Then
final String expectedToString = "OperationChain[AddElements->GetAdjacentEntitySeeds->GetAdjacentEntitySeeds->GetElements]";
assertEquals(expectedToString, toString);
}
Aggregations