Search in sources :

Example 6 with Project

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

the class ProjectAPI method addGraphs.

public Project addGraphs(Object projectId, Set<String> graphs) {
    Project project = new Project();
    project.graphs(graphs);
    RestResult result = this.client.put(this.path(), formatEntityId(projectId), project, ImmutableMap.of("action", ACTION_ADD_GRAPH));
    return result.readObject(Project.class);
}
Also used : Project(com.baidu.hugegraph.structure.auth.Project) RestResult(com.baidu.hugegraph.rest.RestResult)

Example 7 with Project

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

the class ProjectApiTest method createProject.

private static Project createProject(String name, Set<String> graphs) {
    Project project = new Project(name);
    project = api.create(project);
    project = api.addGraphs(project.id(), graphs);
    return project;
}
Also used : Project(com.baidu.hugegraph.structure.auth.Project)

Example 8 with Project

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

the class ProjectApiTest method testAddGraph.

@Test
public void testAddGraph() {
    Project project = createProject("project_test");
    api.addGraphs(project, ImmutableSet.of("test_graph"));
    project = getProject(project);
    Assert.assertEquals(1, project.graphs().size());
    Assert.assertTrue(project.graphs().contains("test_graph"));
    api.addGraphs(project, ImmutableSet.of("test_graph1"));
    project = getProject(project);
    Assert.assertEquals(2, project.graphs().size());
    Assert.assertTrue(project.graphs().contains("test_graph1"));
}
Also used : Project(com.baidu.hugegraph.structure.auth.Project) Test(org.junit.Test)

Example 9 with Project

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

the class ProjectApiTest method testCreate.

@Test
public void testCreate() {
    Project paramsProject = new Project("project_test", "project_description");
    Project createdProject = api.create(paramsProject);
    Assert.assertEquals(paramsProject.name(), createdProject.name());
    Assert.assertEquals(paramsProject.description(), createdProject.description());
}
Also used : Project(com.baidu.hugegraph.structure.auth.Project) Test(org.junit.Test)

Example 10 with Project

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

the class ProjectApiTest method testList.

@Test
public void testList() {
    Project project1 = createProject("project_test1");
    Project project2 = createProject("project_test2");
    Project project3 = createProject("project_test3");
    List<Project> allProject = api.list(API.NO_LIMIT);
    Assert.assertTrue(allProject.contains(project1));
    Assert.assertTrue(allProject.contains(project2));
    Assert.assertTrue(allProject.contains(project3));
    List<Project> projects = api.list(1);
    Assert.assertEquals(1, projects.size());
    Project project = projects.get(0);
    Assert.assertTrue(StringUtils.isNotEmpty(project.adminGroup()));
    Assert.assertTrue(StringUtils.isNotEmpty(project.opGroup()));
    Assert.assertTrue(StringUtils.isNotEmpty(project.target()));
    Assert.assertTrue(StringUtils.isNotEmpty(project.creator()));
    Assert.assertNotNull(project.createTime());
    Assert.assertNotNull(project.updateTime());
}
Also used : Project(com.baidu.hugegraph.structure.auth.Project) Test(org.junit.Test)

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