Search in sources :

Example 1 with FederatedStoreCache

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());
}
Also used : AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) FederatedStoreCache(uk.gov.gchq.gaffer.federatedstore.FederatedStoreCache) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) FederatedAccess(uk.gov.gchq.gaffer.federatedstore.FederatedAccess) Test(org.junit.jupiter.api.Test)

Example 2 with FederatedStoreCache

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();
}
Also used : AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) FederatedStoreCache(uk.gov.gchq.gaffer.federatedstore.FederatedStoreCache) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) RemoveGraph(uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph) Test(org.junit.jupiter.api.Test)

Example 3 with FederatedStoreCache

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();
}
Also used : FederatedStoreCache(uk.gov.gchq.gaffer.federatedstore.FederatedStoreCache) Test(org.junit.jupiter.api.Test)

Example 4 with FederatedStoreCache

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 });
}
Also used : AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) FederatedStoreCache(uk.gov.gchq.gaffer.federatedstore.FederatedStoreCache) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 FederatedStoreCache (uk.gov.gchq.gaffer.federatedstore.FederatedStoreCache)4 AddGraph (uk.gov.gchq.gaffer.federatedstore.operation.AddGraph)3 GetAllGraphIds (uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds)3 Schema (uk.gov.gchq.gaffer.store.schema.Schema)3 FederatedAccess (uk.gov.gchq.gaffer.federatedstore.FederatedAccess)1 RemoveGraph (uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph)1 GraphSerialisable (uk.gov.gchq.gaffer.graph.GraphSerialisable)1