Search in sources :

Example 61 with ExpectedDatabase

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

the class ThreadTest method testExampleThread.

/**
 * 这是一个展示Junit配合Groboutils进行多线程测试的例子,在这个例子中accountInsert以子线程的方式执行多次,
 * 主线程会等待子线程全部执行完后再结束
 */
@Test
@DatabaseSetup(type = DatabaseOperation.CLEAN_INSERT, value = "/indi/mybatis/flying/test/threadTest/testExampleThread.xml")
@ExpectedDatabase(assertionMode = DatabaseAssertionMode.NON_STRICT, value = "/indi/mybatis/flying/test/threadTest/testExampleThread.result.xml")
@DatabaseTearDown(type = DatabaseOperation.DELETE_ALL, value = "/indi/mybatis/flying/test/threadTest/testExampleThread.result.xml")
public void testExampleThread() throws Throwable {
    // 实例化 TestRunnable 类
    TestRunnable tr1, tr2;
    tr1 = new accountInsert(2L, "ann");
    tr2 = new accountInsert(3L, "ann");
    // 把实例传递给 MTTR
    TestRunnable[] trs = { tr1, tr2 };
    MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(trs);
    // 执行MTTR和线程
    mttr.runTestRunnables();
}
Also used : TestRunnable(net.sourceforge.groboutils.junit.v1.TestRunnable) MultiThreadedTestRunner(net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup) DatabaseTearDown(com.github.springtestdbunit.annotation.DatabaseTearDown)

Example 62 with ExpectedDatabase

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

the class AnalysisSubmissionControllerTests method testDeclineSubmissionResultByOwner.

@Test
@WithUserDetails(DATA_NODE_ONWER)
@DatabaseSetups({ @DatabaseSetup("/data/analysis/submission/submission-executed.xml") })
@ExpectedDatabase(value = "/data/analysis/submission/result/submission-datasource2-result-declined.xml", assertionMode = NON_STRICT)
public void testDeclineSubmissionResultByOwner() throws Exception {
    ApproveDTO approveDTO = new ApproveDTO(SUBMISSION_ID, false, null, "comment");
    prepareAnalysisFile(STUDY_ID, ANALYSIS_ID);
    prepareSubmissionGroupFile(STUDY_ID, ANALYSIS_ID, SUBMISSION_GROUP_ID);
    mvc.perform(post("/api/v1/analysis-management/submissions/{submissionId}/approveresult", 1).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(approveDTO))).andExpect(NO_ERROR_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)

Example 63 with ExpectedDatabase

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

the class AnalysisSubmissionControllerTests method testDeclineSubmissionResultByNonOwner.

@Test
@WithUserDetails(DATA_NODE_USER)
@DatabaseSetups({ @DatabaseSetup("/data/analysis/submission/submission-executed.xml") })
@ExpectedDatabase(value = "/data/analysis/submission/submission-executed.xml", assertionMode = NON_STRICT)
public void testDeclineSubmissionResultByNonOwner() throws Exception {
    ApproveDTO approveDTO = new ApproveDTO(SUBMISSION_ID, false, null, "comment");
    prepareAnalysisFile(STUDY_ID, ANALYSIS_ID);
    prepareSubmissionGroupFile(STUDY_ID, ANALYSIS_ID, SUBMISSION_GROUP_ID);
    mvc.perform(post("/api/v1/analysis-management/submissions/{submissionId}/approveresult", 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)

Example 64 with ExpectedDatabase

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

the class AnalysisSubmissionControllerTests method testDeclineSubmissionByNonOwner.

@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 testDeclineSubmissionByNonOwner() throws Exception {
    ApproveDTO approveDTO = new ApproveDTO(SUBMISSION_ID, false, null, "comment");
    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)

Example 65 with ExpectedDatabase

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

the class AnalysisSubmissionControllerTests method testApproveSubmissionResultByOwner.

@Test
@WithUserDetails(DATA_NODE_ONWER)
@DatabaseSetups({ @DatabaseSetup("/data/analysis/submission/submission-executed.xml") })
@ExpectedDatabase(value = "/data/analysis/submission/result/submission-datasource2-result-approved.xml", assertionMode = NON_STRICT)
public void testApproveSubmissionResultByOwner() 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}/approveresult", 1).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(approveDTO))).andExpect(NO_ERROR_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

ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)76 Test (org.junit.Test)72 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)53 DatabaseTearDown (com.github.springtestdbunit.annotation.DatabaseTearDown)42 MvcResult (org.springframework.test.web.servlet.MvcResult)26 Account_ (indi.mybatis.flying.pojo.Account_)25 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)20 IfProfileValue (org.springframework.test.annotation.IfProfileValue)19 Role_ (indi.mybatis.flying.pojo.Role_)17 Account_Condition (indi.mybatis.flying.pojo.condition.Account_Condition)11 HashMap (java.util.HashMap)9 LoginLog_ (indi.mybatis.flying.pojo.LoginLog_)7 LoginLog_Condition (indi.mybatis.flying.pojo.condition.LoginLog_Condition)7 DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)6 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)6 PageParam (indi.mybatis.flying.pagination.PageParam)5 Role_Condition (indi.mybatis.flying.pojo.condition.Role_Condition)5 Order (indi.mybatis.flying.pagination.Order)3 SortParam (indi.mybatis.flying.pagination.SortParam)3 JSONArray (org.json.JSONArray)3