Search in sources :

Example 16 with DatabaseSetup

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

the class OrTest method testOr3.

@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr3.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr3.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr3.result.xml")
public void testOr3() {
    LoginLog_Condition lc4 = new LoginLog_Condition();
    Account_Condition2 ac = new Account_Condition2();
    ac.setNameEqualsOr("ann", "bob");
    lc4.setAccount(ac);
    lc4.setIpLikeFilter("1");
    int i4 = loginLogService.count(lc4);
    Assert.assertEquals(2, i4);
}
Also used : LoginLog_Condition(indi.mybatis.flying.pojo.condition.LoginLog_Condition) Account_Condition2(indi.mybatis.flying.pojo.condition.Account_Condition2) 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 DatabaseSetup

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

the class OrTest method testOr4.

@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/orTest/testOr4.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/orTest/testOr4.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/orTest/testOr4.result.xml")
public void testOr4() {
    LoginLog_Condition lc = new LoginLog_Condition();
    Account_Condition ac = new Account_Condition();
    ac.setNameEqualsOrLoginlogIpEquals("ann", "bob", "c1");
    lc.setAccount(ac);
    int i1 = loginLogService.count(lc);
    Assert.assertEquals(5, i1);
    LoginLog_Condition lc2 = new LoginLog_Condition();
    lc2.setAccount(new Account_Condition());
    lc2.getAccount().setRole(new Role_Condition());
    ((Role_Condition) (lc2.getAccount().getRole())).setNameEqualsOrAccountNameEquals("admin", "cal");
    int i2 = loginLogService.count(lc2);
    Assert.assertEquals(6, i2);
}
Also used : 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 18 with DatabaseSetup

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

the class SelectOneTest method testSelectOne2.

/**
 * 测试selectOne2
 */
@Test
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne2.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne2.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne2.result.xml")
public void testSelectOne2() {
    Account_ a1 = new Account_();
    a1.setName("ann");
    a1.setEmail("ann@live.cn");
    accountService.insert(a1);
    Account_ a2 = new Account_();
    a2.setName("ann");
    a2.setEmail("bob@live.cn");
    accountService.insert(a2);
    Account_Condition ac = new Account_Condition();
    ac.setLimiter(new PageParam(1, 2));
    ac.setSorter(new SortParam(new Order("id", Sequence.asc)));
    ac.setName("ann");
    Account_ account = accountService.selectOne(ac);
    Assert.assertEquals("ann@live.cn", account.getEmail());
    Assert.assertNull(ac.getLimiter());
}
Also used : Order(indi.mybatis.flying.pagination.Order) Account_(indi.mybatis.flying.pojo.Account_) Account_Condition(indi.mybatis.flying.pojo.condition.Account_Condition) PageParam(indi.mybatis.flying.pagination.PageParam) SortParam(indi.mybatis.flying.pagination.SortParam) 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 DatabaseSetup

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

the class SelectOneTest method testSelectOne1.

/**
 * 测试selectOne1
 */
@Test
@DatabaseSetup(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne1.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne1.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/selectOneTest/testSelectOne1.result.xml")
public void testSelectOne1() {
    Account_ a1 = new Account_();
    a1.setName("ann");
    a1.setEmail("ann@live.cn");
    accountService.insert(a1);
    Account_ a2 = new Account_();
    a2.setName("bob");
    a2.setEmail("bob@live.cn");
    accountService.insert(a2);
    accountService.update(a2);
    accountService.updatePersistent(a2);
    Account_ account_ = accountService.select(a2.getId());
    Account_ ac = new Account_();
    ac.setName("bob");
    ac.setEmail("bob@live.cn");
    Account_ account = accountService.selectOne(ac);
    Assert.assertEquals("bob@live.cn", account.getEmail());
}
Also used : Account_(indi.mybatis.flying.pojo.Account_) 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 DatabaseSetup

use of com.github.springtestdbunit.annotation.DatabaseSetup in project ArachneCentralAPI by OHDSI.

the class StudyControllerTests method testUpdateStudyEndDate.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-before-updating.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-after-updating-end-date.xml", assertionMode = NON_STRICT) })
public void testUpdateStudyEndDate() throws Exception {
    StudyDTO updatedStudyDTO = new StudyDTO();
    updatedStudyDTO.setId(STUDY_ID);
    updatedStudyDTO.setDescription("description");
    updatedStudyDTO.setEndDate(UPDATED_DATE);
    StudyStatusDTO status = new StudyStatusDTO(STUDY_STATUS_ID, "Initiate");
    updatedStudyDTO.setStatus(status);
    testUpdate(updatedStudyDTO, UPDATED_STUDY_END_DATE_JSON_OBJECT, UPDATED_DATE);
}
Also used : CreateStudyDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO) StudyDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO) StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Aggregations

DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)79 Test (org.junit.Test)78 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)53 DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)44 MvcResult (org.springframework.test.web.servlet.MvcResult)26 Account_ (indi.mybatis.flying.pojo.Account_)25 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)22 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)21 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)12 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)11 ArrayList (java.util.ArrayList)11 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)8 CreateStudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO)7 StudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO)6 StudyStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO)6 IfProfileValue (org.springframework.test.annotation.IfProfileValue)5 StudyTypeDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO)4 Order (indi.mybatis.flying.pagination.Order)4 SortParam (indi.mybatis.flying.pagination.SortParam)4 Role_ (indi.mybatis.flying.pojo.Role_)4