use of uk.gov.gchq.gaffer.federatedstore.FederatedStoreCache in project Gaffer by gchq.
the class FederatedAdminIT method shouldChangeGraphAccessIdInCache.
@Test
public void shouldChangeGraphAccessIdInCache() throws Exception {
// given
FederatedStoreCache federatedStoreCache = new FederatedStoreCache();
final String graphA = "graphA";
graph.execute(new AddGraph.Builder().graphId(graphA).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).build(), user);
assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
// when
FederatedAccess before = federatedStoreCache.getAccessFromCache(graphA);
final Boolean changed = graph.execute(new ChangeGraphAccess.Builder().graphId(graphA).ownerUserId(ADMIN_USER.getUserId()).build(), user);
FederatedAccess after = federatedStoreCache.getAccessFromCache(graphA);
// then
assertThat(changed).isTrue();
assertThat(after).isNotEqualTo(before);
assertThat(before.getAddingUserId()).isEqualTo(user.getUserId());
assertThat(after.getAddingUserId()).isEqualTo(ADMIN_USER.getUserId());
}
use of uk.gov.gchq.gaffer.federatedstore.FederatedStoreCache in project Gaffer by gchq.
the class FederatedAdminIT method shouldRemoveGraphFromCache.
@Test
public void shouldRemoveGraphFromCache() throws Exception {
// given
FederatedStoreCache federatedStoreCache = new FederatedStoreCache();
final String graphA = "graphA";
graph.execute(new AddGraph.Builder().graphId(graphA).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).build(), user);
assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
// when
assertThat(federatedStoreCache.getGraphSerialisableFromCache(graphA)).isNotNull();
final Boolean removed = graph.execute(new RemoveGraph.Builder().graphId(graphA).build(), user);
// then
assertThat(removed).isTrue();
GraphSerialisable graphSerialisableFromCache = federatedStoreCache.getGraphSerialisableFromCache(graphA);
assertThat(graphSerialisableFromCache).as(new String(JSONSerialiser.serialise(graphSerialisableFromCache, true))).isNull();
assertThat(federatedStoreCache.getAllGraphIds()).isEmpty();
}
use of uk.gov.gchq.gaffer.federatedstore.FederatedStoreCache in project Gaffer by gchq.
the class FederatedAdminIT method shouldStartWithEmptyCache.
@Test
public void shouldStartWithEmptyCache() throws Exception {
// given
FederatedStoreCache federatedStoreCache = new FederatedStoreCache();
// then
assertThat(federatedStoreCache.getAllGraphIds()).isEmpty();
}
use of uk.gov.gchq.gaffer.federatedstore.FederatedStoreCache in project Gaffer by gchq.
the class FederatedAdminIT method shouldChangeGraphIdInCache.
@Test
public void shouldChangeGraphIdInCache() throws Exception {
// given
String newName = "newName";
FederatedStoreCache federatedStoreCache = new FederatedStoreCache();
final String graphA = "graphA";
graph.execute(new AddGraph.Builder().graphId(graphA).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).build(), user);
assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
// when
final Boolean changed = graph.execute(new ChangeGraphId.Builder().graphId(graphA).newGraphId(newName).build(), user);
// then
Set<String> graphIds = federatedStoreCache.getAllGraphIds();
assertThat(changed).isTrue();
assertThat(graphIds.toArray()).as(graphIds.toString()).containsExactly(new String[] { newName });
}
Aggregations