use of uk.gov.gchq.koryphe.ValidationResult 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());
}
use of uk.gov.gchq.koryphe.ValidationResult in project Gaffer by gchq.
the class GetWalksTest method shouldValidateWhenOperationContainsMultipleHops.
@Test
public void shouldValidateWhenOperationContainsMultipleHops() {
// Given
final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new OperationChain.Builder().first(new GetElements.Builder().input((Iterable<? extends ElementId>) null).view(new View.Builder().edge(TestGroups.EDGE).build()).build()).then(new GetElements.Builder().input((Iterable<? extends ElementId>) null).view(new View.Builder().edge(TestGroups.EDGE).build()).build()).build()).build();
// Then
final ValidationResult result = getWalks.validate();
assertFalse(result.isValid());
assertTrue(result.getErrorString().contains("All operations must contain a single hop. Operation ") && result.getErrorString().contains(" contains multiple hops"), result.getErrorString());
}
use of uk.gov.gchq.koryphe.ValidationResult in project Gaffer by gchq.
the class GetWalksTest method shouldValidateWhenOperationListContainsAnEmptyOperationChain.
@Test
public void shouldValidateWhenOperationListContainsAnEmptyOperationChain() {
// Given
final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new GetElements.Builder().input((Iterable<? extends ElementId>) null).view(new View.Builder().edge(TestGroups.EDGE).build()).build(), new OperationChain()).build();
// Then
final ValidationResult result = getWalks.validate();
assertFalse(result.isValid());
assertTrue(result.getErrorString().contains("Operation chain 1 contains no operations"), result.getErrorString());
}
use of uk.gov.gchq.koryphe.ValidationResult in project Gaffer by gchq.
the class GetWalksTest method shouldValidateWhenOperationListDoesNotContainAGetElementsOperation.
@Test
public void shouldValidateWhenOperationListDoesNotContainAGetElementsOperation() {
// Given
final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new GetElements.Builder().input((Iterable<? extends ElementId>) null).view(new View.Builder().edge(TestGroups.EDGE).build()).build(), new OperationChain.Builder().first(new AddElements()).build(), new GetElements.Builder().input((Iterable<? extends ElementId>) null).view(new View.Builder().edge(TestGroups.EDGE).build()).build()).build();
// Then
final ValidationResult result = getWalks.validate();
assertFalse(result.isValid());
assertTrue(result.getErrorString().contains("All operations must contain a single hop. Operation 1 does not contain a hop."), result.getErrorString());
}
use of uk.gov.gchq.koryphe.ValidationResult in project Gaffer by gchq.
the class OperationTest method shouldValidateRequiredFields.
@Test
public void shouldValidateRequiredFields() throws Exception {
// Given
final Operation op = getTestObject();
// When
final ValidationResult validationResult = op.validate();
// Then
final Set<String> requiredFields = getRequiredFields();
final Set<String> requiredFieldsErrors = requiredFields.stream().map(f -> f + " is required for: " + op.getClass().getSimpleName()).collect(Collectors.toSet());
assertEquals(requiredFieldsErrors, validationResult.getErrors());
}
Aggregations