Search in sources :

Example 6 with GetAdjacentEntitySeeds

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

the class OperationAuthoriserTest method shouldRejectOperationChainWhenUserDoesntHaveAnyOpAuths.

@Test
public void shouldRejectOperationChainWhenUserDoesntHaveAnyOpAuths() throws OperationException {
    // Given
    final OperationAuthoriser opAuthoriser = new OperationAuthoriser(StreamUtil.opAuths(getClass()));
    final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentEntitySeeds()).then(new GetElements()).build();
    final User user = new User();
    // When/Then
    try {
        opAuthoriser.preExecute(opChain, user);
        fail("Exception expected");
    } catch (final UnauthorisedException e) {
        assertNotNull(e.getMessage());
    }
}
Also used : GetAdjacentEntitySeeds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds) User(uk.gov.gchq.gaffer.user.User) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) UnauthorisedException(uk.gov.gchq.gaffer.commonutil.exception.UnauthorisedException) Test(org.junit.Test)

Example 7 with GetAdjacentEntitySeeds

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

the class OperationAuthoriserTest method shouldRejectOperationChainWhenUserDoesntHaveAllOpAuthsForAllOperations.

@Test
public void shouldRejectOperationChainWhenUserDoesntHaveAllOpAuthsForAllOperations() {
    // Given
    final OperationAuthoriser opAuthoriser = new OperationAuthoriser(StreamUtil.opAuths(getClass()));
    final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentEntitySeeds()).then(// Requires AdminUser
    new GenerateObjects()).build();
    final User user = new User.Builder().opAuths("WriteUser", "ReadUser", "User").build();
    // When/Then
    try {
        opAuthoriser.preExecute(opChain, user);
        fail("Exception expected");
    } catch (final UnauthorisedException e) {
        assertNotNull(e.getMessage());
    }
}
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) UnauthorisedException(uk.gov.gchq.gaffer.commonutil.exception.UnauthorisedException) Test(org.junit.Test)

Example 8 with GetAdjacentEntitySeeds

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

the class OperationChainTest method shouldBuildOperationChainWithSingleOperation.

@Test
public void shouldBuildOperationChainWithSingleOperation() throws SerialisationException {
    // Given
    final GetAdjacentEntitySeeds getAdjacentEntitySeeds = mock(GetAdjacentEntitySeeds.class);
    // When
    final OperationChain opChain = new OperationChain.Builder().first(getAdjacentEntitySeeds).build();
    // Then
    assertEquals(1, opChain.getOperations().size());
    assertSame(getAdjacentEntitySeeds, opChain.getOperations().get(0));
}
Also used : GetAdjacentEntitySeeds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) Test(org.junit.Test)

Example 9 with GetAdjacentEntitySeeds

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

the class OperationChainTest method shouldBuildOperationChain_AdjEntitySeedsThenRelatedEdges.

@Test
public void shouldBuildOperationChain_AdjEntitySeedsThenRelatedEdges() throws SerialisationException {
    // Given
    final GetAdjacentEntitySeeds getAdjacentEntitySeeds = mock(GetAdjacentEntitySeeds.class);
    final GetEdges<EntitySeed> getEdges = mock(GetEdges.class);
    // When
    final OperationChain opChain = new OperationChain.Builder().first(getAdjacentEntitySeeds).then(getEdges).build();
    // Then
    assertEquals(2, opChain.getOperations().size());
    assertSame(getAdjacentEntitySeeds, opChain.getOperations().get(0));
    assertSame(getEdges, opChain.getOperations().get(1));
}
Also used : GetAdjacentEntitySeeds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Test(org.junit.Test)

Example 10 with GetAdjacentEntitySeeds

use of uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds 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);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) GetAdjacentEntitySeeds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Test(org.junit.Test)

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