Search in sources :

Example 1 with ValidateOperationChain

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"));
}
Also used : ViewValidator(uk.gov.gchq.gaffer.store.schema.ViewValidator) ValidateOperationChain(uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) ValidateOperationChain(uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain) AddElementsFromSocket(uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromSocket) OperationChainValidator(uk.gov.gchq.gaffer.store.operation.OperationChainValidator) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 2 with ValidateOperationChain

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());
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) ViewValidator(uk.gov.gchq.gaffer.store.schema.ViewValidator) ValidateOperationChain(uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput) ValidateOperationChain(uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain) OperationChainValidator(uk.gov.gchq.gaffer.store.operation.OperationChainValidator) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)2 ValidateOperationChain (uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain)2 OperationChainValidator (uk.gov.gchq.gaffer.store.operation.OperationChainValidator)2 ViewValidator (uk.gov.gchq.gaffer.store.schema.ViewValidator)2 ValidationResult (uk.gov.gchq.koryphe.ValidationResult)2 DiscardOutput (uk.gov.gchq.gaffer.operation.impl.DiscardOutput)1 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)1 AddElementsFromSocket (uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromSocket)1 GetAdjacentIds (uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds)1 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)1