use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class ElementValidatorTest method shouldReturnFalseWhenSchemaValidateWithInvalidElement.
@Test
public void shouldReturnFalseWhenSchemaValidateWithInvalidElement() {
// Given
final Schema schema = mock(Schema.class);
final String group = TestGroups.EDGE;
final Element elm = mock(Element.class);
final SchemaElementDefinition elementDef = mock(SchemaElementDefinition.class);
final ElementFilter filter = mock(ElementFilter.class);
final boolean includeIsA = true;
final ElementValidator validator = new ElementValidator(schema, includeIsA);
given(elm.getGroup()).willReturn(group);
given(schema.getElement(group)).willReturn(elementDef);
given(elementDef.getValidator(includeIsA)).willReturn(filter);
given(filter.filter(elm)).willReturn(false);
// When
final boolean isValid = validator.validate(elm);
// Then
assertFalse(isValid);
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class ElementValidatorTest method shouldReturnTrueWhenSchemaValidateWithValidElement.
@Test
public void shouldReturnTrueWhenSchemaValidateWithValidElement() {
// Given
final Schema schema = mock(Schema.class);
final String group = TestGroups.EDGE;
final Element elm = mock(Element.class);
final SchemaElementDefinition elementDef = mock(SchemaElementDefinition.class);
final ElementFilter filter = mock(ElementFilter.class);
final boolean includeIsA = true;
final ElementValidator validator = new ElementValidator(schema, includeIsA);
given(elm.getGroup()).willReturn(group);
given(schema.getElement(group)).willReturn(elementDef);
given(elementDef.getValidator(includeIsA)).willReturn(filter);
given(filter.filter(elm)).willReturn(true);
// When
final boolean isValid = validator.validate(elm);
// Then
assertTrue(isValid);
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class LoadAndQuery14 method run.
public Schema run() throws OperationException {
// [graph] create a graph using our schema and store properties
// ---------------------------------------------------------
final Graph graph = new Graph.Builder().addSchemas(getSchemas()).storeProperties(getStoreProperties()).build();
// ---------------------------------------------------------
final Schema schema = graph.getSchema();
try {
log("SCHEMA", new String(schema.toJson(true), CommonConstants.UTF_8));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
return schema;
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class LoadAndQuery14Test method shouldLoadSchema.
@Test
public void shouldLoadSchema() throws OperationException {
// Given
final LoadAndQuery14 query = new LoadAndQuery14();
// When
final Schema schema = query.run();
// Then
assertNotNull(schema);
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class BloomFilter18IT method setup.
@Before
public void setup() {
Schema schema = new Schema.Builder().type(TestTypes.PROP_INTEGER, Integer.class).vertexSerialiser(new JavaSerialiser()).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().property(AccumuloPropertyNames.INT, TestTypes.PROP_INTEGER).build()).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(AccumuloPropertyNames.INT, TestTypes.PROP_INTEGER).build()).build();
byteEntityRangeFactory = new ByteEntityRangeFactory(schema);
byteEntityElementConverter = new ByteEntityAccumuloElementConverter(schema);
Gaffer1RangeFactory = new ClassicRangeFactory(schema);
gafferV1ElementConverter = new ClassicAccumuloElementConverter(schema);
}
Aggregations