use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class IfTest method shouldThrowErrorForTryingToUpdateOperationsWithTooManyOps.
@Test
public void shouldThrowErrorForTryingToUpdateOperationsWithTooManyOps() {
// Given
final GetElements getElements = new GetElements.Builder().input(new EntitySeed("2")).build();
final GetAllElements getAllElements = new GetAllElements();
final Limit limit = new Limit(5);
final If<Object, Object> ifOp = new If.Builder<>().build();
final Collection<Operation> opList = Lists.newArrayList(getElements, getAllElements, limit, limit);
// When / Then
assertThatIllegalArgumentException().isThrownBy(() -> ifOp.updateOperations(opList)).withMessage("Unable to update operations - exactly 3 operations are required. Received 4 operations");
}
use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class IfTest method shouldShallowCloneOperation.
@Test
@Override
public void shouldShallowCloneOperation() {
// Given
final Object input = "testInput";
final If ifOp = new If.Builder<>().input(input).condition(true).conditional(new Conditional()).then(new GetElements.Builder().input(new EntitySeed("A")).build()).otherwise(new GetAllElements()).build();
// When
final If clone = ifOp.shallowClone();
// Then
assertNotSame(ifOp, clone);
assertEquals(input, clone.getInput());
}
use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class IfTest method shouldUpdateOperations.
@Test
public void shouldUpdateOperations() {
// Given
final GetElements getElements = new GetElements.Builder().input(new EntitySeed("A")).build();
final OperationChain opChain = new OperationChain.Builder().first(new GetAllElements()).then(new Limit<>(3)).build();
final If<Object, Object> ifOp = new If.Builder<>().condition(false).build();
final Collection<Operation> opList = Lists.newArrayList(new OperationChain<>(), getElements, opChain);
// When
ifOp.updateOperations(opList);
// Then
assertNotNull(ifOp.getThen());
assertNotNull(ifOp.getOtherwise());
assertEquals(getElements, ifOp.getThen());
assertEquals(opChain, ifOp.getOtherwise());
}
use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class GetWalksTest method builderShouldCreatePopulatedOperation.
@Test
@Override
public void builderShouldCreatePopulatedOperation() {
// Given
final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new GetElements()).resultsLimit(100).build();
// Then
Assertions.<EntityId>assertThat(getWalks.getInput()).hasSize(2).containsOnly(new EntitySeed("1"), new EntitySeed("2"));
assertThat(getWalks.getResultsLimit()).isEqualTo(100);
assertThat(getWalks.getOperations()).hasSize(1);
}
use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.
the class GetWalksTest method shouldValidateWhenPreFiltersContainsAnOperationWhichDoesNotAllowAnInput.
@Test
public void shouldValidateWhenPreFiltersContainsAnOperationWhichDoesNotAllowAnInput() {
// Given
final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new OperationChain.Builder().first(new ScoreOperationChain()).then(new DiscardOutput()).then(new GetElements.Builder().input().view(new View.Builder().edge(TestGroups.EDGE).build()).build()).build()).build();
// Then
final ValidationResult result = getWalks.validate();
assertFalse(result.isValid());
assertTrue(result.getErrorString().contains("The first operation in operation chain 0: " + ScoreOperationChain.class.getName() + " is not be able to accept the input seeds."), result.getErrorString());
}
Aggregations