Package org.nutz.dao.test.meta

Examples of org.nutz.dao.test.meta.Soldier


    TableName.run(platoon, new Atom() {
      public void run() {
        Tank t = dao.fetchLinks(dao.fetch(Tank.class, "M1-A1"), "motorman");
        t.getMotorman().setAge(32);
        dao.updateLinks(t, "motorman");
        Soldier s = dao.fetch(Soldier.class, t.getMotorName());
        assertEquals(32, s.getAge());
      }
    });
  }
View Full Code Here


      public void run() {
        Tank t = dao.fetchLinks(dao.fetch(Tank.class, "M1-A1"), "motorman");
        t.getMotorman().setAge(32);
        t.setWeight(50);
        dao.updateWith(t, "motorman");
        Soldier s = dao.fetch(Soldier.class, t.getMotorName());
        assertEquals(32, s.getAge());
        t = dao.fetch(Tank.class, t.getId());
        assertEquals(50, t.getWeight());
      }
    });
  }
View Full Code Here

  @Test
  public void delete_links() {
    TableName.run(platoon, new Atom() {
      public void run() {
        Soldier s = dao.fetchLinks(dao.fetch(Soldier.class, "ZZH"), "guns");
        assertEquals(3, s.getGuns().length);
        dao.deleteLinks(s, "guns");
        assertEquals(8, dao.count(Gun.class));
      }
    });
  }
View Full Code Here

  public void delete_links_partly() {
    TableName.run(platoon, new Atom() {
      public void run() {
        TableName.run(platoon, new Atom() {
          public void run() {
            Soldier s = dao.fetchLinks(dao.fetch(Soldier.class, "ZZH"), "guns");
            s.getGuns()[1] = null;
            dao.deleteLinks(s, "guns");
            assertEquals(9, dao.count(Gun.class));
          }
        });
      }
View Full Code Here

  @Test
  public void delete_with() {
    TableName.run(platoon, new Atom() {
      public void run() {
        Soldier s = dao.fetchLinks(dao.fetch(Soldier.class, "ZZH"), "guns");
        dao.deleteWith(s, "guns");
        assertEquals(4, dao.count(Soldier.class));
        assertEquals(8, dao.count(Gun.class));
      }
    });
View Full Code Here

  @Test
  public void delete_with_partly() {
    TableName.run(platoon, new Atom() {
      public void run() {
        Soldier s = dao.fetchLinks(dao.fetch(Soldier.class, "ZZH"), "guns");
        s.getGuns()[1] = null;
        dao.deleteWith(s, "guns");
        assertEquals(4, dao.count(Soldier.class));
        assertEquals(9, dao.count(Gun.class));
      }
    });
View Full Code Here

  @Test
  public void clear_links() {
    TableName.run(platoon, new Atom() {
      public void run() {
        Soldier s = dao.fetch(Soldier.class, "ZZH");
        dao.clearLinks(s, "guns");
        assertEquals(5, dao.count(Soldier.class));
        assertEquals(8, dao.count(Gun.class));
      }
    });
View Full Code Here

  @Test
  public void update_links() {
    TableName.run(platoon, new Atom() {
      public void run() {
        Soldier s = dao.fetchLinks(dao.fetch(Soldier.class, "ZZH"), "guns");
        s.setAge(25);
        s.getGuns()[0].setType(Gun.TYPE.AK47);
        s.getGuns()[1].setType(Gun.TYPE.AK47);
        s.getGuns()[2].setType(Gun.TYPE.AK47);
        dao.updateLinks(s, "guns");
        s = dao.fetchLinks(dao.fetch(Soldier.class, "ZZH"), "guns");
        assertEquals(0, s.getAge());
        assertEquals(3, s.getGuns().length);
        for (Gun gun : s.getGuns()) {
          assertEquals(Gun.TYPE.AK47, gun.getType());
        }
      }
    });
  }
View Full Code Here

  @Test
  public void update_with() {
    TableName.run(platoon, new Atom() {
      public void run() {
        Soldier s = dao.fetchLinks(dao.fetch(Soldier.class, "ZZH"), "guns");
        s.setAge(25);
        s.getGuns()[0].setType(Gun.TYPE.AK47);
        s.getGuns()[1].setType(Gun.TYPE.AK47);
        s.getGuns()[2].setType(Gun.TYPE.AK47);
        dao.updateWith(s, "guns");
        s = dao.fetchLinks(dao.fetch(Soldier.class, "ZZH"), "guns");
        assertEquals(25, s.getAge());
        assertEquals(3, s.getGuns().length);
        for (Gun gun : s.getGuns()) {
          assertEquals(Gun.TYPE.AK47, gun.getType());
        }
      }
    });
  }
View Full Code Here

    @Test
    public void delete_links() {
        TableName.run(platoon, new Atom() {
            public void run() {
                Soldier s = dao.fetchLinks(dao.fetch(Soldier.class, "ZZH"), "guns");
                assertEquals(3, s.getGuns().length);
                dao.deleteLinks(s, "guns");
                assertEquals(8, dao.count(Gun.class));
            }
        });
    }
View Full Code Here

TOP

Related Classes of org.nutz.dao.test.meta.Soldier

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.