TSK-858: extracted default db test to separate test file.

This commit is contained in:
Holger Hagen 2019-07-24 08:59:10 +02:00 committed by Dennis Lehmann
parent bee34a5cec
commit 469452b50b
3 changed files with 34 additions and 88 deletions

View File

@ -64,13 +64,18 @@ import pro.taskana.security.WithAccessId;
public class TaskServiceImplIntAutocommitTest {
private DataSource dataSource;
private TaskServiceImpl taskServiceImpl;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
private TaskanaEngine taskanaEngine;
private TaskanaEngineImpl taskanaEngineImpl;
private ClassificationService classificationService;
private WorkbasketService workbasketService;
private TaskServiceImpl taskServiceImpl;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
private TaskanaEngine taskanaEngine;
private TaskanaEngineImpl taskanaEngineImpl;
private ClassificationService classificationService;
private WorkbasketService workbasketService;
@Before
public void setup() throws SQLException {
@ -93,10 +98,12 @@ public class TaskServiceImplIntAutocommitTest {
WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException,
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
Workbasket wb = workbasketService.newWorkbasket("workbasket", "DOMAIN_A");
wb.setName("workbasket");
wb.setType(WorkbasketType.GROUP);
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
taskanaEngine.getClassificationService().createClassification(classification);
@ -119,6 +126,7 @@ public class TaskServiceImplIntAutocommitTest {
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException {
Workbasket wb = workbasketService.newWorkbasket("wb1k1", "DOMAIN_A");
wb.setName("sdf");
wb.setType(WorkbasketType.GROUP);
@ -127,7 +135,8 @@ public class TaskServiceImplIntAutocommitTest {
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
classification = taskanaEngine.getClassificationService()
.createClassification(classification);
classification = taskanaEngine.getClassificationService().getClassification(
classification = taskanaEngine.getClassificationService()
.getClassification(
classification.getKey(),
classification.getDomain());
@ -143,35 +152,6 @@ public class TaskServiceImplIntAutocommitTest {
taskServiceImpl2.getTask(wb.getId());
}
@Test
public void testCreateTaskInTaskanaWithDefaultDb()
throws SQLException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException {
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(null, false, false,
null);
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());
}
@Test
public void should_ReturnList_when_BuilderIsUsed() throws NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,

View File

@ -47,13 +47,11 @@ import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.ClassificationImpl;
import pro.taskana.impl.ClassificationServiceImpl;
import pro.taskana.impl.JunitHelper;
import pro.taskana.impl.TaskImpl;
import pro.taskana.impl.TaskServiceImpl;
import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.impl.WorkbasketServiceImpl;
import pro.taskana.impl.WorkbasketSummaryImpl;
import pro.taskana.impl.configuration.DBCleaner;
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
@ -71,12 +69,19 @@ import pro.taskana.security.WithAccessId;
public class TaskServiceImplIntExplicitTest {
private static DataSource dataSource;
private static DBCleaner cleaner;
private static TaskServiceImpl taskServiceImpl;
private static TaskanaEngineConfiguration taskanaEngineConfiguration;
private static TaskanaEngine taskanaEngine;
private static TaskanaEngineImpl taskanaEngineImpl;
private static ClassificationService classificationService;
private static WorkbasketService workbasketService;
@BeforeClass
@ -175,45 +180,6 @@ public class TaskServiceImplIntExplicitTest {
connection.commit();
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test
public void testCreateTaskInTaskanaWithDefaultDb()
throws SQLException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException {
DataSource ds = TaskanaEngineConfiguration.createDefaultDataSource();
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(ds, false, false,
null);
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);
}
@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test(expected = WorkbasketNotFoundException.class)
public void createTaskShouldThrowWorkbasketNotFoundException()