use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldCreateNewGraphWithStoresSchema.
@Test
public void shouldCreateNewGraphWithStoresSchema() {
// Given
given(store.getSchema()).willReturn(schema);
given(store.getGraphLibrary()).willReturn(null);
final StoreProperties storeProperties1 = StoreProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).storeProperties(storeProperties1).build();
// When
Graph graph = createGraph(export);
// Then
assertEquals(GRAPH_ID + 1, graph.getGraphId());
assertEquals(schema, graph.getSchema());
assertEquals(storeProperties1, graph.getStoreProperties());
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class GraphSerialisableTest method setUp.
@BeforeEach
public void setUp() throws Exception {
config = new GraphConfig.Builder().graphId("testGraphId").addHook(new NamedViewResolver()).addHook(new FunctionAuthoriser(FunctionAuthoriserUtil.DEFAULT_UNAUTHORISED_FUNCTIONS)).view(new View.Builder().entity("e1").build()).build();
schema = new Schema.Builder().entity("e1", new SchemaEntityDefinition.Builder().vertex("string").build()).type("string", String.class).build();
final StoreProperties storeProperties = new StoreProperties();
storeProperties.setStoreClass(TestStore.class);
properties = storeProperties.getProperties();
expected = new GraphSerialisable.Builder().schema(schema).properties(properties).config(config).build();
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class GraphSerialisableTest method shouldConsumeGraph.
@Test
public void shouldConsumeGraph() {
// Given
final Graph graph = new Graph.Builder().addSchema(schema).addStoreProperties(new StoreProperties(properties)).config(config).build();
final GraphSerialisable result = new GraphSerialisable.Builder().graph(graph).build();
// When / Then
assertEquals(expected, result);
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class ExportToOtherGraphTest method shouldJSONSerialiseAndDeserialise.
@Test
public void shouldJSONSerialiseAndDeserialise() throws SerialisationException, JsonProcessingException {
// Given
final Schema schema = new Schema.Builder().entity(TestGroups.ENTITY, new SchemaEntityDefinition()).build();
final StoreProperties storeProperties = StoreProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
final ExportToOtherGraph op = new ExportToOtherGraph.Builder().graphId("graphId").parentSchemaIds("schema1", "schema2").parentStorePropertiesId("props1").schema(schema).storeProperties(storeProperties).build();
// When
final byte[] json = JSONSerialiser.serialise(op);
final ExportToOtherGraph deserialisedOp = JSONSerialiser.deserialise(json, op.getClass());
// Then
assertEquals("graphId", deserialisedOp.getGraphId());
assertEquals(Arrays.asList("schema1", "schema2"), deserialisedOp.getParentSchemaIds());
assertEquals("props1", deserialisedOp.getParentStorePropertiesId());
JsonAssert.assertEquals(schema.toJson(false), deserialisedOp.getSchema().toJson(false));
assertEquals(storeProperties, deserialisedOp.getStoreProperties());
}
use of uk.gov.gchq.gaffer.store.StoreProperties in project Gaffer by gchq.
the class OperationChainHandlerTest method shouldHandleNestedOperationChain.
@Test
public void shouldHandleNestedOperationChain() throws OperationException {
// Given
final OperationChainValidator opChainValidator = mock(OperationChainValidator.class);
final List<OperationChainOptimiser> opChainOptimisers = Collections.emptyList();
final OperationChainHandler opChainHandler = new OperationChainHandler(opChainValidator, opChainOptimisers);
final Context context = mock(Context.class);
final Store store = mock(Store.class);
final User user = mock(User.class);
final StoreProperties storeProperties = new StoreProperties();
final GetAdjacentIds op1 = mock(GetAdjacentIds.class);
final GetElements op2 = mock(GetElements.class);
final Limit op3 = mock(Limit.class);
final OperationChain opChain1 = new OperationChain(Arrays.asList(op1, op2));
final OperationChain opChain2 = new OperationChain(Arrays.asList(opChain1, op3));
final Entity entityA = new Entity.Builder().group(TestGroups.ENTITY).vertex("A").build();
final Entity entityB = new Entity.Builder().group(TestGroups.ENTITY).vertex("B").build();
given(context.getUser()).willReturn(user);
given(store.getProperties()).willReturn(storeProperties);
given(opChainValidator.validate(any(), any(), any())).willReturn(new ValidationResult());
given(store.handleOperation(op1, context)).willReturn(new WrappedCloseableIterable<>(Lists.newArrayList(new EntitySeed("A"), new EntitySeed("B"))));
given(store.handleOperation(op2, context)).willReturn(new WrappedCloseableIterable<>(Lists.newArrayList(entityA, entityB)));
given(store.handleOperation(op3, context)).willReturn(entityA);
// When
final Object result = opChainHandler.doOperation(opChain2, context, store);
// Then
assertSame(entityA, result);
}
Aggregations