Search in sources :

Example 6 with Builder

use of uk.gov.gchq.gaffer.operation.OperationChain.Builder in project Gaffer by gchq.

the class CountGroupsIT method shouldCountGroupsOfElementsWhenLessElementsThanLimit.

@Test
public void shouldCountGroupsOfElementsWhenLessElementsThanLimit() throws OperationException, InterruptedException {
    // Given
    final User user = new User();
    final Integer limit = getEntities().size() + getEdges().size() + 1;
    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
    assertEquals(1, counts.getEntityGroups().size());
    assertEquals(getEntities().size(), (int) counts.getEntityGroups().get(TestGroups.ENTITY));
    assertEquals(1, counts.getEdgeGroups().size());
    assertEquals(getEdges().size(), (int) counts.getEdgeGroups().get(TestGroups.EDGE));
    assertFalse(counts.isLimitHit());
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) User(uk.gov.gchq.gaffer.user.User) CountGroups(uk.gov.gchq.gaffer.operation.impl.CountGroups) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GroupCounts(uk.gov.gchq.gaffer.data.GroupCounts) Test(org.junit.Test)

Example 7 with Builder

use of uk.gov.gchq.gaffer.operation.OperationChain.Builder in project Gaffer by gchq.

the class CountGroupsIT method shouldCountGroupsOfElements.

@Test
public void shouldCountGroupsOfElements() throws OperationException, InterruptedException {
    // Given
    final User user = new User();
    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()).build(), user);
    // Then
    assertEquals(1, counts.getEntityGroups().size());
    assertEquals(getEntities().size(), (int) counts.getEntityGroups().get(TestGroups.ENTITY));
    assertEquals(1, counts.getEdgeGroups().size());
    assertEquals(getEdges().size(), (int) counts.getEdgeGroups().get(TestGroups.EDGE));
    assertFalse(counts.isLimitHit());
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) User(uk.gov.gchq.gaffer.user.User) CountGroups(uk.gov.gchq.gaffer.operation.impl.CountGroups) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GroupCounts(uk.gov.gchq.gaffer.data.GroupCounts) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 Builder (uk.gov.gchq.gaffer.operation.OperationChain.Builder)7 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)3 GroupCounts (uk.gov.gchq.gaffer.data.GroupCounts)3 Entity (uk.gov.gchq.gaffer.data.element.Entity)3 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)3 CountGroups (uk.gov.gchq.gaffer.operation.impl.CountGroups)3 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)3 User (uk.gov.gchq.gaffer.user.User)3 Element (uk.gov.gchq.gaffer.data.element.Element)2 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)2 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)2 Edge (uk.gov.gchq.gaffer.data.element.Edge)1 EntitySeedExtractor (uk.gov.gchq.gaffer.operation.data.generator.EntitySeedExtractor)1 OperationImpl (uk.gov.gchq.gaffer.operation.impl.OperationImpl)1 ExportToSet (uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet)1 GetSetExport (uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport)1 GenerateObjects (uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects)1 GetAdjacentEntitySeeds (uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds)1 GetEdges (uk.gov.gchq.gaffer.operation.impl.get.GetEdges)1