Search in sources :

Example 16 with ExpectedDatabase

use of com.github.springtestdbunit.annotation.ExpectedDatabase in project mybatis.flying by limeng32.

the class ConditionInTest method testConditionIn4.

/**
 * 测试无外键情况下condition:in功能且变量类型为时间的情况
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn4.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn4.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/conditionInTest/testConditionIn4.xml")
public void testConditionIn4() {
    LoginLog_Condition lc = new LoginLog_Condition();
    List<Date> timeC = new ArrayList<>();
    Calendar c = Calendar.getInstance(), c2 = Calendar.getInstance();
    c.clear();
    c2.clear();
    c.set(1970, 0, 1, 8, 0, 0);
    c2.set(1970, 0, 1, 8, 0, 1);
    timeC.add(c.getTime());
    timeC.add(c2.getTime());
    lc.setLoginTimeIn(timeC);
    int count = loginLogService.count(lc);
    Assert.assertEquals(2, count);
}
Also used : Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) LoginLog_Condition(indi.mybatis.flying.pojo.condition.LoginLog_Condition) Date(java.util.Date) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 17 with ExpectedDatabase

use of com.github.springtestdbunit.annotation.ExpectedDatabase in project mybatis.flying by limeng32.

the class KeyGeneratorTest method test1.

@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/keyGeneratorTest/test1.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/keyGeneratorTest/test1.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/keyGeneratorTest/test1.xml")
public void test1() {
    Product product = productService.select("a");
    Assert.assertEquals("n", product.getName());
    Product product2 = new Product();
    product2.setName("n2");
    product2.setName2("asd");
    productService.insert(product2);
    Assert.assertEquals(32, product2.getId().length());
    Product p = new Product();
    p.setName("n2");
    Product product_ = productService.selectOne(p);
    Assert.assertEquals(32, product_.getId().length());
    Product product3 = new Product();
    product3.setId("cc");
    product3.setName("n3");
    productService.insert2(product3);
    Assert.assertEquals("cc", product3.getId());
    Product p2 = new Product();
    p2.setName("n3");
    Product product2_ = productService.selectOne(p2);
    Assert.assertEquals("cc", product2_.getId());
    Product product4 = new Product();
    product4.setId("dd");
    product4.setName("n4");
    productService.insert3(product4);
    Assert.assertEquals("dd", product4.getId());
    Product p3 = new Product();
    p3.setName("n4");
    Product product3_ = productService.selectOne(p3);
    Assert.assertEquals("dd", product3_.getId());
    Product product5 = new Product();
    product5.setName("n5");
    productService.insertMilliSecond(product5);
    Product p5 = new Product();
    p5.setName("n5");
    Product product5_ = productService.selectOne(p5);
    Assert.assertEquals(product5.getId(), product5_.getId());
    Product product6 = new Product();
    product6.setName("n6");
    productService.insertSnowFlake(product6);
    Product product9 = new Product();
    product9.setName("n9");
    productService.insertSnowFlake(product9);
    Product product10 = new Product();
    product10.setName("n10");
    productService.insertSnowFlake(product10);
    Product p6 = new Product();
    p6.setName("n6");
    Product product6_ = productService.selectOne(p6);
    Assert.assertEquals(product6.getId(), product6_.getId());
    // Product product7 = new Product();
    // product7.setName("n7");
    // productService.insertMilliSecond(product7);
    // Product p7 = new Product();
    // p7.setName("n7");
    // Product product7_ = productService.selectOne(p7);
    // Assert.assertEquals(product7.getId(), product7_.getId());
    // Product product8 = new Product();
    // product8.setName("n8");
    // productService.insertMilliSecond2(product8);
    // 
    // Product p8 = new Product();
    // p8.setName("n8");
    // Product product8_ = productService.selectOne(p8);
    // Assert.assertEquals(product8.getId(), product8_.getId());
    Product product11 = new Product();
    product11.setName("n11");
    productService.insertMySnowFlake(product11);
    Product product12 = new Product();
    product12.setName("n12");
    productService.insertMySnowFlake(product12);
    Product product13 = new Product();
    product13.setName("n13");
    productService.insertMySnowFlake2(product13);
    Assert.assertNull(product13.getId());
    Product product14 = new Product();
    product14.setName("n14");
    productService.insertAsd(product14);
    Assert.assertEquals("asd", product14.getId());
    Product product15 = new Product();
    product15.setName("n15");
    productService.insertDistributedSnowflake(product15);
    Product product16 = new Product();
    product16.setName("n16");
    productService.insertDistributedSnowflake(product16);
    Product product17 = new Product();
    product17.setName("n17");
    productService.insertDistributedSnowflake(product17);
    Product p15 = new Product();
    p15.setName("n15");
    Product product15_ = productService.selectOne(p15);
    Assert.assertEquals(product15.getId(), product15_.getId());
}
Also used : Product(indi.mybatis.flying.pojo.Product) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 18 with ExpectedDatabase

use of com.github.springtestdbunit.annotation.ExpectedDatabase in project mybatis.flying by limeng32.

the class LoginLogTest method testInsert.

/**
 * 测试insert功能(无乐观锁)
 */
