Search in sources :

Example 1 with TaskanaEngineConfiguration

use of pro.taskana.configuration.TaskanaEngineConfiguration in project taskana by Taskana.

the class ProvideCategoryReportAccTest method resetDb.

public static void resetDb() throws SQLException, IOException {
    DataSource dataSource = TaskanaEngineConfigurationTest.getDataSource();
    DBCleaner cleaner = new DBCleaner();
    cleaner.clearDb(dataSource, true);
    dataSource = TaskanaEngineConfigurationTest.getDataSource();
    taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
    taskanaEngineConfiguration.setGermanPublicHolidaysEnabled(false);
    taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
    ((TaskanaEngineImpl) taskanaEngine).setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
    cleaner.clearDb(dataSource, false);
    TestDataGenerator testDataGenerator = new TestDataGenerator();
    testDataGenerator.generateMonitoringTestData(dataSource);
}
Also used : TaskanaEngineConfiguration(pro.taskana.configuration.TaskanaEngineConfiguration) TaskanaEngineImpl(pro.taskana.impl.TaskanaEngineImpl) DBCleaner(pro.taskana.impl.configuration.DBCleaner) DataSource(javax.sql.DataSource) TestDataGenerator(pro.taskana.database.TestDataGenerator)

Example 2 with TaskanaEngineConfiguration

use of pro.taskana.configuration.TaskanaEngineConfiguration in project taskana by Taskana.

the class ProvideCustomFieldValueReportAccTest method resetDb.

public static void resetDb() throws SQLException, IOException {
    DataSource dataSource = TaskanaEngineConfigurationTest.getDataSource();
    DBCleaner cleaner = new DBCleaner();
    cleaner.clearDb(dataSource, true);
    dataSource = TaskanaEngineConfigurationTest.getDataSource();
    taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
    taskanaEngineConfiguration.setGermanPublicHolidaysEnabled(false);
    taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
    taskanaEngine.setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
    cleaner.clearDb(dataSource, false);
    TestDataGenerator testDataGenerator = new TestDataGenerator();
    testDataGenerator.generateMonitoringTestData(dataSource);
}
Also used : TaskanaEngineConfiguration(pro.taskana.configuration.TaskanaEngineConfiguration) DBCleaner(pro.taskana.impl.configuration.DBCleaner) DataSource(javax.sql.DataSource) TestDataGenerator(pro.taskana.database.TestDataGenerator)

Example 3 with TaskanaEngineConfiguration

use of pro.taskana.configuration.TaskanaEngineConfiguration in project taskana by Taskana.

the class ClassificationServiceImplIntAutoCommitTest method setup.

@Before
public void setup() throws FileNotFoundException, SQLException, LoginException {
    dataSource = TaskanaEngineConfigurationTest.getDataSource();
    taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, false);
    taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
    classificationService = taskanaEngine.getClassificationService();
    taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
    taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
    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 4 with TaskanaEngineConfiguration

use of pro.taskana.configuration.TaskanaEngineConfiguration in project taskana by Taskana.

the class TaskServiceImplIntAutocommitTest method setup.

@Before
public void setup() throws FileNotFoundException, SQLException, LoginException {
    dataSource = TaskanaEngineConfigurationTest.getDataSource();
    taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, false);
    taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
    taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
    taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
    taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
    classificationService = taskanaEngine.getClassificationService();
    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 5 with TaskanaEngineConfiguration

use of pro.taskana.configuration.TaskanaEngineConfiguration in project taskana by Taskana.

the class TaskServiceImplIntAutocommitTest method shouldNotTransferByFailingSecurity.

