use of com.baidu.hugegraph.auth.HugeProject in project incubator-hugegraph by apache.
the class AuthTest method testUpdateProject.
@Test
public void testUpdateProject() {
HugeProject project = makeProject("test_project", "this is a desc");
AuthManager authManager = graph().authManager();
Id projectId = authManager.createProject(project);
project = authManager.getProject(projectId);
project.description("this is a desc another");
projectId = authManager.updateProject(project);
HugeProject newProject = authManager.getProject(projectId);
Assert.assertEquals("this is a desc another", newProject.description());
}
use of com.baidu.hugegraph.auth.HugeProject in project incubator-hugegraph by apache.
the class AuthTest method testDelProject.
@Test
public void testDelProject() {
HugeProject project = makeProject("test_project", null);
AuthManager authManager = graph().authManager();
Id projectId = authManager.createProject(project);
Assert.assertNotNull(projectId);
HugeProject deletedProject = authManager.deleteProject(projectId);
Assert.assertThrows(NotFoundException.class, () -> {
authManager.getProject(projectId);
});
Assert.assertThrows(NotFoundException.class, () -> {
authManager.getGroup(IdGenerator.of(deletedProject.adminGroupId()));
});
Assert.assertThrows(NotFoundException.class, () -> {
authManager.getGroup(IdGenerator.of(deletedProject.opGroupId()));
});
Assert.assertThrows(NotFoundException.class, () -> {
authManager.getTarget(IdGenerator.of(deletedProject.targetId()));
});
}
use of com.baidu.hugegraph.auth.HugeProject in project incubator-hugegraph by apache.
the class AuthTest method testProjectAddGraph.
@Test
public void testProjectAddGraph() {
HugeProject project = makeProject("test_project", "");
AuthManager authManager = graph().authManager();
Id projectId = authManager.createProject(project);
projectId = authManager.projectAddGraphs(projectId, ImmutableSet.of("graph_test"));
Assert.assertNotNull(projectId);
project = authManager.getProject(projectId);
Assert.assertFalse(project.graphs().isEmpty());
}
use of com.baidu.hugegraph.auth.HugeProject in project incubator-hugegraph by apache.
the class AuthTest method makeProject.
private static HugeProject makeProject(String name, String desc) {
HugeProject project = new HugeProject(name, desc);
project.creator("admin");
return project;
}
use of com.baidu.hugegraph.auth.HugeProject in project incubator-hugegraph by apache.
the class AuthTest method testCreateProject.
@Test
public void testCreateProject() {
HugeGraph graph = graph();
HugeProject project = makeProject("test_project", "this is a test project");
Id id = graph.authManager().createProject(project);
Assert.assertNotNull(id);
project = graph.authManager().getProject(id);
Assert.assertNotNull(project);
Assert.assertEquals("this is a test project", project.description());
Assert.assertEquals("test_project", project.name());
Assert.assertNotNull(project.adminGroupId());
Assert.assertNotNull(project.opGroupId());
Assert.assertNotNull(project.targetId());
// Check name is unique index
HugeProject sameNameProject = makeProject("test_project", "this is a test " + "project another");
Assert.assertThrows(HugeException.class, () -> {
graph.authManager().createProject(sameNameProject);
});
}
Aggregations