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