TSK-73 Create Workbasket
This commit is contained in:
parent
9c6f2db7eb
commit
407a4a33d8
|
@ -40,9 +40,8 @@ public class TaskanaRestTest {
|
|||
public Response startTask() throws NotAuthorizedException, WorkbasketNotFoundException,
|
||||
ClassificationNotFoundException, ClassificationAlreadyExistException, InvalidWorkbasketException,
|
||||
TaskAlreadyExistException, InvalidArgumentException {
|
||||
Workbasket workbasket = taskanaEjb.getWorkbasketService().newWorkbasket();
|
||||
Workbasket workbasket = taskanaEjb.getWorkbasketService().newWorkbasket("key");
|
||||
workbasket.setName("wb");
|
||||
workbasket.setKey("key");
|
||||
workbasket.setDomain("cdiDomain");
|
||||
workbasket.setType(WorkbasketType.PERSONAL);
|
||||
taskanaEjb.getWorkbasketService().createWorkbasket(workbasket);
|
||||
|
|
|
@ -45,6 +45,7 @@ public interface BaseQuery<T> {
|
|||
* amount of elements for this page.
|
||||
* @return resulList for the current query starting at X and returning max Y elements.
|
||||
* @throws NotAuthorizedException
|
||||
* if the user is not authorized to perform this query
|
||||
*/
|
||||
default List<T> listPage(int pageNumber, int pageSize) throws NotAuthorizedException {
|
||||
int offset = (pageNumber < 0) ? 0 : (pageNumber * pageSize);
|
||||
|
|
|
@ -30,14 +30,6 @@ public interface Workbasket {
|
|||
*/
|
||||
String getKey();
|
||||
|
||||
/**
|
||||
* Set the key of the workbasket.
|
||||
*
|
||||
* @param key
|
||||
* the key of the workbasket
|
||||
*/
|
||||
void setKey(String key);
|
||||
|
||||
/**
|
||||
* Returns the domain of the workbasket.
|
||||
*
|
||||
|
@ -75,14 +67,6 @@ public interface Workbasket {
|
|||
*/
|
||||
Instant getModified();
|
||||
|
||||
/**
|
||||
* Sets the time when the workbasket was modified the last time.
|
||||
*
|
||||
* @param modified
|
||||
* as Instant
|
||||
*/
|
||||
void setModified(Instant modified);
|
||||
|
||||
/**
|
||||
* Returns the name of the workbasket.
|
||||
*
|
||||
|
|
|
@ -56,13 +56,9 @@ public interface WorkbasketService {
|
|||
* @return the created and persisted Workbasket
|
||||
* @throws InvalidWorkbasketException
|
||||
* If a required property of the Workbasket is not set.
|
||||
* @throws WorkbasketNotFoundException
|
||||
* If the to be created work basket references a distribution target that does not exist.
|
||||
* @throws NotAuthorizedException
|
||||
* If the current user or group does not have the permissions for interactions.
|
||||
*/
|
||||
Workbasket createWorkbasket(Workbasket workbasket)
|
||||
throws InvalidWorkbasketException, WorkbasketNotFoundException, NotAuthorizedException;
|
||||
throws InvalidWorkbasketException;
|
||||
|
||||
/**
|
||||
* Update a Workbasket.
|
||||
|
@ -163,9 +159,11 @@ public interface WorkbasketService {
|
|||
/**
|
||||
* Returns a new workbasket which is not persisted.
|
||||
*
|
||||
* @param key
|
||||
* the workbasket key used to identify the workbasket
|
||||
* @return newWorkbasket
|
||||
*/
|
||||
Workbasket newWorkbasket();
|
||||
Workbasket newWorkbasket(String key);
|
||||
|
||||
/**
|
||||
* Returns a set with all permissions of the current user at this workbasket.
|
||||
|
|
|
@ -46,7 +46,6 @@ public class WorkbasketImpl implements Workbasket {
|
|||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
@ -65,7 +64,6 @@ public class WorkbasketImpl implements Workbasket {
|
|||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModified(Instant modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
|
||||
@Override
|
||||
public Workbasket createWorkbasket(Workbasket newWorkbasket)
|
||||
throws InvalidWorkbasketException, WorkbasketNotFoundException, NotAuthorizedException {
|
||||
throws InvalidWorkbasketException {
|
||||
LOGGER.debug("entry to createtWorkbasket(workbasket)", newWorkbasket);
|
||||
Workbasket result = null;
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) newWorkbasket;
|
||||
|
@ -379,8 +379,10 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Workbasket newWorkbasket() {
|
||||
return new WorkbasketImpl();
|
||||
public Workbasket newWorkbasket(String key) {
|
||||
WorkbasketImpl wb = new WorkbasketImpl();
|
||||
wb.setKey(key);
|
||||
return wb;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -526,6 +528,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
throws NotAuthorizedException {
|
||||
LOGGER.debug("entry to checkAuthorization(workbasketId = {}, workbasketAuthorization = {})", workbasketKey,
|
||||
workbasketAuthorization);
|
||||
if ((workbasketAuthorization == null && workbasketKey == null) || workbasketAuthorization == null) {
|
||||
throw new SystemException("checkAuthorization was called with an invalid parameter combination");
|
||||
}
|
||||
boolean isAuthorized = false;
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
|
@ -556,7 +561,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
"checkAuthorizationImpl was called with both workbasketKey and workbasketId set to null");
|
||||
}
|
||||
|
||||
if (accessItems.size() <= 0) {
|
||||
if (accessItems.isEmpty()) {
|
||||
throw new NotAuthorizedException("Not authorized. Authorization '" + workbasketAuthorization.name()
|
||||
+ "' on workbasket '" + workbasketKey + "' is needed.");
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
Assert.assertEquals("7654321", updatedTask.getPrimaryObjRef().getValue());
|
||||
Assert.assertNotNull(updatedTask.getCreated());
|
||||
Assert.assertNotNull(updatedTask.getModified());
|
||||
Assert.assertTrue(modifiedOriginal.isBefore(updatedTask.getModified()));
|
||||
Assert.assertFalse(modifiedOriginal.isAfter(updatedTask.getModified()));
|
||||
Assert.assertNotEquals(updatedTask.getCreated(), updatedTask.getModified());
|
||||
Assert.assertEquals(task.getCreated(), updatedTask.getCreated());
|
||||
Assert.assertEquals(task.isRead(), updatedTask.isRead());
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
package acceptance.workbasket;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import acceptance.AbstractAccTest;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.model.WorkbasketType;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
|
||||
/**
|
||||
* Acceptance test for all "get workbasket" scenarios.
|
||||
*/
|
||||
@RunWith(JAASRunner.class)
|
||||
public class CreateWorkbasketAccTest extends AbstractAccTest {
|
||||
|
||||
public CreateWorkbasketAccTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWorkbasket()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
InvalidWorkbasketException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
|
||||
int before = workbasketService.getWorkbaskets().size();
|
||||
Workbasket workbasket = workbasketService.newWorkbasket("key");
|
||||
workbasket.setName("Megabasket");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setDomain("novatec");
|
||||
workbasket.setOrgLevel1("company");
|
||||
workbasketService.createWorkbasket(workbasket);
|
||||
Assert.assertEquals(before + 1, workbasketService.getWorkbaskets().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWorkbasketWithMissingRequiredField()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
|
||||
Workbasket workbasket = workbasketService.newWorkbasket(null);
|
||||
workbasket.setName("Megabasket");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setDomain("novatec");
|
||||
workbasket.setOrgLevel1("company");
|
||||
try { // missing key
|
||||
workbasketService.createWorkbasket(workbasket);
|
||||
fail("InvalidWorkbasketException was expected");
|
||||
} catch (InvalidWorkbasketException e) {
|
||||
}
|
||||
|
||||
workbasket = workbasketService.newWorkbasket("key");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setDomain("novatec");
|
||||
workbasket.setOrgLevel1("company");
|
||||
try { // missing name
|
||||
workbasketService.createWorkbasket(workbasket);
|
||||
fail("InvalidWorkbasketException was expected");
|
||||
} catch (InvalidWorkbasketException e) {
|
||||
}
|
||||
|
||||
workbasket = workbasketService.newWorkbasket("key");
|
||||
workbasket.setName("Megabasket");
|
||||
workbasket.setDomain("novatec");
|
||||
workbasket.setOrgLevel1("company");
|
||||
try { // missing type
|
||||
workbasketService.createWorkbasket(workbasket);
|
||||
fail("InvalidWorkbasketException was expected");
|
||||
} catch (InvalidWorkbasketException e) {
|
||||
}
|
||||
|
||||
workbasket = workbasketService.newWorkbasket("key");
|
||||
workbasket.setName("Megabasket");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setOrgLevel1("company");
|
||||
try { // missing domain
|
||||
workbasketService.createWorkbasket(workbasket);
|
||||
fail("InvalidWorkbasketException was expected");
|
||||
} catch (InvalidWorkbasketException e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -128,7 +128,7 @@ public class TaskMonitorServiceImplTest {
|
|||
|
||||
@Test
|
||||
public void testGetTotalNumbersOfWorkbasketLevelReport() {
|
||||
Workbasket workbasket = new WorkbasketImpl();
|
||||
WorkbasketImpl workbasket = new WorkbasketImpl();
|
||||
workbasket.setName("workbasket");
|
||||
workbasket.setKey("wb1");
|
||||
List<Workbasket> workbaskets = Arrays.asList(workbasket);
|
||||
|
@ -157,7 +157,7 @@ public class TaskMonitorServiceImplTest {
|
|||
|
||||
@Test
|
||||
public void testGetWorkbasketLevelReportWithReportLineItemDefinitions() {
|
||||
Workbasket workbasket = new WorkbasketImpl();
|
||||
WorkbasketImpl workbasket = new WorkbasketImpl();
|
||||
workbasket.setName("workbasket");
|
||||
workbasket.setKey("wb1");
|
||||
List<Workbasket> workbaskets = Arrays.asList(workbasket);
|
||||
|
@ -191,7 +191,7 @@ public class TaskMonitorServiceImplTest {
|
|||
|
||||
@Test
|
||||
public void testGetTotalNumbersOfCatgoryReport() {
|
||||
Workbasket workbasket = new WorkbasketImpl();
|
||||
WorkbasketImpl workbasket = new WorkbasketImpl();
|
||||
workbasket.setName("workbasket");
|
||||
workbasket.setKey("wb1");
|
||||
List<Workbasket> workbaskets = Arrays.asList(workbasket);
|
||||
|
@ -220,7 +220,7 @@ public class TaskMonitorServiceImplTest {
|
|||
|
||||
@Test
|
||||
public void testGetCategoryReportWithReportLineItemDefinitions() {
|
||||
Workbasket workbasket = new WorkbasketImpl();
|
||||
WorkbasketImpl workbasket = new WorkbasketImpl();
|
||||
workbasket.setName("workbasket");
|
||||
workbasket.setKey("wb1");
|
||||
List<Workbasket> workbaskets = Arrays.asList(workbasket);
|
||||
|
|
|
@ -102,8 +102,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException,
|
||||
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
|
||||
InvalidArgumentException {
|
||||
Workbasket wb = workbasketService.newWorkbasket();
|
||||
wb.setKey("workbasket");
|
||||
Workbasket wb = workbasketService.newWorkbasket("workbasket");
|
||||
wb.setName("workbasket");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
wb.setDomain("novatec");
|
||||
|
@ -130,11 +129,10 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException {
|
||||
Workbasket wb = workbasketService.newWorkbasket();
|
||||
Workbasket wb = workbasketService.newWorkbasket("wb1k1");
|
||||
wb.setName("sdf");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
wb.setDomain("novatec");
|
||||
wb.setKey("wb1k1");
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
|
||||
Classification classification = classificationService.newClassification("novatec", "TEST", "t1");
|
||||
|
@ -168,8 +166,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
((TaskanaEngineImpl) te).setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
|
||||
TaskServiceImpl taskServiceImpl = (TaskServiceImpl) te.getTaskService();
|
||||
|
||||
Workbasket wb = workbasketService.newWorkbasket();
|
||||
wb.setKey("workbasket");
|
||||
Workbasket wb = workbasketService.newWorkbasket("workbasket");
|
||||
wb.setName("workbasket");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
wb.setDomain("novatec");
|
||||
|
@ -191,8 +188,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, SystemException {
|
||||
Workbasket wb = workbasketService.newWorkbasket();
|
||||
wb.setKey("key");
|
||||
Workbasket wb = workbasketService.newWorkbasket("key");
|
||||
wb.setName("workbasket");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
wb.setDomain("novatec");
|
||||
|
@ -227,8 +223,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
|
||||
@Test
|
||||
public void shouldReturnTaskSummaryListWithValues() throws Exception {
|
||||
Workbasket dummyWorkbasket = workbasketService.newWorkbasket();
|
||||
dummyWorkbasket.setKey("Dummy-Key");
|
||||
Workbasket dummyWorkbasket = workbasketService.newWorkbasket("Dummy-Key");
|
||||
dummyWorkbasket.setName("Dummy-Basket");
|
||||
dummyWorkbasket.setType(WorkbasketType.GROUP);
|
||||
dummyWorkbasket.setDomain("novatec");
|
||||
|
@ -266,8 +261,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void shouldThrowWorkbasketNotFoundExceptionByInvalidWorkbasketParameter()
|
||||
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
wb.setKey("key");
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("key");
|
||||
wb.setName("wb");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
wb.setDomain("novatec");
|
||||
|
@ -292,19 +286,18 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
final int sleepTime = 100;
|
||||
|
||||
// Source Workbasket
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket("key1");
|
||||
wb.setName("Basic-Workbasket");
|
||||
wb.setDescription("Just used as base WB for Task here");
|
||||
wb.setKey("key1");
|
||||
wb.setDomain("domain");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
wb.setOwner("The Tester ID");
|
||||
sourceWB = workbasketService.createWorkbasket(wb);
|
||||
|
||||
// Destination Workbasket
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket("k1");
|
||||
wb.setName("Desination-WorkBasket");
|
||||
wb.setKey("k1");
|
||||
|
||||
wb.setDomain("domain");
|
||||
wb.setType(WorkbasketType.CLEARANCE);
|
||||
wb.setDescription("Destination WB where Task should be transfered to");
|
||||
|
@ -369,33 +362,32 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
classification.setName("Transfert-Task Classification");
|
||||
classificationService.createClassification(classification);
|
||||
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("k5");
|
||||
wb.setName("BASE WB");
|
||||
wb.setDescription("Normal base WB");
|
||||
wb.setOwner(user);
|
||||
wb.setKey("k5");
|
||||
wb.setDomain("test-domain");
|
||||
wb.setType(WorkbasketType.TOPIC);
|
||||
wb = (WorkbasketImpl) workbasketService.createWorkbasket(wb);
|
||||
createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true);
|
||||
|
||||
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket("key77");
|
||||
wbNoAppend.setName("Test-Security-WorkBasket-APPEND");
|
||||
wbNoAppend.setDescription("Workbasket without permission APPEND on Task");
|
||||
wbNoAppend.setOwner(user);
|
||||
wbNoAppend.setDomain("d2");
|
||||
wbNoAppend.setType(WorkbasketType.PERSONAL);
|
||||
wbNoAppend.setKey("key77");
|
||||
|
||||
wbNoAppend = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoAppend);
|
||||
createWorkbasketWithSecurity(wbNoAppend, wbNoAppend.getOwner(), true, true, false, true);
|
||||
|
||||
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket("k99");
|
||||
wbNoTransfer.setName("Test-Security-WorkBasket-TRANSFER");
|
||||
wbNoTransfer.setDescription("Workbasket without permission TRANSFER on Task");
|
||||
wbNoTransfer.setOwner(user);
|
||||
wbNoTransfer.setDomain("test-domain");
|
||||
wbNoTransfer.setType(WorkbasketType.CLEARANCE);
|
||||
wbNoTransfer.setKey("k99");
|
||||
|
||||
wbNoTransfer = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoTransfer);
|
||||
createWorkbasketWithSecurity(wbNoTransfer, wbNoTransfer.getOwner(), true, true, true, false);
|
||||
|
||||
|
@ -441,8 +433,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException,
|
||||
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
|
||||
InvalidArgumentException {
|
||||
Workbasket wb = workbasketService.newWorkbasket();
|
||||
wb.setKey("workbasket");
|
||||
Workbasket wb = workbasketService.newWorkbasket("workbasket");
|
||||
wb.setName("workbasket");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
wb.setDomain("novatec");
|
||||
|
|
|
@ -111,10 +111,10 @@ public class TaskServiceImplIntExplicitTest {
|
|||
|
||||
generateSampleAccessItems();
|
||||
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1");
|
||||
workbasket.setName("workbasket");
|
||||
workbasket.setId("1"); // set id manually for authorization tests
|
||||
workbasket.setKey("k1");
|
||||
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setDomain("novatec");
|
||||
Classification classification = classificationService.newClassification("novatec", "TEST", "type1");
|
||||
|
@ -185,9 +185,9 @@ public class TaskServiceImplIntExplicitTest {
|
|||
WorkbasketServiceImpl workBasketServiceImpl = (WorkbasketServiceImpl) te.getWorkbasketService();
|
||||
ClassificationServiceImpl classificationServiceImpl = (ClassificationServiceImpl) te.getClassificationService();
|
||||
|
||||
Workbasket workbasket = workbasketService.newWorkbasket();
|
||||
Workbasket workbasket = workbasketService.newWorkbasket("K99");
|
||||
workbasket.setName("workbasket");
|
||||
workbasket.setKey("K99");
|
||||
|
||||
workbasket.setName("workbasket99");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setDomain("novatec");
|
||||
|
@ -242,11 +242,11 @@ public class TaskServiceImplIntExplicitTest {
|
|||
|
||||
Instant tomorrow = Instant.now().plus(Duration.ofDays(1L));
|
||||
|
||||
Workbasket wb = workbasketService.newWorkbasket();
|
||||
Workbasket wb = workbasketService.newWorkbasket("k1");
|
||||
wb.setDomain("novatec");
|
||||
wb.setName("wbk1");
|
||||
wb.setType(WorkbasketType.PERSONAL);
|
||||
wb.setKey("k1");
|
||||
|
||||
workbasketService.createWorkbasket(wb);
|
||||
|
||||
Task test = taskServiceImpl.newTask("k1");
|
||||
|
@ -306,9 +306,8 @@ public class TaskServiceImplIntExplicitTest {
|
|||
|
||||
generateSampleAccessItems();
|
||||
|
||||
Workbasket wb = workbasketService.newWorkbasket();
|
||||
Workbasket wb = workbasketService.newWorkbasket("WB NR.1");
|
||||
wb.setName("dummy-WB");
|
||||
wb.setKey("WB NR.1");
|
||||
wb.setDomain("nova");
|
||||
wb.setType(WorkbasketType.PERSONAL);
|
||||
wb = workbasketService.createWorkbasket(wb);
|
||||
|
@ -335,12 +334,11 @@ public class TaskServiceImplIntExplicitTest {
|
|||
|
||||
generateSampleAccessItems();
|
||||
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1");
|
||||
workbasket.setName("workbasket");
|
||||
Classification classification = classificationService.newClassification("novatec", "TEST", "t1");
|
||||
classificationService.createClassification(classification);
|
||||
workbasket.setId("1"); // set id manually for authorization tests
|
||||
workbasket.setKey("k1");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setDomain("novatec");
|
||||
workbasket = (WorkbasketImpl) workbasketService.createWorkbasket(workbasket);
|
||||
|
@ -389,12 +387,11 @@ public class TaskServiceImplIntExplicitTest {
|
|||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
// Source Workbasket
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket("sourceWbKey");
|
||||
wb.setName("Basic-Workbasket");
|
||||
wb.setDescription("Just used as base WB for Task here");
|
||||
wb.setOwner(user);
|
||||
wb.setDomain("domain");
|
||||
wb.setKey("sourceWbKey");
|
||||
wb.setType(WorkbasketType.PERSONAL);
|
||||
sourceWB = workbasketService.createWorkbasket(wb);
|
||||
|
||||
|
@ -402,13 +399,13 @@ public class TaskServiceImplIntExplicitTest {
|
|||
createWorkbasketWithSecurity(sourceWB, sourceWB.getOwner(), true, true, true, true);
|
||||
|
||||
// Destination Workbasket
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket("wb2Key");
|
||||
wb.setName("Desination-WorkBasket");
|
||||
wb.setDescription("Destination WB where Task should be transfered to");
|
||||
wb.setOwner(user);
|
||||
wb.setDomain("domain");
|
||||
wb.setType(WorkbasketType.TOPIC);
|
||||
wb.setKey("wb2Key");
|
||||
|
||||
destinationWB = workbasketService.createWorkbasket(wb);
|
||||
createWorkbasketWithSecurity(destinationWB, destinationWB.getOwner(), false, true, true, true);
|
||||
|
||||
|
@ -476,31 +473,29 @@ public class TaskServiceImplIntExplicitTest {
|
|||
classification.setName("Transfert-Task Classification");
|
||||
classificationService.createClassification(classification);
|
||||
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("wbKey1");
|
||||
wb.setName("BASE WB");
|
||||
wb.setDescription("Normal base WB");
|
||||
wb.setOwner(user);
|
||||
wb.setKey("wbKey1");
|
||||
wb.setDomain("test-domain");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
wb = (WorkbasketImpl) workbasketService.createWorkbasket(wb);
|
||||
createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true);
|
||||
|
||||
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoAppend");
|
||||
wbNoAppend.setName("Test-Security-WorkBasket-APPEND");
|
||||
wbNoAppend.setDescription("Workbasket without permission APPEND on Task");
|
||||
wbNoAppend.setOwner(user);
|
||||
wbNoAppend.setKey("keyNoAppend");
|
||||
|
||||
wbNoAppend.setDomain("anotherDomain");
|
||||
wbNoAppend.setType(WorkbasketType.CLEARANCE);
|
||||
wbNoAppend = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoAppend);
|
||||
createWorkbasketWithSecurity(wbNoAppend, wbNoAppend.getOwner(), true, true, false, true);
|
||||
|
||||
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoTransfer");
|
||||
wbNoTransfer.setName("Test-Security-WorkBasket-TRANSFER");
|
||||
wbNoTransfer.setDescription("Workbasket without permission TRANSFER on Task");
|
||||
wbNoTransfer.setOwner(user);
|
||||
wbNoTransfer.setKey("keyNoTransfer");
|
||||
wbNoTransfer.setDomain("test-domain");
|
||||
wbNoTransfer.setType(WorkbasketType.GROUP);
|
||||
wbNoTransfer = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoTransfer);
|
||||
|
@ -545,8 +540,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
|
||||
private Task generateDummyTask() throws ClassificationAlreadyExistException, ClassificationNotFoundException,
|
||||
WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket();
|
||||
workbasket.setKey("wb");
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("wb");
|
||||
workbasket.setName("wb");
|
||||
workbasket.setId("1"); // set id manually for authorization tests
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
|
|
|
@ -89,10 +89,9 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
public void testInsertWorkbasket()
|
||||
throws NotAuthorizedException, InvalidWorkbasketException, WorkbasketNotFoundException {
|
||||
int before = workBasketService.getWorkbaskets().size();
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workBasketService.newWorkbasket("key");
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket.setId(id1);
|
||||
workbasket.setKey("key");
|
||||
workbasket.setName("Megabasket");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setDomain("novatec");
|
||||
|
@ -104,26 +103,23 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
public void testSelectAllWorkbaskets()
|
||||
throws NotAuthorizedException, InvalidWorkbasketException, WorkbasketNotFoundException {
|
||||
int before = workBasketService.getWorkbaskets().size();
|
||||
WorkbasketImpl workbasket0 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl workbasket0 = (WorkbasketImpl) workBasketService.newWorkbasket("key0");
|
||||
String id0 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket0.setId(id0);
|
||||
workbasket0.setKey("key0");
|
||||
workbasket0.setName("Superbasket");
|
||||
workbasket0.setType(WorkbasketType.PERSONAL);
|
||||
workbasket0.setDomain("novatec");
|
||||
workBasketService.createWorkbasket(workbasket0);
|
||||
WorkbasketImpl workbasket1 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl workbasket1 = (WorkbasketImpl) workBasketService.newWorkbasket("key1");
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket1.setId(id1);
|
||||
workbasket1.setKey("key1");
|
||||
workbasket1.setName("Megabasket");
|
||||
workbasket1.setType(WorkbasketType.GROUP);
|
||||
workbasket1.setDomain("novatec");
|
||||
workBasketService.createWorkbasket(workbasket1);
|
||||
WorkbasketImpl workbasket2 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl workbasket2 = (WorkbasketImpl) workBasketService.newWorkbasket("key2");
|
||||
String id2 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket2.setId(id2);
|
||||
workbasket2.setKey("key2");
|
||||
workbasket2.setName("Hyperbasket");
|
||||
workbasket2.setType(WorkbasketType.GROUP);
|
||||
workbasket2.setDomain("novatec");
|
||||
|
@ -339,9 +335,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
|
||||
private void generateSampleDataForQuery()
|
||||
throws InvalidWorkbasketException, WorkbasketNotFoundException, NotAuthorizedException {
|
||||
WorkbasketImpl basket1 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl basket1 = (WorkbasketImpl) workBasketService.newWorkbasket("k1");
|
||||
basket1.setId("1");
|
||||
basket1.setKey("k1");
|
||||
basket1.setName("Basket1");
|
||||
basket1.setOwner("Eberhardt");
|
||||
basket1.setType(WorkbasketType.GROUP);
|
||||
|
@ -357,9 +352,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
accessItem.setPermRead(true);
|
||||
workBasketService.createWorkbasketAuthorization(accessItem);
|
||||
|
||||
WorkbasketImpl basket2 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl basket2 = (WorkbasketImpl) workBasketService.newWorkbasket("k2");
|
||||
basket2.setId("2");
|
||||
basket2.setKey("k2");
|
||||
basket2.setName("Basket2");
|
||||
basket2.setOwner("Konstantin");
|
||||
basket2.setType(WorkbasketType.CLEARANCE);
|
||||
|
@ -376,9 +370,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
accessItem2.setPermOpen(true);
|
||||
workBasketService.createWorkbasketAuthorization(accessItem2);
|
||||
|
||||
WorkbasketImpl basket3 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl basket3 = (WorkbasketImpl) workBasketService.newWorkbasket("k3");
|
||||
basket3.setId("3");
|
||||
basket3.setKey("k3");
|
||||
basket3.setName("Basket3");
|
||||
basket3.setOwner("Holger");
|
||||
basket3.setType(WorkbasketType.TOPIC);
|
||||
|
@ -393,9 +386,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
accessItem3.setPermAppend(true);
|
||||
workBasketService.createWorkbasketAuthorization(accessItem3);
|
||||
|
||||
WorkbasketImpl basket4 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl basket4 = (WorkbasketImpl) workBasketService.newWorkbasket("k4");
|
||||
basket4.setId("4");
|
||||
basket4.setKey("k4");
|
||||
basket4.setName("Basket4");
|
||||
basket4.setOwner("Holger");
|
||||
basket4.setType(WorkbasketType.PERSONAL);
|
||||
|
@ -454,9 +446,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
}
|
||||
|
||||
private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type) {
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket(key);
|
||||
wb.setId(id);
|
||||
wb.setKey(key);
|
||||
wb.setDomain(domain);
|
||||
wb.setName(name);
|
||||
wb.setDescription("Description of a Workbasket...");
|
||||
|
|
|
@ -80,10 +80,9 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
taskanaEngineImpl.setConnection(connection);
|
||||
workBasketService = taskanaEngine.getWorkbasketService();
|
||||
int before = workBasketService.getWorkbaskets().size();
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workBasketService.newWorkbasket("key");
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket.setId(id1);
|
||||
workbasket.setKey("key");
|
||||
workbasket.setName("Megabasket");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setDomain("novatec");
|
||||
|
@ -99,26 +98,23 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
taskanaEngineImpl.setConnection(connection);
|
||||
workBasketService = taskanaEngine.getWorkbasketService();
|
||||
int before = workBasketService.getWorkbaskets().size();
|
||||
WorkbasketImpl workbasket0 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl workbasket0 = (WorkbasketImpl) workBasketService.newWorkbasket("key0");
|
||||
String id0 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket0.setId(id0);
|
||||
workbasket0.setKey("key0");
|
||||
workbasket0.setName("Superbasket");
|
||||
workbasket0.setType(WorkbasketType.GROUP);
|
||||
workbasket0.setDomain("novatec");
|
||||
workBasketService.createWorkbasket(workbasket0);
|
||||
WorkbasketImpl workbasket1 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl workbasket1 = (WorkbasketImpl) workBasketService.newWorkbasket("key1");
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket1.setId(id1);
|
||||
workbasket1.setKey("key1");
|
||||
workbasket1.setName("Megabasket");
|
||||
workbasket1.setType(WorkbasketType.GROUP);
|
||||
workbasket1.setDomain("novatec");
|
||||
workbasket1 = (WorkbasketImpl) workBasketService.createWorkbasket(workbasket1);
|
||||
WorkbasketImpl workbasket2 = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl workbasket2 = (WorkbasketImpl) workBasketService.newWorkbasket("key2");
|
||||
String id2 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket2.setId(id2);
|
||||
workbasket2.setKey("key2");
|
||||
workbasket2.setName("Hyperbasket");
|
||||
workbasket2.setType(WorkbasketType.GROUP);
|
||||
workbasket2.setDomain("novatec");
|
||||
|
@ -135,10 +131,9 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
workBasketService = taskanaEngine.getWorkbasketService();
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workBasketService.newWorkbasket("key0");
|
||||
String id0 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket.setId(id0);
|
||||
workbasket.setKey("key0");
|
||||
workbasket.setName("Superbasket");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setDomain("novatec");
|
||||
|
@ -299,9 +294,8 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type) {
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket();
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket(key);
|
||||
wb.setId(id);
|
||||
wb.setKey(key);
|
||||
wb.setDomain(domain);
|
||||
wb.setName(name);
|
||||
wb.setDescription("Description of a Workbasket...");
|
||||
|
|
|
@ -116,10 +116,9 @@ public class TaskanaTestController {
|
|||
}
|
||||
|
||||
private Workbasket createWorkBasket(String key, String name) {
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) taskanaEngine.getWorkbasketService().newWorkbasket();
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) taskanaEngine.getWorkbasketService().newWorkbasket(key);
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket.setId(id1);
|
||||
workbasket.setKey(key);
|
||||
workbasket.setName(name);
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setDomain("generali");
|
||||
|
|
|
@ -27,7 +27,7 @@ import pro.taskana.model.WorkbasketAccessItem;
|
|||
import pro.taskana.model.WorkbasketAuthorization;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(path = "/v1/workbaskets", produces = { MediaType.APPLICATION_JSON_VALUE })
|
||||
@RequestMapping(path = "/v1/workbaskets", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
public class WorkbasketController {
|
||||
|
||||
@Autowired
|
||||
|
@ -110,10 +110,6 @@ public class WorkbasketController {
|
|||
return new ResponseEntity<>(createdWorkbasket, HttpStatus.CREATED);
|
||||
} catch (InvalidWorkbasketException e) {
|
||||
return new ResponseEntity<>(HttpStatus.CONFLICT);
|
||||
} catch (WorkbasketNotFoundException e) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
} catch (NotAuthorizedException e) {
|
||||
return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue