Search in sources :

Example 41 with Workbasket

use of pro.taskana.Workbasket in project taskana by Taskana.

the class TaskServiceImplIntAutocommitTest method testWithPrimaryObjectRef.

@Test
public void testWithPrimaryObjectRef() throws FileNotFoundException, SQLException, TaskNotFoundException, 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);
    Task task = taskServiceImpl.newTask(wb.getId());
    task.setName("Unit Test Task");
    task.setClassificationKey(classification.getKey());
    ObjectReference objRef = new ObjectReference();
    objRef.setCompany("novatec");
    objRef.setSystem("linux");
    objRef.setSystemInstance("inst1");
    objRef.setType("fast");
    objRef.setValue("4711");
    task.setPrimaryObjRef(objRef);
    task = taskServiceImpl.createTask(task);
    Task task2 = taskServiceImpl.getTask(task.getId());
    // skanaEngineImpl.getSqlSession().commit(); // needed so that the change is visible in the other session
    Assert.assertNotNull(task2);
}
Also used : Task(pro.taskana.Task) ObjectReference(pro.taskana.impl.ObjectReference) Classification(pro.taskana.Classification) Workbasket(pro.taskana.Workbasket) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Example 42 with Workbasket

use of pro.taskana.Workbasket in project taskana by Taskana.

the class TaskServiceImplIntAutocommitTest method testStartTransactionFail.

@Test(expected = TaskNotFoundException.class)
public void testStartTransactionFail() throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
    Workbasket wb = workbasketService.newWorkbasket("wb1k1", "DOMAIN_A");
    wb.setName("sdf");
    wb.setType(WorkbasketType.GROUP);
    taskanaEngine.getWorkbasketService().createWorkbasket(wb);
    Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
    classification = taskanaEngine.getClassificationService().createClassification(classification);
    classification = taskanaEngine.getClassificationService().getClassification(classification.getKey(), classification.getDomain());
    TaskImpl task = (TaskImpl) taskServiceImpl.newTask(wb.getKey(), "DOMAIN_A");
    task.setName("Unit Test Task");
    task.setClassificationKey(classification.getKey());
    task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
    taskServiceImpl.createTask(task);
    taskServiceImpl.getTask(task.getId());
    TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
    TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
    taskServiceImpl2.getTask(wb.getId());
}
Also used : TaskImpl(pro.taskana.impl.TaskImpl) Classification(pro.taskana.Classification) TaskanaEngineImpl(pro.taskana.impl.TaskanaEngineImpl) TaskServiceImpl(pro.taskana.impl.TaskServiceImpl) Workbasket(pro.taskana.Workbasket) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) Test(org.junit.Test)

Example 43 with Workbasket

use of pro.taskana.Workbasket in project taskana by Taskana.

the class WorkbasketServiceImplIntAutocommitTest method testUpdateWorkbasket.

@WithAccessId(userName = "Elena", groupNames = { "businessadmin" })
@Test
public void testUpdateWorkbasket() throws Exception {
    String id0 = IdGenerator.generateWithPrefix("TWB");
    Workbasket workbasket0 = createTestWorkbasket(id0, "key0", "DOMAIN_A", "Superbasket", WorkbasketType.GROUP);
    workbasket0 = workBasketService.createWorkbasket(workbasket0);
    createWorkbasketWithSecurity(workbasket0, "Elena", true, true, false, false);
    String id1 = IdGenerator.generateWithPrefix("TWB");
    Workbasket workbasket1 = createTestWorkbasket(id1, "key1", "DOMAIN_A", "Megabasket", WorkbasketType.GROUP);
    workbasket1 = workBasketService.createWorkbasket(workbasket1);
    createWorkbasketWithSecurity(workbasket1, "Elena", true, true, false, false);
    String id2 = IdGenerator.generateWithPrefix("TWB");
    Workbasket workbasket2 = createTestWorkbasket(id2, "key2", "DOMAIN_A", "Hyperbasket", WorkbasketType.GROUP);
    workbasket2 = workBasketService.createWorkbasket(workbasket2);
    createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false);
    List<String> distTargets = new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId()));
    Thread.sleep(SLEEP_TIME);
    workBasketService.setDistributionTargets(workbasket2.getId(), distTargets);
    String id3 = IdGenerator.generateWithPrefix("TWB");
    Workbasket workbasket3 = createTestWorkbasket(id3, "key3", "DOMAIN_A", "hm ... irgend ein basket", WorkbasketType.GROUP);
    workbasket3 = workBasketService.createWorkbasket(workbasket3);
    createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false);
    List<String> newDistTargets = new ArrayList<>(Arrays.asList(workbasket3.getId()));
    Thread.sleep(SLEEP_TIME);
    workBasketService.setDistributionTargets(workbasket2.getId(), newDistTargets);
    Workbasket foundBasket = workBasketService.getWorkbasket(workbasket2.getId());
    List<WorkbasketSummary> distributionTargets = workBasketService.getDistributionTargets(foundBasket.getId());
    Assert.assertEquals(1, distributionTargets.size());
    Assert.assertEquals(id3, distributionTargets.get(0).getId());
    Assert.assertNotEquals(workBasketService.getWorkbasket(id2).getCreated(), workBasketService.getWorkbasket(id2).getModified());
    Assert.assertEquals(workBasketService.getWorkbasket(id1).getCreated(), workBasketService.getWorkbasket(id1).getModified());
    Assert.assertEquals(workBasketService.getWorkbasket(id3).getCreated(), workBasketService.getWorkbasket(id3).getModified());
}
Also used : ArrayList(java.util.ArrayList) Workbasket(pro.taskana.Workbasket) WorkbasketSummary(pro.taskana.WorkbasketSummary) TaskanaEngineConfigurationTest(pro.taskana.impl.configuration.TaskanaEngineConfigurationTest) TaskanaEngineProxyForTest(pro.taskana.impl.TaskanaEngineProxyForTest) Test(org.junit.Test) WithAccessId(pro.taskana.security.WithAccessId)

