Search in sources :

Example 6 with Role

use of com.github.drinkjava2.functionstest.entitynet.entities.Role in project jSqlBox by drinkjava2.

the class EntityNetDemoTest method testAutoPath.

@Test
public void testAutoPath() {
    insertDemoData();
    EntityNet net = ctx.netLoad(new User(), new Role(), Privilege.class, UserRole.class, RolePrivilege.class);
    Set<Privilege> privileges = net.findEntitySet(Privilege.class, new Path(User.class).where("id='u1' or id='u2'").autoPath(Privilege.class));
    for (Privilege privilege : privileges) System.out.print(privilege.getId() + " ");
    Assert.assertEquals(3, privileges.size());
}
Also used : UserRole(com.github.drinkjava2.functionstest.entitynet.entities.UserRole) Role(com.github.drinkjava2.functionstest.entitynet.entities.Role) Path(com.github.drinkjava2.jsqlbox.entitynet.Path) User(com.github.drinkjava2.functionstest.entitynet.entities.User) EntityNet(com.github.drinkjava2.jsqlbox.entitynet.EntityNet) RolePrivilege(com.github.drinkjava2.functionstest.entitynet.entities.RolePrivilege) Privilege(com.github.drinkjava2.functionstest.entitynet.entities.Privilege) Test(org.junit.Test)

Example 7 with Role

use of com.github.drinkjava2.functionstest.entitynet.entities.Role in project jSqlBox by drinkjava2.

the class EntityNetDemoTest method testAutoPathAndBind.

@Test
public void testAutoPathAndBind() {
    insertDemoData();
    EntityNet net = ctx.netLoad(new User(), new Role(), Privilege.class, UserRole.class, RolePrivilege.class);
    Set<Privilege> privileges = net.findEntitySet(Privilege.class, new Path(User.class).where("id='u1' or id='u2'").autoPath(Privilege.class));
    for (Privilege privilege : privileges) System.out.print(privilege.getId() + " ");
    Assert.assertEquals(3, privileges.size());
}
Also used : UserRole(com.github.drinkjava2.functionstest.entitynet.entities.UserRole) Role(com.github.drinkjava2.functionstest.entitynet.entities.Role) Path(com.github.drinkjava2.jsqlbox.entitynet.Path) User(com.github.drinkjava2.functionstest.entitynet.entities.User) EntityNet(com.github.drinkjava2.jsqlbox.entitynet.EntityNet) RolePrivilege(com.github.drinkjava2.functionstest.entitynet.entities.RolePrivilege) Privilege(com.github.drinkjava2.functionstest.entitynet.entities.Privilege) Test(org.junit.Test)

Example 8 with Role

use of com.github.drinkjava2.functionstest.entitynet.entities.Role in project jSqlBox by drinkjava2.

the class EntityNetDemoTest method testloadEntityNet.

@Test
public void testloadEntityNet() {
    insertDemoData();
    EntityNet net = ctx.netLoad(new User(), Email.class, Address.class, new Role(), Privilege.class, UserRole.class, RolePrivilege.class);
    Assert.assertEquals(37, net.size());
    System.out.println(net.size());
    List<User> users = net.getAllEntityList(User.class);
    Assert.assertEquals(5, users.size());
    Assert.assertEquals("user1", users.get(0).getUserName());
    System.out.println(users.get(0).getUserName());
}
Also used : UserRole(com.github.drinkjava2.functionstest.entitynet.entities.UserRole) Role(com.github.drinkjava2.functionstest.entitynet.entities.Role) User(com.github.drinkjava2.functionstest.entitynet.entities.User) EntityNet(com.github.drinkjava2.jsqlbox.entitynet.EntityNet) Test(org.junit.Test)

Aggregations

User (com.github.drinkjava2.functionstest.entitynet.entities.User)8 Role (com.github.drinkjava2.functionstest.entitynet.entities.Role)7 UserRole (com.github.drinkjava2.functionstest.entitynet.entities.UserRole)7 Test (org.junit.Test)7 EntityNet (com.github.drinkjava2.jsqlbox.entitynet.EntityNet)6 Privilege (com.github.drinkjava2.functionstest.entitynet.entities.Privilege)5 RolePrivilege (com.github.drinkjava2.functionstest.entitynet.entities.RolePrivilege)5 Path (com.github.drinkjava2.jsqlbox.entitynet.Path)4 Email (com.github.drinkjava2.functionstest.entitynet.entities.Email)2 Address (com.github.drinkjava2.functionstest.entitynet.entities.Address)1