Search in sources :

Example 1 with Country

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

the class OneTest method delete_links.

@Test
public void delete_links() {
    Base b = dao.fetchLinks(dao.fetch(Base.class, "red"), "country");
    dao.deleteLinks(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 2 with Country

use of org.nutz.dao.test.meta.Country 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 3 with Country

use of org.nutz.dao.test.meta.Country 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 4 with Country

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

the class CustomizedSqlsTest method test_statice_null_field.

@Test
public void test_statice_null_field() {
    pojos.init();
    Sql sql = Sqls.create("INSERT INTO dao_country (name,detail) VALUES(@name,@detail)");
    sql.params().set("name", "ABC").set("detail", "haha");
    dao.execute(sql);
    assertEquals(1, dao.count("dao_country"));
    sql = Sqls.create("UPDATE dao_country SET detail=@detail WHERE name=@name");
    sql.params().set("name", "ABC").set("detail", null);
    dao.execute(sql);
    Country c = dao.fetch(Country.class, "ABC");
    assertNull(c.getDetail());
}
Also used : Country(org.nutz.dao.test.meta.Country) NutSql(org.nutz.dao.impl.sql.NutSql) Sql(org.nutz.dao.sql.Sql) Test(org.junit.Test)

Example 5 with Country

use of org.nutz.dao.test.meta.Country 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)

Aggregations

Test (org.junit.Test)8 Country (org.nutz.dao.test.meta.Country)8 Base (org.nutz.dao.test.meta.Base)7 NutSql (org.nutz.dao.impl.sql.NutSql)1 Sql (org.nutz.dao.sql.Sql)1