use of uk.gov.gchq.gaffer.graph.GraphSerialisable in project Gaffer by gchq.
the class FederatedStoreGetTraitsTest method shouldGetNonCurrentTraitsForAddingUserButSelectedGraphsOnly.
@Test
public void shouldGetNonCurrentTraitsForAddingUserButSelectedGraphsOnly() throws Exception {
// given
final GraphSerialisable acc2 = new GraphSerialisable.Builder().graph(acc.getGraph()).config(new GraphConfig(GRAPH_ID_ACCUMULO + 2)).build();
federatedStore.addGraphs(ACCESS_UNUSED_AUTH_AND_USER, acc);
federatedStore.addGraphs(ACCESS_UNUSED_AUTH_WITH_TEST_USER, acc2);
federatedStore.addGraphs(ACCESS_UNUSED_AUTH_WITH_TEST_USER, map);
getTraits.addOption(FederatedStoreConstants.KEY_OPERATION_OPTIONS_GRAPH_IDS, GRAPH_ID_MAP);
getTraits.setCurrentTraits(false);
// when
final Set<StoreTrait> traits = federatedStore.execute(getTraits, testUserContext);
// then
assertNotEquals(ACCUMULO_TRAITS, traits, "Returning AccumuloStore traits instead of MapStore");
assertEquals(Collections.emptySet(), traits.stream().filter(ACCUMULO_TRAITS_EXCLUSIVE_OF_MAP::contains).collect(Collectors.toSet()), "Revealing some hidden traits from the AccumuloStore instead of only MapStore");
assertEquals(MAP_TRAITS, traits);
}
use of uk.gov.gchq.gaffer.graph.GraphSerialisable in project Gaffer by gchq.
the class FederatedStoreGetTraitsTest method shouldGetCurrentTraitsForAddingUserButSelectedGraphsOnly.
@Test
public void shouldGetCurrentTraitsForAddingUserButSelectedGraphsOnly() throws Exception {
// given
final GraphSerialisable acc2 = new GraphSerialisable.Builder().graph(acc.getGraph()).config(new GraphConfig(GRAPH_ID_ACCUMULO + 2)).build();
federatedStore.addGraphs(ACCESS_UNUSED_AUTH_AND_USER, acc);
federatedStore.addGraphs(ACCESS_UNUSED_AUTH_WITH_TEST_USER, acc2);
federatedStore.addGraphs(ACCESS_UNUSED_AUTH_WITH_TEST_USER, map);
getTraits.addOption(FederatedStoreConstants.KEY_OPERATION_OPTIONS_GRAPH_IDS, GRAPH_ID_MAP);
// when
final Set<StoreTrait> traits = federatedStore.execute(getTraits, testUserContext);
// then
assertNotEquals(ACCUMULO_TRAITS, traits, "Returning AccumuloStore traits instead of MapStore");
assertEquals(Collections.emptySet(), traits.stream().filter(ACCUMULO_TRAITS_EXCLUSIVE_OF_MAP::contains).collect(Collectors.toSet()), "Revealing some hidden traits from the AccumuloStore instead of only MapStore");
assertEquals(MAP_CURRENT_TRAITS, traits);
}
use of uk.gov.gchq.gaffer.graph.GraphSerialisable in project Gaffer by gchq.
the class FederatedAddGraphHandlerParent method doOperation.
@Override
public Void doOperation(final OP operation, final Context context, final Store store) throws OperationException {
final User user = context.getUser();
boolean isLimitedToLibraryProperties = ((FederatedStore) store).isLimitedToLibraryProperties(user);
if (isLimitedToLibraryProperties && null != operation.getStoreProperties()) {
throw new OperationException(String.format(USER_IS_LIMITED_TO_ONLY_USING_PARENT_PROPERTIES_ID_FROM_GRAPHLIBRARY_BUT_FOUND_STORE_PROPERTIES_S, operation.getProperties().toString()));
}
final GraphSerialisable graphSerialisable;
try {
graphSerialisable = _makeGraph(operation, store);
} catch (final Exception e) {
throw new OperationException(String.format(ERROR_BUILDING_GRAPH_GRAPH_ID_S, operation.getGraphId()), e);
}
try {
((FederatedStore) store).addGraphs(operation.getGraphAuths(), context.getUser().getUserId(), operation.getIsPublic(), operation.isDisabledByDefault(), operation.getReadAccessPredicate(), operation.getWriteAccessPredicate(), graphSerialisable);
} catch (final StorageException e) {
throw new OperationException(e.getMessage(), e);
} catch (final Exception e) {
throw new OperationException(String.format(ERROR_ADDING_GRAPH_GRAPH_ID_S, operation.getGraphId()), e);
}
addGenericHandler((FederatedStore) store, graphSerialisable.getGraph());
return null;
}
use of uk.gov.gchq.gaffer.graph.GraphSerialisable in project Gaffer by gchq.
the class MapStorePropertiesGraphSerialisableTest method shouldConsumeGraph.
@Test
public void shouldConsumeGraph() throws Exception {
final MapStoreProperties mapStoreProperties = new MapStoreProperties();
mapStoreProperties.setProperties(properties);
final Graph graph = new Graph.Builder().addSchema(schema).addStoreProperties(mapStoreProperties).config(config).build();
final GraphSerialisable result = new GraphSerialisable.Builder().graph(graph).build();
assertEquals(expected, result);
}
use of uk.gov.gchq.gaffer.graph.GraphSerialisable in project Gaffer by gchq.
the class MapStorePropertiesGraphSerialisableTest method shouldSerialiseAndDeserialise.
@Test
public void shouldSerialiseAndDeserialise() throws Exception {
final JavaSerialiser javaSerialiser = new JavaSerialiser();
final byte[] serialise = javaSerialiser.serialise(expected);
final GraphSerialisable result = (GraphSerialisable) javaSerialiser.deserialise(serialise);
assertEquals(expected, result);
}
Aggregations