use of com.github.springtestdbunit.annotation.DatabaseSetups in project ArachneCentralAPI by OHDSI.
the class StudyControllerTests method testUpdateContributorRoleForLastLeadInvestigator.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant-before-changing-role.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant-before-changing-role.xml", assertionMode = NON_STRICT) })
public void testUpdateContributorRoleForLastLeadInvestigator() throws Exception {
UpdateParticipantDTO participantDTO = new UpdateParticipantDTO();
participantDTO.setRole(CONTRIBUTOR.name());
mvc.perform(put("/api/v1/study-management/studies/" + STUDY_ID + "/participants/" + UserIdUtils.idToUuid(ADMIN_ID)).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(participantDTO))).andExpect(jsonPath("$.errorCode").value(VALIDATION_ERROR.getCode()));
}
use of com.github.springtestdbunit.annotation.DatabaseSetups in project ArachneCentralAPI by OHDSI.
the class StudyControllerTests method testUpdateContributorRoleToContributor.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant-with-2-leaders-before-updating.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant-with-contributor-and-leader.xml", assertionMode = NON_STRICT) })
public void testUpdateContributorRoleToContributor() throws Exception {
UpdateParticipantDTO participantDTO = new UpdateParticipantDTO();
participantDTO.setRole(CONTRIBUTOR.name());
mvc.perform(put("/api/v1/study-management/studies/" + STUDY_ID + "/participants/" + UserIdUtils.idToUuid(ADMIN_ID)).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(participantDTO))).andExpect(NO_ERROR_CODE).andReturn();
}
use of com.github.springtestdbunit.annotation.DatabaseSetups in project mybatis.flying by limeng32.
the class CacheTest method test22.
@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest2/test2.datasource1.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest2/test2.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest2/test2.datasource1.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/cacheTest2/test2.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest2/test2.datasource1.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest2/test2.datasource2.result.xml") })
public void test22() {
String name = "ann";
String roleName = "user";
String newRoleName = "admin";
Account_ a = new Account_();
Role_ r = new Role_();
r.setName(roleName);
roleService.insert(r);
a.setName(name);
a.setRole(r);
accountService.insert(a);
Account_ account_ = accountService.select(a.getId());
Assert.assertEquals(roleName, account_.getRole().getName());
Role_ r12 = roleService.select(r.getId());
r12.setName(newRoleName);
roleService.update(r12);
account_ = accountService.select(a.getId());
Assert.assertEquals(newRoleName, account_.getRole().getName());
Account2_ a2 = new Account2_();
Role2_ r2 = new Role2_();
r2.setName(roleName);
role2Service.insert(r2);
a2.setName(name);
a2.setRole(r2);
account2Service.insert(a2);
Account2_ account2_ = account2Service.select(a2.getId());
Assert.assertEquals(roleName, account2_.getRole().getName());
Role2_ r22 = role2Service.select(r2.getId());
r22.setName(newRoleName);
role2Service.update(r22);
account2_ = account2Service.select(a2.getId());
Assert.assertEquals(newRoleName, account2_.getRole().getName());
}
use of com.github.springtestdbunit.annotation.DatabaseSetups in project mybatis.flying by limeng32.
the class CacheTest method testAccountTypeHandlerUsingCache.
/* 一个证明缓存对跨库关联也有效的测试用例 */
@Test
@IfProfileValue(name = "CACHE", value = "true")
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/cacheTest/testAccountTypeHandlerUsingCache.datasource2.result.xml") })
public void testAccountTypeHandlerUsingCache() {
Role_ r = new Role_();
r.setId(101);
r.setName("user");
roleService.insert(r);
Account_ a = new Account_();
a.setId(1L);
a.setEmail("ann@live.cn");
a.setRole(r);
accountService.insert(a);
Account_ a2 = new Account_();
a2.setId(2L);
a2.setEmail("bob@live.cn");
accountService.insert(a2);
LoginLog_ l = new LoginLog_();
l.setId(2);
l.setLoginIP("2");
loginLogService.insert(l);
LoginLogSource2 l2 = new LoginLogSource2();
l2.setId(21);
l2.setLoginIP("ip0");
l2.setAccount(a);
loginLogSource2Service.insert(l2);
LoginLogSource2 loginLogSource2 = loginLogSource2Service.select(21);
Assert.assertEquals("user", loginLogSource2.getAccount().getRole().getName());
Account_ account = accountService.select(1L);
LoginLogSource2 loginLogSource4 = loginLogSource2Service.select(21);
loginLogSource4.setLoginIP("ip00");
loginLogSource2Service.updateNoFlush(loginLogSource4);
account = accountService.select(1L);
accountService.update(account);
LoginLogSource2 loginLogSource5 = loginLogSource2Service.select(21);
Assert.assertEquals("ip00", loginLogSource5.getLoginIP());
Assert.assertEquals(1, loginLogSource5.getAccount().getOpLock().intValue());
}
use of com.github.springtestdbunit.annotation.DatabaseSetups in project mybatis.flying by limeng32.
the class NoApplicationContextProviderTest method testNormal.
@Test
@IfProfileValue(name = "NO_PROVIDER", value = "true")
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/noApplicationContextProviderTest/testNormal.datasource2.result.xml") })
public void testNormal() {
Account_ a = accountService.selectWithoutCache(1);
assertEquals("r", a.getRole().getName());
Role_ r = roleService.selectWithoutCache(51);
assertEquals("r", r.getName());
try {
Account22 account22 = account22Service.select(11);
fail("Expected an Exception to be thrown");
} catch (Exception e) {
assertEquals("Can not find the ApplicationContextProvider bean in the context", e.getCause().getCause().getMessage());
}
}
Aggregations