Search in sources :

Example 11 with Project

use of com.baidu.hugegraph.structure.auth.Project in project incubator-hugegraph-toolchain by apache.

the class ProjectApiTest method testRemoveGraph.

@Test
public void testRemoveGraph() {
    Set<String> graphs = ImmutableSet.of("test_graph1", "test_graph2", "test_graph3");
    Project project = createProject("project_test", graphs);
    graphs = new HashSet<>(graphs);
    Assert.assertTrue(graphs.containsAll(project.graphs()));
    project = api.removeGraphs(project, ImmutableSet.of("test_graph1"));
    graphs.remove("test_graph1");
    Assert.assertTrue(graphs.containsAll(project.graphs()));
    project = api.removeGraphs(project, ImmutableSet.of("test_graph2"));
    graphs.remove("test_graph2");
    Assert.assertTrue(graphs.containsAll(project.graphs()));
    project = api.removeGraphs(project, ImmutableSet.of("test_graph3"));
    graphs.remove("test_graph3");
    Assert.assertEquals(0, graphs.size());
    Assert.assertNull(project.graphs());
}
Also used : Project(com.baidu.hugegraph.structure.auth.Project) Test(org.junit.Test)

Example 12 with Project

use of com.baidu.hugegraph.structure.auth.Project in project incubator-hugegraph-toolchain by apache.

the class AuthManager method deleteAll.

public void deleteAll() {
    for (Belong belong : this.listBelongs()) {
        this.deleteBelong(belong.id());
    }
    for (Access access : this.listAccesses()) {
        this.deleteAccess(access.id());
    }
    for (User user : this.listUsers()) {
        if (user.name().equals("admin")) {
            continue;
        }
        this.deleteUser(user.id());
    }
    for (Group group : this.listGroups()) {
        this.deleteGroup(group.id());
    }
    for (Target target : this.listTargets()) {
        this.deleteTarget(target.id());
    }
    for (Project project : this.listProjects()) {
        Set<String> graphs = project.graphs();
        if (CollectionUtils.isNotEmpty(graphs)) {
            this.projectRemoveGraphs(project.id(), graphs);
        }
        this.deleteProject(project.id());
    }
}
Also used : Group(com.baidu.hugegraph.structure.auth.Group) Project(com.baidu.hugegraph.structure.auth.Project) Target(com.baidu.hugegraph.structure.auth.Target) User(com.baidu.hugegraph.structure.auth.User) Access(com.baidu.hugegraph.structure.auth.Access) Belong(com.baidu.hugegraph.structure.auth.Belong)

Aggregations

Project (com.baidu.hugegraph.structure.auth.Project)12 Test (org.junit.Test)7 RestResult (com.baidu.hugegraph.rest.RestResult)2 Access (com.baidu.hugegraph.structure.auth.Access)2 Belong (com.baidu.hugegraph.structure.auth.Belong)2 Group (com.baidu.hugegraph.structure.auth.Group)2 Target (com.baidu.hugegraph.structure.auth.Target)2 User (com.baidu.hugegraph.structure.auth.User)2 HugeClient (com.baidu.hugegraph.driver.HugeClient)1 HugeResource (com.baidu.hugegraph.structure.auth.HugeResource)1 Login (com.baidu.hugegraph.structure.auth.Login)1 LoginResult (com.baidu.hugegraph.structure.auth.LoginResult)1 TokenPayload (com.baidu.hugegraph.structure.auth.TokenPayload)1 UserRole (com.baidu.hugegraph.structure.auth.User.UserRole)1 AfterClass (org.junit.AfterClass)1