use of uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain in project Gaffer by gchq.
the class ValidateOperationChainHandlerTest method shouldReturnValidationResultWithErrorsIfOperationChainInvalid.
@Test
public void shouldReturnValidationResultWithErrorsIfOperationChainInvalid() throws OperationException {
// Given
final AddElementsFromSocket addElementsFromSocket = new AddElementsFromSocket();
OperationChain chain = new OperationChain.Builder().first(addElementsFromSocket).build();
ValidateOperationChain validateOperationChain = new ValidateOperationChain.Builder().operationChain(chain).build();
given(store.getOperationChainValidator()).willReturn(new OperationChainValidator(new ViewValidator()));
ValidateOperationChainHandler handler = new ValidateOperationChainHandler();
// When
ValidationResult result = handler.doOperation(validateOperationChain, context, store);
// Then
assertFalse(result.isValid());
assertTrue(result.getErrorString().contains("elementGenerator is required for: AddElementsFromSocket"));
assertTrue(result.getErrorString().contains("hostname is required for: AddElementsFromSocket"));
}
use of uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain in project Gaffer by gchq.
the class ValidateOperationChainHandlerTest method shouldValidateOperationChain.
@Test
public void shouldValidateOperationChain() throws OperationException {
// Given
final AddElements addElements = new AddElements();
final GetAdjacentIds getAdj = new GetAdjacentIds();
final GetElements getElements = new GetElements();
final DiscardOutput discardOutput = new DiscardOutput();
OperationChain chain = new OperationChain.Builder().first(addElements).then(getAdj).then(getElements).then(discardOutput).build();
ValidateOperationChain validateOperationChain = new ValidateOperationChain.Builder().operationChain(chain).build();
given(store.getOperationChainValidator()).willReturn(new OperationChainValidator(new ViewValidator()));
ValidateOperationChainHandler handler = new ValidateOperationChainHandler();
// When
ValidationResult result = handler.doOperation(validateOperationChain, context, store);
// Then
assertTrue(result.isValid());
}
Aggregations