Search in sources :

Example 11 with DBCleaner

use of pro.taskana.impl.configuration.DBCleaner in project taskana by Taskana.

the class TaskServiceImplIntExplicitTest method setup.

@Before
public void setup() throws FileNotFoundException, SQLException, LoginException {
    dataSource = TaskanaEngineConfigurationTest.getDataSource();
    taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
    taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
    taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
    taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
    classificationService = taskanaEngine.getClassificationService();
    taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.EXPLICIT);
    workbasketService = taskanaEngine.getWorkbasketService();
    DBCleaner cleaner = new DBCleaner();
    cleaner.clearDb(dataSource, false);
}
Also used : TaskanaEngineConfiguration(pro.taskana.configuration.TaskanaEngineConfiguration) DBCleaner(pro.taskana.impl.configuration.DBCleaner) Before(org.junit.Before)

Example 12 with DBCleaner

use of pro.taskana.impl.configuration.DBCleaner in project taskana by Taskana.

the class TaskServiceImplIntExplicitTest method testCreateTaskInTaskanaWithDefaultDb.

@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test
public void testCreateTaskInTaskanaWithDefaultDb() throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
    DataSource ds = TaskanaEngineConfiguration.createDefaultDataSource();
    DBCleaner cleaner = new DBCleaner();
    cleaner.clearDb(ds, false);
    TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(ds, false, false);
    TaskanaEngine te = taskanaEngineConfiguration.buildTaskanaEngine();
    Connection connection = ds.getConnection();
    te.setConnection(connection);
    TaskServiceImpl taskServiceImpl = (TaskServiceImpl) te.getTaskService();
    WorkbasketServiceImpl workBasketServiceImpl = (WorkbasketServiceImpl) te.getWorkbasketService();
    ClassificationServiceImpl classificationServiceImpl = (ClassificationServiceImpl) te.getClassificationService();
    Workbasket workbasket = workbasketService.newWorkbasket("K99", "DOMAIN_A");
    workbasket.setName("workbasket");
    workbasket.setName("workbasket99");
    workbasket.setType(WorkbasketType.GROUP);
    workbasket = workBasketServiceImpl.createWorkbasket(workbasket);
    Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
    classification = classificationServiceImpl.createClassification(classification);
    Task task = taskServiceImpl.newTask(workbasket.getId());
    task.setName("Unit Test Task");
    task.setClassificationKey(classification.getKey());
    task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
    task.addAttachment(null);
    task = taskServiceImpl.createTask(task);
    Assert.assertNotNull(task);
    Assert.assertNotNull(task.getId());
    connection.commit();
    te.setConnection(null);
}
Also used : TaskanaEngineConfiguration(pro.taskana.configuration.TaskanaEngineConfiguration) Task(pro.taskana.Task) ClassificationServiceImpl(pro.taskana.impl.ClassificationServiceImpl) TaskanaEngine(pro.taskana.TaskanaEngine) Classification(pro.taskana.Classification) Connection(java.sql.Connection) TaskServiceImpl(pro.taskana.impl.TaskServiceImpl) WorkbasketServiceImpl(pro.taskana.impl.WorkbasketServiceImpl) DBCleaner(pro.taskana.impl.configuration.DBCleaner) Workbasket(pro.taskana.Workbasket) DataSource(javax.sql.DataSource) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 13 with DBCleaner

use of pro.taskana.impl.configuration.DBCleaner in project taskana by Taskana.

the class WorkbasketServiceImplIntExplicitTest method resetDb.

@BeforeClass
public static void resetDb() throws SQLException {
    DataSource ds = TaskanaEngineConfigurationTest.getDataSource();
    DBCleaner cleaner = new DBCleaner();
    cleaner.clearDb(ds, true);
}
Also used : DBCleaner(pro.taskana.impl.configuration.DBCleaner) DataSource(javax.sql.DataSource) BeforeClass(org.junit.BeforeClass)

Example 14 with DBCleaner

use of pro.taskana.impl.configuration.DBCleaner in project taskana by Taskana.

the class ClassificationServiceImplIntAutoCommitTest method resetDb.

@BeforeClass
public static void resetDb() throws SQLException {
    DataSource ds = TaskanaEngineConfigurationTest.getDataSource();
    DBCleaner cleaner = new DBCleaner();
    cleaner.clearDb(ds, true);
}
Also used : DBCleaner(pro.taskana.impl.configuration.DBCleaner) DataSource(javax.sql.DataSource) BeforeClass(org.junit.BeforeClass)

Example 15 with DBCleaner

use of pro.taskana.impl.configuration.DBCleaner in project taskana by Taskana.

the class TaskServiceImplIntAutocommitTest method testCreateTaskInTaskanaWithDefaultDb.

@Test
public void testCreateTaskInTaskanaWithDefaultDb() throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
    DBCleaner cleaner = new DBCleaner();
    cleaner.clearDb(TaskanaEngineConfiguration.createDefaultDataSource(), false);
    TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(null, false, false);
    TaskanaEngine te = taskanaEngineConfiguration.buildTaskanaEngine();
    ((TaskanaEngineImpl) te).setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
    TaskServiceImpl taskServiceImpl = (TaskServiceImpl) te.getTaskService();
    Workbasket wb = workbasketService.newWorkbasket("workbasket", "DOMAIN_A");
    wb.setName("workbasket");
    wb.setType(WorkbasketType.GROUP);
    te.getWorkbasketService().createWorkbasket(wb);
    Classification classification = te.getClassificationService().newClassification("TEST", "DOMAIN_A", "TASK");
    te.getClassificationService().createClassification(classification);
    Task task = taskServiceImpl.newTask(wb.getId());
    task.setName("Unit Test Task");
    task.setClassificationKey(classification.getKey());
    task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
    task = taskServiceImpl.createTask(task);
    Assert.assertNotNull(task);
    Assert.assertNotNull(task.getId());
}
Also used : TaskanaEngineConfiguration(pro.taskana.configuration.TaskanaEngineConfiguration) Task(pro.taskana.Task) TaskanaEngine(pro.taskana.TaskanaEngine) Classification(pro.taskana.Classification) TaskanaEngineImpl(pro.taskana.impl.TaskanaEngineImpl) TaskServiceImpl(pro.taskana.impl.TaskServiceImpl) DBCleaner(pro.taskana.impl.configuration.DBCleaner) Workbasket(pro.taskana.Workbasket) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Aggregations

DBCleaner (pro.taskana.impl.configuration.DBCleaner)22 TaskanaEngineConfiguration (pro.taskana.configuration.TaskanaEngineConfiguration)16 DataSource (javax.sql.DataSource)15 TestDataGenerator (pro.taskana.database.TestDataGenerator)8 Before (org.junit.Before)6 BeforeClass (org.junit.BeforeClass)6 TaskanaEngineImpl (pro.taskana.impl.TaskanaEngineImpl)6 Test (org.junit.Test)2 Classification (pro.taskana.Classification)2 Task (pro.taskana.Task)2 TaskanaEngine (pro.taskana.TaskanaEngine)2 Workbasket (pro.taskana.Workbasket)2 TaskServiceImpl (pro.taskana.impl.TaskServiceImpl)2 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)2 Connection (java.sql.Connection)1 ClassificationServiceImpl (pro.taskana.impl.ClassificationServiceImpl)1 WorkbasketServiceImpl (pro.taskana.impl.WorkbasketServiceImpl)1 WithAccessId (pro.taskana.security.WithAccessId)1