Search in sources :

Example 1 with ViewValidator

use of uk.gov.gchq.gaffer.store.schema.ViewValidator in project Gaffer by gchq.

the class ExamplesServiceTest method shouldCreateViewForEdges.

@Test
public void shouldCreateViewForEdges() {
    final View.Builder builder = service.generateViewBuilder();
    final View view = builder.build();
    assertNotNull(view);
    final ViewValidator viewValidator = new ViewValidator();
    final boolean validate = viewValidator.validate(view, schema, false);
    assertTrue(validate);
}
Also used : ViewValidator(uk.gov.gchq.gaffer.store.schema.ViewValidator) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test)

Example 2 with ViewValidator

use of uk.gov.gchq.gaffer.store.schema.ViewValidator in project Gaffer by gchq.

the class StoreTest method shouldThrowExceptionIfOperationViewIsInvalid.

@Test
public void shouldThrowExceptionIfOperationViewIsInvalid() throws OperationException, StoreException {
    // Given
    // Given
    final Schema schema = createSchemaMock();
    final StoreProperties properties = mock(StoreProperties.class);
    final AddElements addElements = new AddElements();
    final View view = mock(View.class);
    final ViewValidator viewValidator = mock(ViewValidator.class);
    final StoreImpl store = new StoreImpl(viewValidator);
    addElements.setView(view);
    given(schema.validate()).willReturn(true);
    given(viewValidator.validate(view, schema, true)).willReturn(false);
    store.initialise(schema, properties);
    // When / Then
    try {
        store.execute(addElements, user);
        fail("Exception expected");
    } catch (final SchemaException e) {
        verify(viewValidator).validate(view, schema, true);
        assertTrue(e.getMessage().contains("View"));
    }
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) SchemaException(uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException) ViewValidator(uk.gov.gchq.gaffer.store.schema.ViewValidator) Schema(uk.gov.gchq.gaffer.store.schema.Schema) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)2 ViewValidator (uk.gov.gchq.gaffer.store.schema.ViewValidator)2 SchemaException (uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException)1 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)1 Schema (uk.gov.gchq.gaffer.store.schema.Schema)1