Search in sources :

Example 26 with Base

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

the class OneTest method update_with_as_list.

@Test
public void update_with_as_list() {
    List<Base> b = dao.fetchLinks(Lang.list(dao.fetch(Base.class, "red")), "country");
    b.get(0).setLevel(45);
    b.get(0).getCountry().setName("ABC");
    dao.updateWith(b, "country");
    b = Lang.list(dao.fetch(Base.class, b.get(0).getName()));
    assertEquals(45, 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 27 with Base

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

the class OneTest method clear_links.

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

Example 28 with Base

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

the class LinksGeneralTest method test_fetchLinks_cnd.

@Test
public void test_fetchLinks_cnd() {
    Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "wavebands", Cnd.where("value", ">", -1).asc("name"));
    assertNotNull(b);
    Base b2 = dao.fetchLinks(dao.fetch(Base.class, "red"), "platoons", Cnd.where("id", ">", 0).limit(1, 20).asc("name"));
    assertNotNull(b2);
}
Also used : Base(org.nutz.dao.test.meta.Base) Test(org.junit.Test)

Example 29 with Base

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

the class LinksGeneralTest method insert_links_with_exception.

@Test(expected = Exception.class)
public void insert_links_with_exception() {
    Base b = Base.make("Red");
    dao.insert(b);
    b.setCountry(Country.make(Strings.dup('C', 300)));
    dao.insertLinks(b, "country");
}
Also used : Base(org.nutz.dao.test.meta.Base) Test(org.junit.Test)

Example 30 with Base

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

the class ManyManyTest method fetch_links.

@Test
public void fetch_links() {
    Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "fighters");
    assertEquals(6, b.getFighters().size());
    assertEquals(1, b.countFighter(Fighter.TYPE.SU_35));
}
Also used : 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