Search in sources :

Example 11 with HugeBelong

use of com.baidu.hugegraph.auth.HugeBelong in project incubator-hugegraph by apache.

the class AuthTest method testListAllBelong.

@Test
public void testListAllBelong() {
    HugeGraph graph = graph();
    AuthManager authManager = graph.authManager();
    Id user = authManager.createUser(makeUser("tom", "pass1"));
    Id group1 = authManager.createGroup(makeGroup("group1"));
    Id group2 = authManager.createGroup(makeGroup("group2"));
    authManager.createBelong(makeBelong(user, group1));
    authManager.createBelong(makeBelong(user, group2));
    List<HugeBelong> belongs = authManager.listAllBelong(-1);
    Assert.assertEquals(2, belongs.size());
    Assert.assertEquals(ImmutableSet.of(group1, group2), ImmutableSet.of(belongs.get(0).target(), belongs.get(1).target()));
    Assert.assertEquals(0, authManager.listAllBelong(0).size());
    Assert.assertEquals(1, authManager.listAllBelong(1).size());
    Assert.assertEquals(2, authManager.listAllBelong(2).size());
    Assert.assertEquals(2, authManager.listAllBelong(3).size());
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) HugeBelong(com.baidu.hugegraph.auth.HugeBelong) AuthManager(com.baidu.hugegraph.auth.AuthManager) Id(com.baidu.hugegraph.backend.id.Id) Test(org.junit.Test)

Aggregations

HugeBelong (com.baidu.hugegraph.auth.HugeBelong)11 HugeGraph (com.baidu.hugegraph.HugeGraph)10 Id (com.baidu.hugegraph.backend.id.Id)7 AuthManager (com.baidu.hugegraph.auth.AuthManager)6 Test (org.junit.Test)6 Timed (com.codahale.metrics.annotation.Timed)4 Produces (jakarta.ws.rs.Produces)4 Consumes (jakarta.ws.rs.Consumes)2 GET (jakarta.ws.rs.GET)2 Path (jakarta.ws.rs.Path)2 Status (com.baidu.hugegraph.api.filter.StatusFilter.Status)1 NotFoundException (com.baidu.hugegraph.exception.NotFoundException)1 POST (jakarta.ws.rs.POST)1 PUT (jakarta.ws.rs.PUT)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1