use of uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary in project Gaffer by gchq.
the class FederatedStoreTest method setUp.
@BeforeEach
public void setUp() throws Exception {
clearCache();
federatedProperties = new FederatedStoreProperties();
federatedProperties.set(HashMapCacheService.STATIC_CACHE, String.valueOf(true));
clearLibrary();
library = new HashMapGraphLibrary();
library.addProperties(ID_PROPS_ACC_1, PROPERTIES_1);
library.addProperties(ID_PROPS_ACC_2, PROPERTIES_2);
library.addProperties(ID_PROPS_ACC_ALT, PROPERTIES_ALT);
library.addSchema(ID_SCHEMA_EDGE, getSchemaFromPath(PATH_BASIC_EDGE_SCHEMA_JSON));
library.addSchema(ID_SCHEMA_ENTITY, getSchemaFromPath(PATH_BASIC_ENTITY_SCHEMA_JSON));
store = new FederatedStore();
store.setGraphLibrary(library);
store.initialise(FEDERATED_STORE_ID, null, federatedProperties);
userContext = new Context(blankUser());
blankUser = blankUser();
ignore = new IgnoreOptions();
}
use of uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary in project Gaffer by gchq.
the class FederatedAddGraphHandlerTest method shouldAddGraphUsingLibrary.
@Test
public void shouldAddGraphUsingLibrary() throws Exception {
store.initialise(FEDERATEDSTORE_GRAPH_ID, null, federatedStoreProperties);
Schema expectedSchema = new Schema.Builder().build();
assertEquals(0, store.getGraphs(testUser, null, ignore).size());
assertEquals(0, store.getGraphs(testUser, null, ignore).size());
FederatedAddGraphHandler federatedAddGraphHandler = new FederatedAddGraphHandler();
federatedAddGraphHandler.doOperation(new AddGraph.Builder().graphId(EXPECTED_GRAPH_ID).schema(expectedSchema).storeProperties(PROPERTIES).build(), new Context(testUser), store);
Collection<Graph> graphs = store.getGraphs(testUser, null, ignore);
assertThat(graphs).hasSize(1);
Graph next = graphs.iterator().next();
assertEquals(EXPECTED_GRAPH_ID, next.getGraphId());
assertEquals(expectedSchema, next.getSchema());
final GraphLibrary library = new HashMapGraphLibrary();
library.add(EXPECTED_GRAPH_ID_2, expectedSchema, PROPERTIES);
store.setGraphLibrary(library);
federatedAddGraphHandler.doOperation(new AddGraph.Builder().graphId(EXPECTED_GRAPH_ID_2).build(), new Context(testUser), store);
graphs = store.getGraphs(testUser, null, ignore);
assertThat(graphs).hasSize(2);
Iterator<Graph> iterator = graphs.iterator();
final HashSet<String> set = Sets.newHashSet();
while (iterator.hasNext()) {
set.add(iterator.next().getGraphId());
}
assertThat(set).contains(EXPECTED_GRAPH_ID, EXPECTED_GRAPH_ID_2);
}
Aggregations