use of com.github.springtestdbunit.annotation.DatabaseSetups in project mybatis.flying by limeng32.
the class BatchProcessTest method testBatchInsert.
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchInsert.datasource.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchInsert.datasource.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/batchProcessTest/testBatchInsert.datasource.result.xml") })
public void testBatchInsert() {
Collection<Account_> ac = new ArrayList<>();
Role_ r1 = new Role_(), r2 = new Role_(), r3 = new Role_();
r1.setId(1);
r2.setId(2);
r3.setId(3);
Account_ a = new Account_();
a.setId(1L);
// a.setName("ann");
a.setEmail("ann@live.cn");
a.setPassword("5a690d842935c51f26f473e025c1b97a");
a.setActivated(true);
a.setActivateValue("");
// a.setRole(r1);
ac.add(a);
Account_ a2 = new Account_();
a2.setId(2L);
a2.setName("bob");
a2.setEmail("bob@live.cn");
a2.setPassword("6a690d842935c51f26f473e025c1b97a");
a2.setActivated(true);
a2.setActivateValue("");
a2.setDelegateRoleId(23L);
ac.add(a2);
Account_ a3 = new Account_();
a3.setId(3L);
a3.setName("carl");
a3.setEmail("carl@live.cn");
a3.setPassword("7a690d842935c51f26f473e025c1b97a");
a3.setActivated(true);
a3.setActivateValue("");
a3.setRole(r3);
ac.add(a3);
accountService.insertBatch(ac);
System.out.println(JSONObject.toJSONString(ac));
Collection<Account_> ac2 = new ArrayList<>();
try {
accountService.insertBatch(ac2);
// below code should never reach
Assert.assertTrue(false);
} catch (Exception e) {
}
System.out.println(JSONObject.toJSONString(ac2));
}
use of com.github.springtestdbunit.annotation.DatabaseSetups in project ArachneCentralAPI by OHDSI.
the class AnalysisControllerTests method testUpdateCodeFile.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/analysis-list.xml"), @DatabaseSetup("/data/analysis/code-file-before-deleting.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/code-file-after-updating.xml", assertionMode = NON_STRICT) })
public void testUpdateCodeFile() throws Exception {
String uuid = "68b75ac9-ab29-49a6-8edb-95142456f5fc";
String path = this.getClass().getResource("/test.jpg").getPath();
FileInputStream fileInputStream = new FileInputStream(path);
MockMultipartFile multipartFile = new MockMultipartFile("file", "test_updated.jpg", "image/jpeg", fileInputStream);
MockMultipartHttpServletRequestBuilder builder = fileUpload("/api/v1/analysis-management/analyses/{analysisId}/files/{fileUuid}", ANALYSIS_ID, uuid);
builder.with(request -> {
request.setMethod("PUT");
return request;
});
mvc.perform(builder.file(multipartFile).param("label", "labelUploadedFile").param("file", path).contentType(MULTIPART_FORM_DATA)).andExpect(NO_ERROR_CODE).andExpect(TRUE_RESULT);
}
use of com.github.springtestdbunit.annotation.DatabaseSetups in project ArachneCentralAPI by OHDSI.
the class AnalysisControllerTests method testCreateAnalysis.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/empty-analysis.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis.xml", assertionMode = NON_STRICT) })
public void testCreateAnalysis() throws Exception {
AnalysisCreateDTO analysisDTO = new AnalysisCreateDTO();
analysisDTO.setTitle(ANALYSIS_TITLE);
analysisDTO.setTypeId(ANALYSIS_TYPE_ID);
analysisDTO.setStudyId(STUDY_ID);
MvcResult mvcResult = mvc.perform(post("/api/v1/analysis-management/analyses").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(analysisDTO))).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andExpect(jsonPath("$.result.id").isNotEmpty()).andReturn();
JSONObject result = getResultJSONObject(mvcResult);
JSONAssert.assertEquals(ANALYSIS_JSON_OBJECT, result, false);
}
use of com.github.springtestdbunit.annotation.DatabaseSetups in project ArachneCentralAPI by OHDSI.
the class AnalysisControllerTests method testUpdateAnalysisTitle.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/analysis-before-updating.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-after-title-updating.xml", assertionMode = NON_STRICT) })
public void testUpdateAnalysisTitle() throws Exception {
AnalysisUpdateDTO analysisDTO = new AnalysisUpdateDTO();
analysisDTO.setTitle(UPDATED_ANALYSIS_TITLE);
analysisDTO.setTypeId(ANALYSIS_TYPE_ID);
testUpdate(analysisDTO, UPDATED_ANALYSIS_JSON_OBJECT, UPDATED_ANALYSIS_TITLE);
}
use of com.github.springtestdbunit.annotation.DatabaseSetups in project ArachneCentralAPI by OHDSI.
the class AnalysisControllerTests method testUpdateAnalysisDescription.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study-with-contributor.xml"), @DatabaseSetup("/data/analysis/analysis-before-updating.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study-with-contributor.xml", assertionMode = NON_STRICT), @ExpectedDatabase(value = "/data/analysis/analysis-after-description-updating.xml", assertionMode = NON_STRICT) })
public void testUpdateAnalysisDescription() throws Exception {
AnalysisUpdateDTO analysisDTO = new AnalysisUpdateDTO();
analysisDTO.setDescription(UPDATED_ANALYSIS_DESCRIPTION_VALUE);
analysisDTO.setTypeId(ANALYSIS_TYPE_ID);
testUpdate(analysisDTO, UPDATED_ANALYSIS_DESCR_JSON_OBJECT, null);
}
Aggregations