@Test
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/loginLogTest/testInsert.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/loginLogTest/testInsert.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/loginLogTest/testInsert.xml")
public void testInsert() {
    LoginLog_ a = new LoginLog_();
    a.setId(1);
    a.setLoginIP("0.0.0.1");
    loginLogService.insert(a);
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 19 with ExpectedDatabase

use of com.github.springtestdbunit.annotation.ExpectedDatabase in project mybatis.flying by limeng32.

the class OrTest method testOr5.

@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr5.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr5.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr5.result.xml")
public void testOr5() {
    LoginLog_Condition lc = new LoginLog_Condition();
    lc.setAccount(new Account_Condition());
    lc.getAccount().setRole(new Role_Condition());
    lc.getAccount().setRoleDeputy(new Role_Condition());
    ((Role_Condition) lc.getAccount().getRole()).setNameEqualsOrAccountNameEquals("user", "bob");
    ((Role_Condition) lc.getAccount().getRoleDeputy()).setNameEqualsOrAccountNameEquals("silver", "bob");
    Collection<LoginLog_> loginLogC = loginLogService.selectAll(lc);
    Assert.assertEquals(2, loginLogC.size());
}
Also used : LoginLog_(indi.mybatis.flying.pojo.LoginLog_) Role_Condition(indi.mybatis.flying.pojo.condition.Role_Condition) LoginLog_Condition(indi.mybatis.flying.pojo.condition.LoginLog_Condition) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 20 with ExpectedDatabase

use of com.github.springtestdbunit.annotation.ExpectedDatabase in project mybatis.flying by limeng32.

the class OrTest method testOr2.

/* 一个dbAssociationUniqueKey型外键的或逻辑测试用例 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr2.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr2.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr2.result.xml")
public void testOr2() {
    LoginLog_Condition lc = new LoginLog_Condition();
    lc.setAccount(new Account_Condition());
    ((Account_Condition) lc.getAccount()).setIdEqualsOr(1L, 2L);
    int i = loginLogService.count(lc);
    Assert.assertEquals(4, i);
}
Also used : LoginLog_Condition(indi.mybatis.flying.pojo.condition.LoginLog_Condition) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Aggregations

ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)76 Test (org.junit.Test)72 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)53 DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)42 MvcResult (org.springframework.test.web.servlet.MvcResult)26 Account_ (indi.mybatis.flying.pojo.Account_)25 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)20 IfProfileValue (org.springframework.test.annotation.IfProfileValue)19 Role_ (indi.mybatis.flying.pojo.Role_)17 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)11 HashMap (java.util.HashMap)9 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)7 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)7 DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)6 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)6 PageParam (indi.mybatis.flying.pagination.PageParam)5 Role_Condition (indi.mybatis.flying.pojo.condition.Role_Condition)5 Order (indi.mybatis.flying.pagination.Order)3 SortParam (indi.mybatis.flying.pagination.SortParam)3 JSONArray (org.json.JSONArray)3