Search in sources :

Example 11 with GetAdjacentEntitySeeds

use of uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds in project Gaffer by gchq.

the class OperationChainLimiterTest method shouldAcceptOperationChainWhenUserHasMaxAuthScoreGreaterThanChainScore.

@Test
public void shouldAcceptOperationChainWhenUserHasMaxAuthScoreGreaterThanChainScore() {
    // Given
    final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentEntitySeeds()).then(new GetAdjacentEntitySeeds()).then(new GetAdjacentEntitySeeds()).then(new GenerateObjects()).build();
    final User user = new User.Builder().opAuths("SuperUser", "User").build();
    // When
    OPERATION_CHAIN_LIMITER.preExecute(opChain, user);
// Then - no exceptions
}
Also used : GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) GetAdjacentEntitySeeds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds) User(uk.gov.gchq.gaffer.user.User) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Test(org.junit.Test)

Example 12 with GetAdjacentEntitySeeds

use of uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds in project Gaffer by gchq.

the class OperationChainLimiterTest method shouldAcceptOperationChainWhenUserHasAuthScoreEqualToChainScore.

@Test
public void shouldAcceptOperationChainWhenUserHasAuthScoreEqualToChainScore() {
    // Given
    final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentEntitySeeds()).then(new GenerateObjects()).build();
    final User user = new User.Builder().opAuths("User").build();
    // When
    OPERATION_CHAIN_LIMITER.preExecute(opChain, user);
// Then - no exceptions
}
Also used : GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) GetAdjacentEntitySeeds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds) User(uk.gov.gchq.gaffer.user.User) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Test(org.junit.Test)

Example 13 with GetAdjacentEntitySeeds

use of uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds in project Gaffer by gchq.

the class GetAdjacentEntitySeedsIT method shouldGetEntitySeeds.

private void shouldGetEntitySeeds(final List<String> expectedResultSeeds, final GetOperation.IncludeIncomingOutgoingType inOutType) throws IOException, OperationException {
    // Given
    final User user = new User();
    final List<EntitySeed> seeds = new ArrayList<>();
    for (final String seed : SEEDS) {
        seeds.add(new EntitySeed(seed));
    }
    final GetAdjacentEntitySeeds operation = new GetAdjacentEntitySeeds.Builder().seeds(seeds).includeEntities(true).includeEdges(GetOperation.IncludeEdgeType.ALL).inOutType(inOutType).build();
    // When
    final CloseableIterable<EntitySeed> results = graph.execute(operation, user);
    // Then
    List<String> resultSeeds = new ArrayList<>();
    for (final EntitySeed result : results) {
        resultSeeds.add((String) result.getVertex());
    }
    Collections.sort(resultSeeds);
    Collections.sort(expectedResultSeeds);
    assertArrayEquals("Expected: " + expectedResultSeeds + ", but got: " + resultSeeds, expectedResultSeeds.toArray(), resultSeeds.toArray());
}
Also used : User(uk.gov.gchq.gaffer.user.User) GetAdjacentEntitySeeds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds) ArrayList(java.util.ArrayList) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed)

Aggregations

GetAdjacentEntitySeeds (uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds)13 Test (org.junit.Test)10 User (uk.gov.gchq.gaffer.user.User)9 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)8 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)5 GenerateObjects (uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects)5 UnauthorisedException (uk.gov.gchq.gaffer.commonutil.exception.UnauthorisedException)4 Builder (uk.gov.gchq.gaffer.operation.OperationChain.Builder)3 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)3 ArrayList (java.util.ArrayList)2 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)2 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)2 Element (uk.gov.gchq.gaffer.data.element.Element)1 DataGenerator6 (uk.gov.gchq.gaffer.example.gettingstarted.generator.DataGenerator6)1 Graph (uk.gov.gchq.gaffer.graph.Graph)1 GetEdges (uk.gov.gchq.gaffer.operation.impl.get.GetEdges)1