use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class HyperLogLogPlusAggregatorTest method shouldJsonSerialiseAndDeserialise.
@Test
public void shouldJsonSerialiseAndDeserialise() throws SerialisationException {
// Given
final HyperLogLogPlusAggregator aggregator = new HyperLogLogPlusAggregator();
// When 1
final String json = new String(new JSONSerialiser().serialise(aggregator, true));
// Then 1
JsonUtil.assertEquals(String.format("{%n" + " \"class\" : \"uk.gov.gchq.gaffer.sketches.function.aggregate.HyperLogLogPlusAggregator\"%n" + "}"), json);
// When 2
final HyperLogLogPlusAggregator deserialisedAggregator = new JSONSerialiser().deserialise(json.getBytes(), HyperLogLogPlusAggregator.class);
// Then 2
assertNotNull(deserialisedAggregator);
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class LoadAndQuery6Test method shouldReturnExpectedStringsViaJson.
@Test
public void shouldReturnExpectedStringsViaJson() throws OperationException, SerialisationException {
// Given
final User user01 = new User("user01");
final JSONSerialiser serialiser = new JSONSerialiser();
final OperationChain<?> addOpChain = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/load.json"), OperationChain.class);
final OperationChain<CloseableIterable<String>> queryOpChain = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/query.json"), OperationChain.class);
// Setup graph
final Graph graph = new Graph.Builder().storeProperties(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_PREFIX + "mockaccumulostore.properties")).addSchemas(StreamUtil.openStreams(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "schema")).build();
// When
// Execute the add operation chain on the graph
graph.execute(addOpChain, user01);
// Execute the query operation on the graph.
final CloseableIterable<String> results = graph.execute(queryOpChain, user01);
// Then
verifyResults(results);
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class LoadAndQuery7Test method shouldReturnExpectedStringsViaJson.
@Test
public void shouldReturnExpectedStringsViaJson() throws OperationException, SerialisationException {
// Given
final User user01 = new User("user01");
final JSONSerialiser serialiser = new JSONSerialiser();
final OperationChain<?> addOpChain = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/load.json"), OperationChain.class);
final OperationChain<Iterable<Edge>> queryOpChain = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/query.json"), OperationChain.class);
// Setup graph
final Graph graph = new Graph.Builder().storeProperties(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_PREFIX + "mockaccumulostore.properties")).addSchemas(StreamUtil.openStreams(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "schema")).build();
// When
// Execute the add operation chain on the graph
graph.execute(addOpChain, user01);
// Execute the query operation on the graph.
final Iterable<Edge> results = graph.execute(queryOpChain, user01);
// Then
verifyResults(results);
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class LoadAndQuery8Test method shouldReturnExpectedStringsViaJson.
@Test
public void shouldReturnExpectedStringsViaJson() throws OperationException, SerialisationException {
// Given
final User publicUser = new User.Builder().userId("public user").dataAuths("public").build();
final JSONSerialiser serialiser = new JSONSerialiser();
final OperationChain<?> addOpChain = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/load.json"), OperationChain.class);
final GetAllEdges getAllEdges = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/query.json"), GetAllEdges.class);
// Setup graph
final Graph graph = new Graph.Builder().storeProperties(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_PREFIX + "mockaccumulostore.properties")).addSchemas(StreamUtil.openStreams(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "schema")).build();
// When
// Execute the add operation chain on the graph
graph.execute(addOpChain, publicUser);
// Execute the query operation on the graph.
final Iterable<Edge> results = graph.execute(getAllEdges, publicUser);
// Then
verifyResults(results);
}
use of uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser in project Gaffer by gchq.
the class LoadAndQuery9Test method shouldReturnExpectedEdgesViaJson.
@Test
public void shouldReturnExpectedEdgesViaJson() throws OperationException, SerialisationException {
// Given
final User user = new User("user01");
final JSONSerialiser serialiser = new JSONSerialiser();
final OperationChain<?> addOpChain = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/load.json"), OperationChain.class);
final GetAllEntities getRelatedEdges = serialiser.deserialise(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "json/query.json"), GetAllEntities.class);
// Setup graph
final Graph graph = new Graph.Builder().storeProperties(StreamUtil.openStream(LoadAndQuery.class, RESOURCE_PREFIX + "mockaccumulostore.properties")).addSchemas(StreamUtil.openStreams(LoadAndQuery.class, RESOURCE_EXAMPLE_PREFIX + "schema")).build();
// When
// Execute the add operation chain on the graph
graph.execute(addOpChain, user);
// Execute the query operation on the graph.
final Iterable<Entity> results = graph.execute(getRelatedEdges, user);
// Then
verifyResults(results);
}
Aggregations