use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class GraphTest method shouldConstructGraphFromSchemaModules.
@Test
public void shouldConstructGraphFromSchemaModules() {
// Given
final StoreProperties storeProperties = new StoreProperties();
storeProperties.setStoreClass(StoreImpl.class.getName());
final Schema schemaModule1 = new Schema.Builder().type(TestTypes.PROP_STRING, new TypeDefinition.Builder().clazz(String.class).build()).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().property(TestPropertyNames.PROP_1, TestTypes.PROP_STRING).build()).build();
final Schema schemaModule2 = new Schema.Builder().type(TestTypes.PROP_INTEGER, new TypeDefinition.Builder().clazz(Integer.class).build()).edge(TestGroups.EDGE_2, new SchemaEdgeDefinition.Builder().property(TestPropertyNames.PROP_2, TestTypes.PROP_INTEGER).build()).build();
final Schema schemaModule3 = new Schema.Builder().entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(TestPropertyNames.PROP_1, TestTypes.PROP_STRING).build()).build();
final Schema schemaModule4 = new Schema.Builder().entity(TestGroups.ENTITY_2, new SchemaEntityDefinition.Builder().property(TestPropertyNames.PROP_2, TestTypes.PROP_INTEGER).build()).build();
// When
final Graph graph = new Graph.Builder().storeProperties(storeProperties).addSchema(schemaModule1).addSchema(schemaModule2).addSchema(schemaModule3).addSchema(schemaModule4).build();
// Then
final Schema schema = graph.getSchema();
schema.getEntity(TestGroups.ENTITY);
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class GraphTest method shouldCallAllGraphHooksAfterOperationExecuted.
@Test
public void shouldCallAllGraphHooksAfterOperationExecuted() throws OperationException {
// Given
final Operation operation = mock(Operation.class);
final OperationChain opChain = mock(OperationChain.class);
given(opChain.getOperations()).willReturn(Collections.singletonList(operation));
final User user = mock(User.class);
final GraphHook hook1 = mock(GraphHook.class);
final GraphHook hook2 = mock(GraphHook.class);
final Store store = mock(Store.class);
final Object result1 = mock(Object.class);
final Object result2 = mock(Object.class);
final Object result3 = mock(Object.class);
final Schema schema = new Schema();
given(store.getSchema()).willReturn(schema);
given(hook1.postExecute(result1, opChain, user)).willReturn(result2);
given(hook2.postExecute(result2, opChain, user)).willReturn(result3);
final Graph graph = new Graph.Builder().storeProperties(StreamUtil.storeProps(getClass())).store(store).addSchema(schema).addHook(hook1).addHook(hook2).build();
final ArgumentCaptor<OperationChain> captor = ArgumentCaptor.forClass(OperationChain.class);
given(store.execute(captor.capture(), Mockito.eq(user))).willReturn(result1);
// When
final Object actualResult = graph.execute(opChain, user);
// Then
final InOrder inOrder = inOrder(hook1, hook2);
inOrder.verify(hook1).postExecute(result1, captor.getValue(), user);
inOrder.verify(hook2).postExecute(result2, captor.getValue(), user);
final List<Operation> ops = captor.getValue().getOperations();
assertEquals(1, ops.size());
assertSame(operation, ops.get(0));
assertSame(actualResult, result3);
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class GafferResultCacheUtilTest method shouldCreateGraphWithValidSchemaWithoutAgeOff.
@Test
public void shouldCreateGraphWithValidSchemaWithoutAgeOff() {
// Given
final Graph graph = GafferResultCacheUtil.createGraph(StreamUtil.STORE_PROPERTIES, null);
final Schema schema = graph.getSchema();
// When
final boolean isValid = schema.validate();
// Then
assertTrue(isValid);
assertNull(schema.getType("timestamp").getValidator());
assertTrue(new ElementValidator(schema).validate(validEdge));
assertTrue(new ElementValidator(schema).validate(oldEdge));
assertTrue(schema.validate());
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class JcsJobTrackerIT method setup.
@Before
public void setup() throws Exception {
final StoreProperties storeProps = StoreProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
store = Class.forName(storeProps.getStoreClass()).asSubclass(Store.class).newInstance();
store.initialise(new Schema(), storeProps);
graph = new Graph.Builder().store(store).build();
clearJobTracker();
}
use of uk.gov.gchq.gaffer.store.schema.Schema in project Gaffer by gchq.
the class SingleUseMockAccumuloProxyStore method initialise.
@Override
public void initialise(final Schema accumuloSchema, final StoreProperties proxyProps) throws StoreException {
startMockAccumuloRestApi(accumuloSchema);
super.initialise(new Schema(), proxyProps);
}
Aggregations