Search in sources :

Example 11 with DatabaseSetups

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

the class GroupTest method test1.

@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/groupTest/test1.datasource.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/groupTest/test1.datasource.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/groupTest/test1.datasource.xml") })
public void test1() {
    ProjRatio projRatio = projRatioMapper.select(1);
    System.out.println("::" + JSONObject.toJSONString(projRatio));
    EmpScore2 empScore = empScore2Mapper.select(1L);
    System.out.println("::" + JSONObject.toJSONString(empScore));
    Assert.assertEquals(1, empScore.getProjRatio().getId().intValue());
    EmpScore2 e = new EmpScore2();
    e.setId(3L);
    List<EmpScore2> empScore2List = empScore2Mapper.selectAll(e);
    Assert.assertEquals(1, empScore2List.size());
    Assert.assertEquals(3, empScore2List.get(0).getProjRatio().getId().intValue());
    ProjRatio p = new ProjRatio();
    p.setId(2L);
    e.setProjRatio(p);
    List<EmpScore2> empScore2List2 = empScore2Mapper.selectAll(e);
    Assert.assertEquals(1, empScore2List2.size());
    Assert.assertEquals(2, empScore2List2.get(0).getProjRatio().getId().intValue());
    EmpScore2 e2 = new EmpScore2();
    e2.setId(3L);
    int c = empScore2Mapper.count(e2);
    Assert.assertEquals(4, c);
    EmpScore2 e3 = new EmpScore2();
    e3.setStaffId("111");
    int c2 = empScore2Mapper.count(e3);
    Assert.assertEquals(2, c2);
}
Also used : ProjRatio(indi.mybatis.flying.pojo.ProjRatio) EmpScore2(indi.mybatis.flying.pojo.EmpScore2) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns)

Example 12 with DatabaseSetups

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

the class JpaTest method testDetail2.

@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/jpaTest/testDetail2.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/jpaTest/testDetail2.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/jpaTest/testDetail2.datasource2.result.xml") })
public void testDetail2() {
    Detail2_ detail2 = detail2Service.select(1);
    Assert.assertEquals("n", detail2.getName());
    Assert.assertEquals(123, detail2.getNumber().intValue());
    Assert.assertEquals("l", detail2.getLoginLogSource2().getLoginIP());
    loginLogSource2Service.update(detail2.getLoginLogSource2());
    Detail2_ detail2_2 = new Detail2_();
    detail2_2.setName("name");
    detail2_2.setDetail("detail");
    detail2_2.setNumber(321);
    detail2Service.insert(detail2_2);
    Detail2_ detail2_c = new Detail2_();
    detail2_c.setName("name");
    detail2_c.setDetail("detail");
    Detail2_ detail2_3 = detail2Service.selectOne(detail2_c);
    Assert.assertEquals(detail2_2.getId(), detail2_3.getId());
}
Also used : Detail2_(indi.mybatis.flying.pojo.Detail2_) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns)

Example 13 with DatabaseSetups

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

the class Account2Test method testCondition.

/**
 * 测试insert功能(有乐观锁)
 */
@Test
@DatabaseSetups({ @DatabaseSetup(connection = "dataSource1", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest2/testCondition.datasource.xml"), @DatabaseSetup(connection = "dataSource2", type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/accountTest2/testCondition.datasource2.xml") })
@ExpectedDatabases({ @ExpectedDatabase(connection = "dataSource1", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest2/testCondition.datasource.result.xml"), @ExpectedDatabase(connection = "dataSource2", override = false, assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/accountTest2/testCondition.datasource2.result.xml") })
@DatabaseTearDowns({ @DatabaseTearDown(connection = "dataSource1", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest2/testCondition.datasource.result.xml"), @DatabaseTearDown(connection = "dataSource2", type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/accountTest2/testCondition.datasource2.result.xml") })
public void testCondition() {
    LoginLog_Condition lc1 = new LoginLog_Condition();
    lc1.setIpLikeFilter("5");
    int i1 = loginLogService.count(lc1);
    Assert.assertEquals(1, i1);
    LoginLogSource2Condition lc2 = new LoginLogSource2Condition();
    lc2.setIpLikeFilter("2");
    int i2 = loginLogSource2Service.count(lc2);
    Assert.assertEquals(1, i2);
}
Also used : LoginLog_Condition(indi.mybatis.flying.pojo.condition.LoginLog_Condition) LoginLogSource2Condition(indi.mybatis.flying.pojo.condition.LoginLogSource2Condition) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseTearDowns(com.github.springtestdbunit.annotation.DatabaseTearDowns)

Example 14 with DatabaseSetups

use of com.github.springtestdbunit.annotation.DatabaseSetups 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);
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) FileInputStream(java.io.FileInputStream) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Example 15 with DatabaseSetups

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

the class AnalysisSubmissionControllerTests method testApproveSubmissionByNonOwner.

@Test
@WithUserDetails(DATA_NODE_USER)
@DatabaseSetups({ @DatabaseSetup("/data/analysis/submission/submission-pending.xml") })
@ExpectedDatabase(value = "/data/analysis/submission/submission-pending.xml", assertionMode = NON_STRICT)
public void testApproveSubmissionByNonOwner() throws Exception {
    ApproveDTO approveDTO = new ApproveDTO(SUBMISSION_ID, true, null, null);
    prepareAnalysisFile(STUDY_ID, ANALYSIS_ID);
    prepareSubmissionGroupFile(STUDY_ID, ANALYSIS_ID, SUBMISSION_GROUP_ID);
    mvc.perform(post("/api/v1/analysis-management/submissions/{submissionId}/approve", 1).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(approveDTO))).andExpect(PERMISSION_DENIED_CODE);
}
Also used : ApproveDTO(com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails)

Aggregations

DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)50 Test (org.junit.Test)49 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)44 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)26 DatabaseTearDowns (com.github.springtestdbunit.annotation.DatabaseTearDowns)24 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)17 Account_ (indi.mybatis.flying.pojo.Account_)15 Role_ (indi.mybatis.flying.pojo.Role_)10 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)8 LoginLogSource2 (indi.mybatis.flying.pojo.LoginLogSource2)7 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)6 Detail2_ (indi.mybatis.flying.pojo.Detail2_)5 IfProfileValue (org.springframework.test.annotation.IfProfileValue)5 UpdateParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO)4 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4 AnalysisUpdateDTO (com.odysseusinc.arachne.portal.api.v1.dto.AnalysisUpdateDTO)3 Account2_ (indi.mybatis.flying.pojo.Account2_)3 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)3 Role2_ (indi.mybatis.flying.pojo.Role2_)3