Search in sources :

Example 6 with Base

use of org.nutz.dao.test.meta.Base in project nutz by nutzam.

the class OneTest method delete_with.

@Test
public void delete_with() {
    Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "country");
    dao.deleteWith(b, "country");
    assertEquals(1, dao.count(Country.class));
    assertEquals(1, dao.count(Base.class));
}
Also used : Country(org.nutz.dao.test.meta.Country) Base(org.nutz.dao.test.meta.Base) Test(org.junit.Test)

Example 7 with Base

use of org.nutz.dao.test.meta.Base in project nutz by nutzam.

the class OneTest method update_links_as_list.

@Test
public void update_links_as_list() {
    List<Base> b = dao.fetchLinks(Lang.list(dao.fetch(Base.class, "red")), "country");
    int lv = b.get(0).getLevel();
    b.get(0).setLevel(45);
    b.get(0).getCountry().setName("ABC");
    dao.updateLinks(b, "country");
    b = Lang.list(dao.fetch(Base.class, "red"));
    assertEquals(lv, b.get(0).getLevel());
    Country c = dao.fetch(Country.class, b.get(0).getCountryId());
    assertEquals("ABC", c.getName());
}
Also used : Country(org.nutz.dao.test.meta.Country) Base(org.nutz.dao.test.meta.Base) Test(org.junit.Test)

Example 8 with Base

use of org.nutz.dao.test.meta.Base in project nutz by nutzam.

the class OneTest method fetch_links.

@Test
public void fetch_links() {
    Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "country");
    assertEquals("China", b.getCountry().getName());
}
Also used : Base(org.nutz.dao.test.meta.Base) Test(org.junit.Test)

Example 9 with Base

use of org.nutz.dao.test.meta.Base in project nutz by nutzam.

the class LinksGeneralTest method fetch_all_links.

@Test
public void fetch_all_links() {
    Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), null);
    assertEquals("red", b.getName());
    assertEquals("China", b.getCountry().getName());
    assertEquals(6, b.getFighters().size());
    assertEquals(3, b.getPlatoons().size());
}
Also used : Base(org.nutz.dao.test.meta.Base) Test(org.junit.Test)

Example 10 with Base

use of org.nutz.dao.test.meta.Base in project nutz by nutzam.

the class ManyManyTest method delete_with_partly.

@Test
public void delete_with_partly() {
    Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "fighters");
    b.getFighters().remove(0);
    b.getFighters().remove(0);
    dao.deleteWith(b, "fighters");
    assertEquals(9, dao.count(Fighter.class));
    assertEquals(1, dao.count(Base.class));
}
Also used : Fighter(org.nutz.dao.test.meta.Fighter) Base(org.nutz.dao.test.meta.Base) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)33 Base (org.nutz.dao.test.meta.Base)33 Fighter (org.nutz.dao.test.meta.Fighter)8 Country (org.nutz.dao.test.meta.Country)7 Platoon (org.nutz.dao.test.meta.Platoon)7 WaveBand (org.nutz.dao.test.meta.WaveBand)3 DaoException (org.nutz.dao.DaoException)1