Search in sources :

Example 6 with CustomVertex

use of uk.gov.gchq.gaffer.operation.data.CustomVertex in project Gaffer by gchq.

the class OperationImplTest method shouldValidateASingleMissingRequiredField.

@Test
public void shouldValidateASingleMissingRequiredField() throws SerialisationException {
    // Given
    final String requiredField1 = "value1";
    final Date optionalField1 = new Date(1L);
    final CustomVertex optionalField2 = new CustomVertex("type2", "value2");
    final OperationImpl op = new OperationImpl.Builder().requiredField1(requiredField1).optionalField1(optionalField1).optionalField2(optionalField2).build();
    // When
    final ValidationResult validationResult = op.validate();
    // Then
    assertEquals(Sets.newHashSet("requiredField2 is required for: " + op.getClass().getSimpleName()), validationResult.getErrors());
}
Also used : CustomVertex(uk.gov.gchq.gaffer.operation.data.CustomVertex) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) Date(java.util.Date) Test(org.junit.jupiter.api.Test) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest)

Example 7 with CustomVertex

use of uk.gov.gchq.gaffer.operation.data.CustomVertex in project Gaffer by gchq.

the class OperationImplTest method builderShouldCreatePopulatedOperation.

@Test
@Override
public void builderShouldCreatePopulatedOperation() {
    // Given / When
    final String requiredField1 = "value1";
    final CustomVertex requiredField2 = new CustomVertex("type1", "value1");
    final Date optionalField1 = new Date(1L);
    final CustomVertex optionalField2 = new CustomVertex("type2", "value2");
    final OperationImpl op = new OperationImpl.Builder().requiredField1(requiredField1).requiredField2(requiredField2).optionalField1(optionalField1).optionalField2(optionalField2).build();
    // Then
    assertEquals(requiredField1, op.getRequiredField1());
    assertEquals(requiredField2, op.getRequiredField2());
    assertEquals(optionalField1, op.getOptionalField1());
    assertEquals(optionalField2, op.getOptionalField2());
}
Also used : CustomVertex(uk.gov.gchq.gaffer.operation.data.CustomVertex) Date(java.util.Date) Test(org.junit.jupiter.api.Test) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest)

Example 8 with CustomVertex

use of uk.gov.gchq.gaffer.operation.data.CustomVertex in project Gaffer by gchq.

the class InputImplTest method shouldShallowCloneOperation.

@Test
public void shouldShallowCloneOperation() {
    // Given
    final String requiredField1 = "value1";
    final CustomVertex requiredField2 = new CustomVertex("type1", "value1");
    final Date optionalField1 = new Date(1L);
    final CustomVertex optionalField2 = new CustomVertex("type2", "value2");
    final List<String> input = Arrays.asList("1", "2", "3", "4");
    final InputImpl op = new InputImpl.Builder().requiredField1(requiredField1).requiredField2(requiredField2).optionalField1(optionalField1).optionalField2(optionalField2).input(input).build();
    // When
    final InputImpl clone = (InputImpl) op.shallowClone();
    // Then
    assertEquals(requiredField1, clone.getRequiredField1());
    assertEquals(requiredField2, clone.getRequiredField2());
    assertEquals(optionalField1, clone.getOptionalField1());
    assertEquals(optionalField2, clone.getOptionalField2());
    assertSame(input, clone.getInput());
}
Also used : CustomVertex(uk.gov.gchq.gaffer.operation.data.CustomVertex) Date(java.util.Date) Test(org.junit.jupiter.api.Test) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest)

Aggregations

Date (java.util.Date)8 Test (org.junit.jupiter.api.Test)8 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)8 CustomVertex (uk.gov.gchq.gaffer.operation.data.CustomVertex)8 ValidationResult (uk.gov.gchq.koryphe.ValidationResult)2