Example 44 with Workbasket

use of pro.taskana.Workbasket in project taskana by Taskana.

the class WorkbasketController method createWorkbasket.

@PostMapping
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<WorkbasketResource> createWorkbasket(@RequestBody WorkbasketResource workbasketResource) throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException, WorkbasketNotFoundException, DomainNotFoundException {
    Workbasket workbasket = workbasketMapper.toModel(workbasketResource);
    workbasket = workbasketService.createWorkbasket(workbasket);
    return new ResponseEntity<>(workbasketMapper.toResource(workbasket), HttpStatus.CREATED);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) Workbasket(pro.taskana.Workbasket) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 45 with Workbasket

use of pro.taskana.Workbasket in project taskana by Taskana.

the class TaskServiceImpl method transferTasks.

@Override
public BulkOperationResults<String, TaskanaException> transferTasks(String destinationWorkbasketId, List<String> taskIds) throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
    try {
        taskanaEngine.openConnection();
        LOGGER.debug("entry to transferBulk(targetWbId = {}, taskIds = {})", destinationWorkbasketId, taskIds);
        // Check pre-conditions with trowing Exceptions
        if (destinationWorkbasketId == null || taskIds == null) {
            throw new InvalidArgumentException("DestinationWorkbasketId or TaskIds canĀ“t be used as NULL-Parameter.");
        }
        Workbasket destinationWorkbasket = workbasketService.getWorkbasket(destinationWorkbasketId);
        return transferTasks(taskIds, destinationWorkbasket);
    } finally {
        LOGGER.debug("exit from transferBulk(targetWbKey = {}, taskIds = {})", destinationWorkbasketId, taskIds);
        taskanaEngine.returnConnection();
    }
}
Also used : InvalidArgumentException(pro.taskana.exceptions.InvalidArgumentException) Workbasket(pro.taskana.Workbasket)

Aggregations

Workbasket (pro.taskana.Workbasket)62 Test (org.junit.Test)47 WithAccessId (pro.taskana.security.WithAccessId)23 AbstractAccTest (acceptance.AbstractAccTest)18 Task (pro.taskana.Task)18 Classification (pro.taskana.Classification)17 WorkbasketService (pro.taskana.WorkbasketService)13 ArrayList (java.util.ArrayList)11 TaskanaEngineConfigurationTest (pro.taskana.impl.configuration.TaskanaEngineConfigurationTest)10 WorkbasketSummary (pro.taskana.WorkbasketSummary)9 NotAuthorizedException (pro.taskana.exceptions.NotAuthorizedException)9 WorkbasketNotFoundException (pro.taskana.exceptions.WorkbasketNotFoundException)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 InvalidArgumentException (pro.taskana.exceptions.InvalidArgumentException)7 Attachment (pro.taskana.Attachment)6 InvalidWorkbasketException (pro.taskana.exceptions.InvalidWorkbasketException)6 Instant (java.time.Instant)5 Transactional (org.springframework.transaction.annotation.Transactional)5 WorkbasketResource (pro.taskana.rest.resource.WorkbasketResource)5 Connection (java.sql.Connection)4