Search in sources :

Example 21 with Base

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

the class ManyTest method fetch_links.

@Test
public void fetch_links() {
    Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "platoons");
    assertEquals(3, b.getPlatoons().size());
    assertEquals(b.getName(), b.getPlatoons().get("C").getBaseName());
    assertEquals(b.getName(), b.getPlatoons().get("ES").getBaseName());
    assertEquals(b.getName(), b.getPlatoons().get("DT").getBaseName());
}
Also used : Base(org.nutz.dao.test.meta.Base) Test(org.junit.Test)

Example 22 with Base

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

the class ManyTest method update_with.

@Test
public void update_with() {
    Base b = dao.fetchLinks(dao.fetch(Base.class, "blue"), "platoons");
    b.setLevel(45);
    for (Iterator<Platoon> it = b.getPlatoons().values().iterator(); it.hasNext(); ) {
        it.next().setBaseName("red");
    }
    dao.updateWith(b, "platoons");
    b = dao.fetch(Base.class, "blue");
    assertEquals(45, b.getLevel());
    b = dao.fetchLinks(dao.fetch(Base.class, "red"), "platoons");
    assertEquals(6, b.getPlatoons().size());
}
Also used : Platoon(org.nutz.dao.test.meta.Platoon) Base(org.nutz.dao.test.meta.Base) Test(org.junit.Test)

Example 23 with Base

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

the class ManyTest method delete_links_partly.

@Test
public void delete_links_partly() {
    Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "platoons");
    b.getPlatoons().remove("C");
    dao.deleteLinks(b, "platoons");
    assertEquals(4, dao.count(Platoon.class));
}
Also used : Platoon(org.nutz.dao.test.meta.Platoon) Base(org.nutz.dao.test.meta.Base) Test(org.junit.Test)

Example 24 with Base

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

the class OneTest method update_with.

@Test
public void update_with() {
    Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "country");
    b.setLevel(6);
    b.getCountry().setName("ABC");
    dao.updateWith(b, "country");
    b = dao.fetch(Base.class, b.getName());
    assertEquals(6, b.getLevel());
    Country c = dao.fetch(Country.class, b.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 25 with Base

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

the class OneTest method update_links.

@Test
public void update_links() {
    Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "country");
    int lv = b.getLevel();
    b.setLevel(45);
    b.getCountry().setName("ABC");
    dao.updateLinks(b, "country");
    b = dao.fetch(Base.class, "red");
    assertEquals(lv, b.getLevel());
    Country c = dao.fetch(Country.class, b.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)

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