use of com.github.springtestdbunit.annotation.ExpectedDatabases in project ArachneCentralAPI by OHDSI.
the class AnalysisSubmissionControllerTests method testManualUploadingSubmissionResult.
@Test
@WithUserDetails(DATA_NODE_ONWER)
@DatabaseSetups({ @DatabaseSetup("/data/analysis/submission/submission-in-progress.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/analysis/submission/result/submission-in-progress-with-added-file.xml", assertionMode = NON_STRICT) })
public void testManualUploadingSubmissionResult() throws Exception {
FileInputStream fileInputStream = new FileInputStream(this.getClass().getResource("/test.jpg").getPath());
MockMultipartFile multipartFile = new MockMultipartFile("file", "test.sql", "image/jpeg", fileInputStream);
mvc.perform(fileUpload("/api/v1/analysis-management/submissions/result/manualupload").file(multipartFile).contentType(MULTIPART_FORM_DATA).param("submissionId", "1").param("label", "test.sql")).andExpect(NO_ERROR_CODE);
}
use of com.github.springtestdbunit.annotation.ExpectedDatabases in project ArachneCentralAPI by OHDSI.
the class StudyControllerTests method testAddExistedParticipant.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant.xml", assertionMode = NON_STRICT) })
public void testAddExistedParticipant() throws Exception {
AddStudyParticipantDTO participantDTO = new AddStudyParticipantDTO();
participantDTO.setUserId(USER_2_UUID);
participantDTO.setRole(CONTRIBUTOR);
mvc.perform(post("/api/v1/study-management/studies/" + STUDY_ID + "/participants").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(participantDTO))).andExpect(jsonPath("$.errorCode").value(ALREADY_EXIST.getCode()));
}
use of com.github.springtestdbunit.annotation.ExpectedDatabases in project ArachneCentralAPI by OHDSI.
the class StudyControllerTests method testUpdateStudyTitle.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-before-updating.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-after-updating-title.xml", assertionMode = NON_STRICT) })
public void testUpdateStudyTitle() throws Exception {
StudyDTO updatedStudyDTO = new StudyDTO();
updatedStudyDTO.setId(STUDY_ID);
updatedStudyDTO.setTitle("Study Title New");
updatedStudyDTO.setDescription("description");
StudyTypeDTO type = new StudyTypeDTO(STUDY_TYPE_ID);
type.setName("type");
updatedStudyDTO.setType(type);
StudyStatusDTO status = new StudyStatusDTO(STUDY_STATUS_ID, "Initiate");
updatedStudyDTO.setStatus(status);
testUpdate(updatedStudyDTO, UPDATED_STUDY_TITLE_JSON_OBJECT, UPDATED_STUDY_TITLE);
}
use of com.github.springtestdbunit.annotation.ExpectedDatabases in project mybatis.flying by limeng32.
the class AccountTypeHandlerTest method testAccountTypeHandler.
/* 测试AccountTypeHandler的功能 */
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTypeHandlerTest/testAccountTypeHandler.datasource2.result.xml") })
public void testAccountTypeHandler() {
LoginLogSource2 longinLogSource0 = loginLogSource2Service.selectWithoutAccount(22);
Assert.assertNull(longinLogSource0.getAccount());
LoginLogSource2 longinLogSource = loginLogSource2Service.select(22);
Assert.assertNotNull(longinLogSource);
Assert.assertNotNull(longinLogSource.getAccount());
Assert.assertEquals("ann@live.cn", longinLogSource.getAccount().getEmail());
Account_ ac = new Account_();
ac.setId(1L);
LoginLogSource2 l2c = new LoginLogSource2();
l2c.setAccount(ac);
Collection<LoginLogSource2> loginLogSource2C = loginLogSource2Service.selectAll(l2c);
Assert.assertEquals(2, loginLogSource2C.size());
for (LoginLogSource2 e : loginLogSource2C) {
Assert.assertEquals("ann@live.cn", e.getAccount().getEmail());
}
LoginLogSource2 loginLogSource2 = loginLogSource2Service.select(24);
Assert.assertNull(loginLogSource2.getAccount());
LoginLogSource2 loginLogSource3 = loginLogSource2Service.select(25);
Assert.assertNull(loginLogSource3.getAccount());
Account_ ac2 = new Account_();
ac2.setId(2L);
LoginLogSource2 l2c2 = new LoginLogSource2();
l2c2.setAccount(ac2);
LoginLogSource2 loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
loginLogSource4 = loginLogSource2Service.selectOne(l2c2);
Assert.assertEquals("bob@live.cn", loginLogSource4.getAccount().getEmail());
Account_ ac3 = new Account_();
ac3.setId(1L);
LoginLogSource2 l2c3 = new LoginLogSource2();
l2c3.setAccount(ac3);
l2c3.setLoginIP("ip1");
int i = loginLogSource2Service.count(l2c3);
Assert.assertEquals(1, i);
Account_ account2 = accountService.select(2);
loginLogSource2.setAccount(account2);
loginLogSource2Service.update(loginLogSource2);
loginLogSource4.setAccount(null);
loginLogSource2Service.updatePersistent(loginLogSource4);
Account_ account = accountService.select(1);
loginLogSource2Service.loadAccount(account, new LoginLogSource2());
Assert.assertEquals(2, account.getLoginLogSource2().size());
}
use of com.github.springtestdbunit.annotation.ExpectedDatabases 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());
}
Aggregations