Search in sources :

Example 16 with GetAllGraphIds

use of uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds in project Gaffer by gchq.

the class FederatedAdminIT method shouldChangeGraphIdForOwnGraph.

@Test
public void shouldChangeGraphIdForOwnGraph() throws Exception {
    // given
    final String graphA = "graphTableA";
    final String graphB = "graphTableB";
    Connector connector = TableUtils.getConnector(ACCUMULO_PROPERTIES.getInstance(), ACCUMULO_PROPERTIES.getZookeepers(), ACCUMULO_PROPERTIES.getUser(), ACCUMULO_PROPERTIES.getPassword());
    graph.execute(new AddGraph.Builder().graphId(graphA).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).graphAuths("Auths1").build(), user);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
    // when
    boolean tableGraphABefore = connector.tableOperations().exists(graphA);
    boolean tableGraphBBefore = connector.tableOperations().exists(graphB);
    final Boolean changed = graph.execute(new ChangeGraphId.Builder().graphId(graphA).newGraphId(graphB).build(), user);
    boolean tableGraphAfter = connector.tableOperations().exists(graphA);
    boolean tableGraphBAfter = connector.tableOperations().exists(graphB);
    // then
    assertThat(changed).isTrue();
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).doesNotContain(graphA).contains(graphB);
    assertThat(tableGraphABefore).isTrue();
    assertThat(tableGraphBBefore).isFalse();
    assertThat(tableGraphAfter).isFalse();
    assertThat(tableGraphBAfter).isTrue();
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) Test(org.junit.jupiter.api.Test)

Example 17 with GetAllGraphIds

use of uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds in project Gaffer by gchq.

the class FederatedAdminIT method shouldChangeGraphUserFromOwnGraphToReplacementUser.

@Test
public void shouldChangeGraphUserFromOwnGraphToReplacementUser() throws Exception {
    // given
    final String graphA = "graphA";
    final User replacementUser = new User("replacement");
    graph.execute(new AddGraph.Builder().graphId(graphA).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).graphAuths("Auths1").build(), user);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), replacementUser))).doesNotContain(graphA);
    // when
    final Boolean changed = graph.execute(new ChangeGraphAccess.Builder().graphId(graphA).ownerUserId(replacementUser.getUserId()).build(), user);
    // then
    assertThat(changed).isTrue();
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).doesNotContain(graphA);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), replacementUser))).contains(graphA);
}
Also used : User(uk.gov.gchq.gaffer.user.User) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) Test(org.junit.jupiter.api.Test)

Example 18 with GetAllGraphIds

use of uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds 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)

Example 19 with GetAllGraphIds

use of uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds in project Gaffer by gchq.

the class FederatedAdminIT method shouldGetGraphInfoForSelectedGraphsOnly.

@Test
public void shouldGetGraphInfoForSelectedGraphsOnly() throws Exception {
    // given
    final String graphA = "graphA";
    graph.execute(new AddGraph.Builder().graphId(graphA).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).graphAuths("authsValueA").build(), user);
    final String graphB = "graphB";
    graph.execute(new AddGraph.Builder().graphId(graphB).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).graphAuths("authsValueB").build(), user);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA, graphB);
    final FederatedAccess expectedFedAccess = new FederatedAccess.Builder().addingUserId(user.getUserId()).graphAuths("authsValueB").makePrivate().build();
    // when
    final Map<String, Object> allGraphsAndAuths = graph.execute(new GetAllGraphInfo.Builder().option(KEY_OPERATION_OPTIONS_GRAPH_IDS, graphB).build(), user);
    // then
    assertThat(allGraphsAndAuths).hasSize(1).hasSize(1);
    assertThat(allGraphsAndAuths.keySet().toArray(new String[] {})[0]).isEqualTo(graphB);
    assertThat(allGraphsAndAuths.values().toArray(new Object[] {})[0]).isEqualTo(expectedFedAccess);
}
Also used : GetAllGraphInfo(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphInfo) 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 20 with GetAllGraphIds

use of uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds in project Gaffer by gchq.

the class OperationControllerIT method shouldReturnHelpfulErrorMessageIfOperationIsUnsupported.

@Test
public void shouldReturnHelpfulErrorMessageIfOperationIsUnsupported() {
    // Given
    Graph graph = new Graph.Builder().config(StreamUtil.graphConfig(this.getClass())).storeProperties(new MapStoreProperties()).addSchema(new Schema()).build();
    when(getGraphFactory().getGraph()).thenReturn(graph);
    // When
    final ResponseEntity<Error> response = post("/graph/operations/execute", new GetAllGraphIds(), Error.class);
    // Then
    assertNotNull(response.getBody().getSimpleMessage());
    assertTrue(response.getBody().getSimpleMessage().contains("GetAllGraphIds is not supported by the MapStore"));
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Error(uk.gov.gchq.gaffer.core.exception.Error) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.Test)

Aggregations

GetAllGraphIds (uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds)20 Test (org.junit.jupiter.api.Test)15 Schema (uk.gov.gchq.gaffer.store.schema.Schema)15 User (uk.gov.gchq.gaffer.user.User)6 AddGraph (uk.gov.gchq.gaffer.federatedstore.operation.AddGraph)5 FederatedAccess (uk.gov.gchq.gaffer.federatedstore.FederatedAccess)3 FederatedStoreCache (uk.gov.gchq.gaffer.federatedstore.FederatedStoreCache)3 RemoveGraph (uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph)3 Graph (uk.gov.gchq.gaffer.graph.Graph)3 ChangeGraphAccess (uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphAccess)2 ChangeGraphId (uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphId)2 GetAllGraphInfo (uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphInfo)2 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)2 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)2 Connector (org.apache.accumulo.core.client.Connector)1 Test (org.junit.Test)1 HashMapCacheService (uk.gov.gchq.gaffer.cache.impl.HashMapCacheService)1 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)1 Error (uk.gov.gchq.gaffer.core.exception.Error)1 Element (uk.gov.gchq.gaffer.data.element.Element)1