@WithAccessId(userName = "User", groupNames = { "businessadmin" })
@Test
public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException, TaskNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
    final String user = CurrentUserContext.getUserid();
    // Set up Security for this Test
    dataSource = TaskanaEngineConfigurationTest.getDataSource();
    taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, true);
    taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
    taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
    taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
    taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
    classificationService = taskanaEngine.getClassificationService();
    workbasketService = taskanaEngine.getWorkbasketService();
    ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification("KEY", "DOMAIN_A", "TASK");
    classification.setCategory("EXTERNAL");
    classification.setName("Transfert-Task Classification");
    classificationService.createClassification(classification);
    WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("k5", "DOMAIN_A");
    wb.setName("BASE WB");
    wb.setDescription("Normal base WB");
    wb.setOwner(user);
    wb.setType(WorkbasketType.TOPIC);
    wb = (WorkbasketImpl) workbasketService.createWorkbasket(wb);
    createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true);
    WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket("key77", "DOMAIN_A");
    wbNoAppend.setName("Test-Security-WorkBasket-APPEND");
    wbNoAppend.setDescription("Workbasket without permission APPEND on Task");
    wbNoAppend.setOwner(user);
    wbNoAppend.setType(WorkbasketType.PERSONAL);
    wbNoAppend = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoAppend);
    createWorkbasketWithSecurity(wbNoAppend, wbNoAppend.getOwner(), true, true, false, true);
    WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket("k99", "DOMAIN_B");
    wbNoTransfer.setName("Test-Security-WorkBasket-TRANSFER");
    wbNoTransfer.setDescription("Workbasket without permission TRANSFER on Task");
    wbNoTransfer.setOwner(user);
    wbNoTransfer.setType(WorkbasketType.CLEARANCE);
    wbNoTransfer = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoTransfer);
    createWorkbasketWithSecurity(wbNoTransfer, wbNoTransfer.getOwner(), true, true, true, false);
    TaskImpl task = (TaskImpl) taskServiceImpl.newTask(wb.getId());
    task.setName("Task Name");
    task.setDescription("Task used for transfer Test");
    task.setOwner(user);
    task.setClassificationKey(classification.getKey());
    task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
    task = (TaskImpl) taskServiceImpl.createTask(task);
    // Check failing with missing APPEND
    try {
        task = (TaskImpl) taskServiceImpl.transfer(task.getId(), wbNoAppend.getId());
        fail("Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.");
    } catch (NotAuthorizedException e) {
        if (!e.getMessage().contains("APPEND")) {
            fail("Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.");
        }
        assertThat(task.isTransferred(), equalTo(false));
        assertThat(task.getWorkbasketKey(), not(equalTo(wbNoAppend.getKey())));
        assertThat(task.getWorkbasketKey(), equalTo(wb.getKey()));
    }
    // Check failing with missing TRANSFER
    task.setId("");
    task.getWorkbasketSummaryImpl().setId(wbNoTransfer.getId());
    task.setWorkbasketKey(null);
    task = (TaskImpl) taskServiceImpl.createTask(task);
    try {
        task = (TaskImpl) taskServiceImpl.transfer(task.getId(), wb.getId());
        fail("Transfer Task should be FAILD, because there are no TRANSFER-Rights on current WB.");
    } catch (NotAuthorizedException e) {
        if (!e.getMessage().contains("TRANSFER")) {
            fail("Transfer Task should be FAILD, because there are no APPEND-Rights on current WB.");
        }
        assertThat(task.isTransferred(), equalTo(false));
        assertThat(task.getWorkbasketKey(), not(equalTo(wbNoAppend.getKey())));
    }
}
Also used : TaskanaEngineConfiguration(pro.taskana.configuration.TaskanaEngineConfiguration) TaskImpl(pro.taskana.impl.TaskImpl) WorkbasketImpl(pro.taskana.impl.WorkbasketImpl) NotAuthorizedException(pro.taskana.exceptions.NotAuthorizedException) ClassificationImpl(pro.taskana.impl.ClassificationImpl) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Aggregations

TaskanaEngineConfiguration (pro.taskana.configuration.TaskanaEngineConfiguration)20 DBCleaner (pro.taskana.impl.configuration.DBCleaner)16 DataSource (javax.sql.DataSource)11 TestDataGenerator (pro.taskana.database.TestDataGenerator)8 Before (org.junit.Before)6 TaskanaEngineImpl (pro.taskana.impl.TaskanaEngineImpl)6 Test (org.junit.Test)5 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)4 TaskanaEngine (pro.taskana.TaskanaEngine)3 WithAccessId (pro.taskana.security.WithAccessId)3 Classification (pro.taskana.Classification)2 Task (pro.taskana.Task)2 Workbasket (pro.taskana.Workbasket)2 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)2 ClassificationImpl (pro.taskana.impl.ClassificationImpl)2 TaskImpl (pro.taskana.impl.TaskImpl)2 TaskServiceImpl (pro.taskana.impl.TaskServiceImpl)2 WorkbasketImpl (pro.taskana.impl.WorkbasketImpl)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1