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();
}
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);
}
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 });
}
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);
}
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"));
}
Aggregations