Package com.avaje.tests.model.basic

Examples of com.avaje.tests.model.basic.MRole


  @Test
  public void test() {

    // Create 2 roles r0 and r1
    MRole r0 = new MRole("r0");
    MRole r1 = new MRole("r1");

    // Save r1 and r2
    Ebean.save(r0);
    Ebean.save(r1);
View Full Code Here


public class TestM2MDeleteWithCascade extends BaseTestCase {

  @Test
  public void test() {

    MRole r0 = new MRole("r0");
    MRole r1 = new MRole("r1");

    Ebean.save(r0);
    // Ebean.save(r1);

    MUser u0 = new MUser("usr0");
    u0.addRole(r0);
    u0.addRole(r1);

    Ebean.save(u0);

    List<MRole> roles = u0.getRoles();

    // this will delete
    Ebean.delete(u0);

    MUser notThere = Ebean.find(MUser.class, u0.getUserid());
    Assert.assertNull("been deleted", notThere);

    List<Object> roleIds = new ArrayList<Object>();
    Collections.addAll(roleIds, r0.getRoleid(), r1.getRoleid());

    int rc = Ebean.find(MRole.class).where().idIn(roleIds).findRowCount();

    Assert.assertEquals("roles not deleted", 2, rc);
View Full Code Here

    Ebean.save(user1);
    MUser user2 = new MUser("two");
    user2.setUserType(ut);
    Ebean.save(user2);
   
    MRole roleA = new MRole("A");
    Ebean.save(roleA);
    MRole roleB = new MRole("B");
    Ebean.save(roleB);
   
    user1.addRole(roleA);
    Ebean.save(user1);
    user2.addRole(roleB);
View Full Code Here

  @Test
  public void test() {

    Ebean.beginTransaction();

    MRole r1 = new MRole();
    r1.setRoleName("role1");
    Ebean.save(r1);

    MRole r2 = new MRole();
    r2.setRoleName("role2special");
    Ebean.save(r2);

    MRole r3 = new MRole();
    r3.setRoleName("role3");
    Ebean.save(r3);

    MUser u0 = new MUser();
    u0.setUserName("user0");
    u0.addRole(r1);
View Full Code Here

    }
   
  }
 
  private void  createData() {
    MRole r0 = new MRole("r0");
    MRole r1 = new MRole("r1");

    Ebean.save(r0);
    Ebean.save(r1);

    MUser u0 = new MUser("usr0");
View Full Code Here

      }
    }

    Ebean.save(u);

    MRole r0 = new MRole();
    r0.setRoleName("rol_0");
    Ebean.save(r0);

    MRole r1 = new MRole();
    r1.setRoleName("rol_1");

    MUser u1 = Ebean.find(MUser.class, u.getUserid());

    u1.addRole(r0);
    u1.addRole(r1);
View Full Code Here

   
    Ebean.execute(delInt);
    Ebean.execute(delRoles);
    Ebean.execute(delUsers);
   
    MRole r1 = new MRole();
    r1.setRoleName("role1");
    Ebean.save(r1);

    MRole r2 = new MRole();
    r2.setRoleName("role2");
    Ebean.save(r2);

    MRole r3 = new MRole();
    r3.setRoleName("role3");
    Ebean.save(r3);

    MUser u0 = new MUser();
    u0.setUserName("something");
View Full Code Here

    Order updOrder = jsonContext.toBean(Order.class, jsonString);

    server.update(updOrder);

    MRole r1 = new MRole();
    r1.setRoleName("rolej1");
    Ebean.save(r1);

    MRole r2 = new MRole();
    r2.setRoleName("rolej2");
    Ebean.save(r2);

    MRole r3 = new MRole();
    r3.setRoleName("rolej3");
    Ebean.save(r3);

    MUser u0 = new MUser();
    u0.setUserName("userj1");
    u0.addRole(r1);
    u0.addRole(r2);
    u0.addRole(r3);

    Ebean.save(u0);

    String jsonUser = jsonContext.toJson(u0);

    System.out.println(jsonUser);

    String s = "{\"userid\":" + u0.getUserid()
        + ",\"userName\":\"userj1\", \"roles\":[{\"roleid\":" + r2.getRoleid() + "},{\"roleid\":"
        + r3.getRoleid() + "}]} ";

    MUser updMUser = jsonContext.toBean(MUser.class, s);

    server.update(updMUser);
View Full Code Here

  @Test
  public void test() {

    Ebean.beginTransaction();

    MRole r1 = new MRole();
    r1.setRoleName("role1");
    Ebean.save(r1);

    MRole r2 = new MRole();
    r2.setRoleName("role2special");
    Ebean.save(r2);

    MRole r3 = new MRole();
    r3.setRoleName("role3");
    Ebean.save(r3);

    MUser u0 = new MUser();
    u0.setUserName("user0");
    u0.addRole(r1);
View Full Code Here

TOP

Related Classes of com.avaje.tests.model.basic.MRole

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.