TSK-242 Implement role based access control to the lib
This commit is contained in:
parent
a00289c0ab
commit
0bdbf4700b
|
@ -47,9 +47,11 @@ public interface ClassificationService {
|
|||
* if there are Task existing, which refer to this classification.
|
||||
* @throws ClassificationNotFoundException
|
||||
* if for an domain no classification specification is found.
|
||||
* @throws NotAuthorizedException
|
||||
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
|
||||
*/
|
||||
void deleteClassification(String classificationKey, String domain)
|
||||
throws ClassificationInUseException, ClassificationNotFoundException;
|
||||
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Persists a new classification after adding default values. <br >
|
||||
|
@ -60,9 +62,11 @@ public interface ClassificationService {
|
|||
* @return classification which is persisted with unique ID.
|
||||
* @throws ClassificationAlreadyExistException
|
||||
* when the classification does already exists at the given domain.
|
||||
* @throws NotAuthorizedException
|
||||
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
|
||||
*/
|
||||
Classification createClassification(Classification classification)
|
||||
throws ClassificationAlreadyExistException;
|
||||
throws ClassificationAlreadyExistException, NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Update a Classification.
|
||||
|
|
|
@ -324,8 +324,10 @@ public interface TaskService {
|
|||
* If the given Id does not refer to an existing task.
|
||||
* @throws InvalidStateException
|
||||
* If the state of the referenced task is not Completed.
|
||||
* @throws NotAuthorizedException
|
||||
* if the current user is not member of role ADMIN
|
||||
*/
|
||||
void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException;
|
||||
void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Deletes the task with the given Id.
|
||||
|
@ -338,8 +340,11 @@ public interface TaskService {
|
|||
* If the given Id does not refer to an existing task.
|
||||
* @throws InvalidStateException
|
||||
* If the state of the referenced task is not Completed and forceDelet is false.
|
||||
* @throws NotAuthorizedException
|
||||
* if the current user is not member of role ADMIN
|
||||
*/
|
||||
void deleteTask(String taskId, boolean forceDelete) throws TaskNotFoundException, InvalidStateException;
|
||||
void deleteTask(String taskId, boolean forceDelete)
|
||||
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Deletes a list of tasks.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package pro.taskana;
|
||||
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.impl.WorkbasketAuthorization;
|
||||
import pro.taskana.impl.WorkbasketType;
|
||||
|
||||
|
@ -148,9 +149,11 @@ public interface WorkbasketQuery extends BaseQuery<WorkbasketSummary> {
|
|||
* @return the current query object.
|
||||
* @throws InvalidArgumentException
|
||||
* when permission OR the accessIds are NULL.
|
||||
* @throws NotAuthorizedException
|
||||
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
|
||||
*/
|
||||
WorkbasketQuery accessIdsHavePermission(WorkbasketAuthorization permission, String... accessIds)
|
||||
throws InvalidArgumentException;
|
||||
throws InvalidArgumentException, NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Setting up the permissions for the accessIds of the CurrentUserContext. READ permissions need to be granted,too
|
||||
|
|
|
@ -52,9 +52,11 @@ public interface WorkbasketService {
|
|||
* @return the created and persisted Workbasket
|
||||
* @throws InvalidWorkbasketException
|
||||
* If a required property of the Workbasket is not set.
|
||||
* @throws NotAuthorizedException
|
||||
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
|
||||
*/
|
||||
Workbasket createWorkbasket(Workbasket workbasket)
|
||||
throws InvalidWorkbasketException;
|
||||
throws InvalidWorkbasketException, NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Update a Workbasket.
|
||||
|
@ -91,9 +93,11 @@ public interface WorkbasketService {
|
|||
* @return the created WorkbasketAccessItem
|
||||
* @throws InvalidArgumentException
|
||||
* when the preconditions doesn´t match the required ones.
|
||||
* @throws NotAuthorizedException
|
||||
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
|
||||
*/
|
||||
WorkbasketAccessItem createWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem)
|
||||
throws InvalidArgumentException;
|
||||
throws InvalidArgumentException, NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* This method updates an Workbasket Authorization.
|
||||
|
@ -103,17 +107,21 @@ public interface WorkbasketService {
|
|||
* @return the updated entity
|
||||
* @throws InvalidArgumentException
|
||||
* if accessid or workbasketkey is changed in the workbasketAccessItem
|
||||
* @throws NotAuthorizedException
|
||||
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
|
||||
*/
|
||||
WorkbasketAccessItem updateWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem)
|
||||
throws InvalidArgumentException;
|
||||
throws InvalidArgumentException, NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Deletes a specific authorization.
|
||||
*
|
||||
* @param id
|
||||
* the id of the WorbasketAccessItem to be deleted
|
||||
* @throws NotAuthorizedException
|
||||
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
|
||||
*/
|
||||
void deleteWorkbasketAuthorization(String id);
|
||||
void deleteWorkbasketAuthorization(String id) throws NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* This method checks the authorization with the saved one for the actual User.
|
||||
|
@ -187,8 +195,10 @@ public interface WorkbasketService {
|
|||
* This method provides a query builder for querying the database.
|
||||
*
|
||||
* @return a {@link WorkbasketAccessItemQuery}
|
||||
* @throws NotAuthorizedException
|
||||
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
|
||||
*/
|
||||
WorkbasketAccessItemQuery createWorkbasketAccessItemQuery();
|
||||
WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException;
|
||||
|
||||
/**
|
||||
* Returns a new workbasket which is not persisted.
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ClassificationQueryImpl implements ClassificationQuery {
|
|||
private static final String LINK_TO_MAPPER = "pro.taskana.mappings.QueryMapper.queryClassification";
|
||||
private static final String LINK_TO_COUNTER = "pro.taskana.mappings.QueryMapper.countQueryClassifications";
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationQueryImpl.class);
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
private TaskanaEngineImpl taskanaEngine;
|
||||
private String[] key;
|
||||
private String[] parentId;
|
||||
private String[] category;
|
||||
|
@ -61,7 +61,7 @@ public class ClassificationQueryImpl implements ClassificationQuery {
|
|||
private List<String> orderBy;
|
||||
|
||||
ClassificationQueryImpl(TaskanaEngine taskanaEngine) {
|
||||
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.orderBy = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
@ -341,11 +341,11 @@ public class ClassificationQueryImpl implements ClassificationQuery {
|
|||
LOGGER.debug("entry to list(), this = {}", this);
|
||||
List<ClassificationSummary> result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
result = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this);
|
||||
taskanaEngine.openConnection();
|
||||
result = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this);
|
||||
return result;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||
LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects,
|
||||
|
@ -359,9 +359,9 @@ public class ClassificationQueryImpl implements ClassificationQuery {
|
|||
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
|
||||
List<ClassificationSummary> result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
RowBounds rowBounds = new RowBounds(offset, limit);
|
||||
result = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
result = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
if (e instanceof PersistenceException) {
|
||||
|
@ -374,7 +374,7 @@ public class ClassificationQueryImpl implements ClassificationQuery {
|
|||
}
|
||||
throw e;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects,
|
||||
|
@ -388,11 +388,11 @@ public class ClassificationQueryImpl implements ClassificationQuery {
|
|||
LOGGER.debug("entry to single(), this = {}", this);
|
||||
ClassificationSummary result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
result = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||
taskanaEngine.openConnection();
|
||||
result = taskanaEngine.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||
return result;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from single(). Returning result {} ", result);
|
||||
}
|
||||
}
|
||||
|
@ -535,11 +535,11 @@ public class ClassificationQueryImpl implements ClassificationQuery {
|
|||
LOGGER.debug("entry to count(), this = {}", this);
|
||||
Long rowCount = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
rowCount = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_COUNTER, this);
|
||||
taskanaEngine.openConnection();
|
||||
rowCount = taskanaEngine.getSqlSession().selectOne(LINK_TO_COUNTER, this);
|
||||
return (rowCount == null) ? 0L : rowCount;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from count(). Returning result {} ", rowCount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,24 +32,25 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationServiceImpl.class);
|
||||
private ClassificationMapper classificationMapper;
|
||||
private TaskMapper taskMapper;
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
private TaskanaEngineImpl taskanaEngine;
|
||||
|
||||
ClassificationServiceImpl(TaskanaEngine taskanaEngine, ClassificationMapper classificationMapper,
|
||||
TaskMapper taskMapper) {
|
||||
super();
|
||||
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.classificationMapper = classificationMapper;
|
||||
this.taskMapper = taskMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Classification createClassification(Classification classification)
|
||||
throws ClassificationAlreadyExistException {
|
||||
throws ClassificationAlreadyExistException, NotAuthorizedException {
|
||||
LOGGER.debug("entry to createClassification(classification = {})", classification);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
ClassificationImpl classificationImpl;
|
||||
final boolean isClassificationExisting;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
isClassificationExisting = doesClassificationExist(classification.getKey(), classification.getDomain());
|
||||
|
||||
if (isClassificationExisting) {
|
||||
|
@ -63,7 +64,7 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
|
||||
addClassificationToRootDomain(classificationImpl);
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from createClassification()");
|
||||
}
|
||||
return classificationImpl;
|
||||
|
@ -104,9 +105,10 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
@Override
|
||||
public Classification updateClassification(Classification classification) throws NotAuthorizedException {
|
||||
LOGGER.debug("entry to updateClassification(Classification = {})", classification);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
ClassificationImpl classificationImpl = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
classificationImpl = (ClassificationImpl) classification;
|
||||
this.initDefaultClassificationValues(classificationImpl);
|
||||
|
||||
|
@ -116,7 +118,7 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
classificationImpl.getDomain());
|
||||
// Update classification fields used by tasks
|
||||
if (oldClassification.getCategory() != classificationImpl.getCategory()) {
|
||||
List<TaskSummary> taskSumamries = taskanaEngineImpl.getTaskService()
|
||||
List<TaskSummary> taskSumamries = taskanaEngine.getTaskService()
|
||||
.createTaskQuery()
|
||||
.classificationKeyIn(oldClassification.getKey())
|
||||
.classificationCategoryIn(oldClassification.getCategory())
|
||||
|
@ -150,7 +152,7 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
throw new SystemException("updateClassification didn't find new classification after update");
|
||||
}
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from updateClassification().");
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +205,7 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
LOGGER.debug("entry to getClassification(id = {})", id);
|
||||
Classification result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
result = classificationMapper.findById(id);
|
||||
if (result == null) {
|
||||
LOGGER.error("Classification for id {} was not found. Throwing ClassificationNotFoundException", id);
|
||||
|
@ -211,13 +213,14 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
}
|
||||
return result;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from getClassification(). Returning result {} ", result);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Classification getClassification(String key, String domain) throws ClassificationNotFoundException {
|
||||
LOGGER.debug("entry to getClassification(key = {}, domain = {})", key, domain);
|
||||
if (key == null) {
|
||||
throw new ClassificationNotFoundException(
|
||||
"Classification for key " + key + " and domain " + domain + " was not found.");
|
||||
|
@ -225,7 +228,7 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
LOGGER.debug("entry to getClassification(key = {}, domain = {})", key, domain);
|
||||
Classification result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
result = classificationMapper.findByKeyAndDomain(key, domain);
|
||||
if (result == null) {
|
||||
result = classificationMapper.findByKeyAndDomain(key, "");
|
||||
|
@ -238,14 +241,14 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
}
|
||||
return result;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from getClassification(). Returning result {} ", result);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassificationQuery createClassificationQuery() {
|
||||
return new ClassificationQueryImpl(taskanaEngineImpl);
|
||||
return new ClassificationQueryImpl(taskanaEngine);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -273,9 +276,11 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
|
||||
@Override
|
||||
public void deleteClassification(String classificationKey, String domain)
|
||||
throws ClassificationInUseException, ClassificationNotFoundException {
|
||||
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException {
|
||||
LOGGER.debug("entry to deleteClassification(key = {}, domain = {})", classificationKey, domain);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
Classification classification = this.classificationMapper.findByKeyAndDomain(classificationKey, domain);
|
||||
if (classification == null) {
|
||||
throw new ClassificationNotFoundException(
|
||||
|
@ -291,7 +296,7 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
}
|
||||
}
|
||||
|
||||
TaskServiceImpl taskService = (TaskServiceImpl) taskanaEngineImpl.getTaskService();
|
||||
TaskServiceImpl taskService = (TaskServiceImpl) taskanaEngine.getTaskService();
|
||||
try {
|
||||
List<TaskSummary> classificationTasks = taskService.createTaskQuery()
|
||||
.classificationKeyIn(classificationKey)
|
||||
|
@ -315,7 +320,8 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
|
||||
this.classificationMapper.deleteClassificationInDomain(classificationKey, domain);
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from deleteClassification()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
|
|||
private static final String LINK_TO_COUNTER = "pro.taskana.mappings.QueryMapper.countQueryObjectReferences";
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ObjectReferenceQueryImpl.class);
|
||||
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
private TaskanaEngineImpl taskanaEngine;
|
||||
private String[] company;
|
||||
private String[] system;
|
||||
private String[] systemInstance;
|
||||
|
@ -32,7 +32,7 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
|
|||
private String[] value;
|
||||
|
||||
ObjectReferenceQueryImpl(TaskanaEngine taskanaEngine) {
|
||||
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,11 +70,11 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
|
|||
LOGGER.debug("entry to list(), this = {}", this);
|
||||
List<ObjectReference> result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
result = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this);
|
||||
taskanaEngine.openConnection();
|
||||
result = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this);
|
||||
return result;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||
LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects,
|
||||
|
@ -88,9 +88,9 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
|
|||
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
|
||||
List<ObjectReference> result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
RowBounds rowBounds = new RowBounds(offset, limit);
|
||||
result = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
result = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
if (e instanceof PersistenceException) {
|
||||
|
@ -103,7 +103,7 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
|
|||
}
|
||||
throw e;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects,
|
||||
|
@ -117,11 +117,11 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
|
|||
LOGGER.debug("entry to single(), this = {}", this);
|
||||
ObjectReference result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
result = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||
taskanaEngine.openConnection();
|
||||
result = taskanaEngine.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||
return result;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from single(). Returning result {} ", result);
|
||||
}
|
||||
}
|
||||
|
@ -171,11 +171,11 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
|
|||
LOGGER.debug("entry to count(), this = {}", this);
|
||||
Long rowCount = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
rowCount = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_COUNTER, this);
|
||||
taskanaEngine.openConnection();
|
||||
rowCount = taskanaEngine.getSqlSession().selectOne(LINK_TO_COUNTER, this);
|
||||
return (rowCount == null) ? 0L : rowCount;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from count(). Returning result {} ", rowCount);
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ public class ObjectReferenceQueryImpl implements ObjectReferenceQuery {
|
|||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ObjectReferenceQueryImpl [taskanaEngineImpl=");
|
||||
builder.append(taskanaEngineImpl);
|
||||
builder.append(taskanaEngine);
|
||||
builder.append(", company=");
|
||||
builder.append(Arrays.toString(company));
|
||||
builder.append(", system=");
|
||||
|
|
|
@ -28,7 +28,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
private static final String LINK_TO_MAPPER = "pro.taskana.mappings.QueryMapper.queryTasks";
|
||||
private static final String LINK_TO_COUNTER = "pro.taskana.mappings.QueryMapper.countQueryTasks";
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskQueryImpl.class);
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
private TaskanaEngineImpl taskanaEngine;
|
||||
private TaskServiceImpl taskService;
|
||||
private String[] nameIn;
|
||||
private String[] nameLike;
|
||||
|
@ -93,8 +93,8 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
private List<String> orderBy;
|
||||
|
||||
TaskQueryImpl(TaskanaEngine taskanaEngine) {
|
||||
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.taskService = (TaskServiceImpl) taskanaEngineImpl.getTaskService();
|
||||
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.taskService = (TaskServiceImpl) taskanaEngine.getTaskService();
|
||||
this.orderBy = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
@ -655,7 +655,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
|
||||
@Override
|
||||
public ObjectReferenceQuery createObjectReferenceQuery() {
|
||||
return new ObjectReferenceQueryImpl(taskanaEngineImpl);
|
||||
return new ObjectReferenceQueryImpl(taskanaEngine);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -663,16 +663,16 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
List<TaskSummary> result = new ArrayList<>();
|
||||
try {
|
||||
LOGGER.debug("entry to list(), this = {}", this);
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
checkOpenPermissionForSpecifiedWorkbaskets();
|
||||
List<TaskSummaryImpl> tasks = new ArrayList<>();
|
||||
tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this);
|
||||
tasks = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this);
|
||||
result = taskService.augmentTaskSummariesByContainedSummaries(tasks);
|
||||
return result;
|
||||
} catch (NotAuthorizedException e) {
|
||||
throw new NotAuthorizedToQueryWorkbasketException(e.getMessage());
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||
LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects,
|
||||
|
@ -686,10 +686,10 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
|
||||
List<TaskSummary> result = new ArrayList<>();
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
checkOpenPermissionForSpecifiedWorkbaskets();
|
||||
RowBounds rowBounds = new RowBounds(offset, limit);
|
||||
List<TaskSummaryImpl> tasks = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
List<TaskSummaryImpl> tasks = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
result = taskService.augmentTaskSummariesByContainedSummaries(tasks);
|
||||
return result;
|
||||
} catch (PersistenceException e) {
|
||||
|
@ -703,7 +703,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
} catch (NotAuthorizedException e) {
|
||||
throw new NotAuthorizedToQueryWorkbasketException(e.getMessage());
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects,
|
||||
|
@ -717,9 +717,9 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
LOGGER.debug("entry to single(), this = {}", this);
|
||||
TaskSummary result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
checkOpenPermissionForSpecifiedWorkbaskets();
|
||||
TaskSummaryImpl taskSummaryImpl = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||
TaskSummaryImpl taskSummaryImpl = taskanaEngine.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||
if (taskSummaryImpl == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -732,7 +732,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
} catch (NotAuthorizedException e) {
|
||||
throw new NotAuthorizedToQueryWorkbasketException(e.getMessage());
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from single(). Returning result {} ", result);
|
||||
}
|
||||
}
|
||||
|
@ -742,27 +742,31 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
LOGGER.debug("entry to count(), this = {}", this);
|
||||
Long rowCount = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
checkOpenPermissionForSpecifiedWorkbaskets();
|
||||
rowCount = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_COUNTER, this);
|
||||
rowCount = taskanaEngine.getSqlSession().selectOne(LINK_TO_COUNTER, this);
|
||||
return (rowCount == null) ? 0L : rowCount;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from count(). Returning result {} ", rowCount);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkOpenPermissionForSpecifiedWorkbaskets() {
|
||||
if (taskanaEngine.isUserInRole(TaskanaRole.ADMIN)) {
|
||||
LOGGER.debug("Skipping permissions check since user is in role ADMIN.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (this.workbasketIdIn != null && this.workbasketIdIn.length > 0) {
|
||||
for (String workbasketId : workbasketIdIn) {
|
||||
taskanaEngineImpl.getWorkbasketService().checkAuthorization(workbasketId,
|
||||
taskanaEngine.getWorkbasketService().checkAuthorization(workbasketId,
|
||||
WorkbasketAuthorization.OPEN);
|
||||
}
|
||||
}
|
||||
if (workbasketKeyDomainIn != null && workbasketKeyDomainIn.length > 0) {
|
||||
for (KeyDomain keyDomain : workbasketKeyDomainIn) {
|
||||
taskanaEngineImpl.getWorkbasketService().checkAuthorization(keyDomain.getKey(),
|
||||
taskanaEngine.getWorkbasketService().checkAuthorization(keyDomain.getKey(),
|
||||
keyDomain.getDomain(), WorkbasketAuthorization.OPEN);
|
||||
}
|
||||
}
|
||||
|
@ -772,7 +776,7 @@ public class TaskQueryImpl implements TaskQuery {
|
|||
}
|
||||
|
||||
public TaskanaEngineImpl getTaskanaEngine() {
|
||||
return taskanaEngineImpl;
|
||||
return taskanaEngine;
|
||||
}
|
||||
|
||||
public String[] getTaskIds() {
|
||||
|
|
|
@ -54,8 +54,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
private static final String ID_PREFIX_TASK = "TKI";
|
||||
private static final String ID_PREFIX_BUSINESS_PROCESS = "BPI";
|
||||
private static final String MUST_NOT_BE_EMPTY = " must not be empty";
|
||||
private TaskanaEngine taskanaEngine;
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
private TaskanaEngineImpl taskanaEngine;
|
||||
private WorkbasketService workbasketService;
|
||||
private ClassificationServiceImpl classificationService;
|
||||
private TaskMapper taskMapper;
|
||||
|
@ -64,12 +63,11 @@ public class TaskServiceImpl implements TaskService {
|
|||
TaskServiceImpl(TaskanaEngine taskanaEngine, TaskMapper taskMapper,
|
||||
AttachmentMapper attachmentMapper) {
|
||||
super();
|
||||
this.taskanaEngine = taskanaEngine;
|
||||
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.taskMapper = taskMapper;
|
||||
this.workbasketService = taskanaEngineImpl.getWorkbasketService();
|
||||
this.workbasketService = taskanaEngine.getWorkbasketService();
|
||||
this.attachmentMapper = attachmentMapper;
|
||||
this.classificationService = (ClassificationServiceImpl) taskanaEngineImpl.getClassificationService();
|
||||
this.classificationService = (ClassificationServiceImpl) taskanaEngine.getClassificationService();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,7 +83,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
LOGGER.debug("entry to claim(id = {}, forceClaim = {}, userId = {})", taskId, forceClaim, userId);
|
||||
TaskImpl task = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
task = (TaskImpl) getTask(taskId);
|
||||
TaskState state = task.getState();
|
||||
if (state == TaskState.COMPLETED) {
|
||||
|
@ -109,7 +107,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
taskMapper.update(task);
|
||||
LOGGER.debug("Method claim() claimed task '{}' for user '{}'.", taskId, userId);
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from claim()");
|
||||
}
|
||||
return task;
|
||||
|
@ -128,7 +126,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
forceUnclaim);
|
||||
TaskImpl task = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
task = (TaskImpl) getTask(taskId);
|
||||
TaskState state = task.getState();
|
||||
if (state == TaskState.COMPLETED) {
|
||||
|
@ -152,7 +150,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
taskMapper.update(task);
|
||||
LOGGER.debug("Method cancelClaim() unclaimed task '{}' for user '{}'.", taskId, userId);
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from cancelClaim(taskId = {}) with userId = {}, forceFlag = {}", taskId, userId,
|
||||
forceUnclaim);
|
||||
}
|
||||
|
@ -171,7 +169,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
LOGGER.debug("entry to completeTask(id = {}, isForced {})", taskId, isForced);
|
||||
TaskImpl task = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
task = (TaskImpl) this.getTask(taskId);
|
||||
|
||||
// check pre-conditions for non-forced invocation
|
||||
|
@ -201,7 +199,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
taskMapper.update(task);
|
||||
LOGGER.debug("Method completeTask() completed Task '{}'.", taskId);
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from completeTask()");
|
||||
}
|
||||
return task;
|
||||
|
@ -212,7 +210,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
throws InvalidArgumentException {
|
||||
try {
|
||||
LOGGER.debug("entry to completeTasks(taskIds = {})", taskIds);
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
|
||||
// Check pre-conditions with throwing Exceptions
|
||||
if (taskIds == null) {
|
||||
|
@ -268,7 +266,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
return bulkLog;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from to completeTasks(taskIds = {})", taskIds);
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +277,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException {
|
||||
LOGGER.debug("entry to createTask(task = {})", taskToCreate);
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
TaskImpl task = (TaskImpl) taskToCreate;
|
||||
if (task.getId() != "" && task.getId() != null) {
|
||||
throw new TaskAlreadyExistException(taskToCreate.getId());
|
||||
|
@ -314,7 +312,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
return task;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from createTask(task = {})");
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +322,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
LOGGER.debug("entry to getTaskById(id = {})", id);
|
||||
TaskImpl resultTask = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
|
||||
resultTask = taskMapper.findById(id);
|
||||
if (resultTask != null) {
|
||||
|
@ -356,7 +354,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
throw new TaskNotFoundException(id);
|
||||
}
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from getTaskById(). Returning result {} ", resultTask);
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +365,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
LOGGER.debug("entry to transfer(taskId = {}, destinationWorkbasketId = {})", taskId, destinationWorkbasketId);
|
||||
TaskImpl task = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
task = (TaskImpl) getTask(taskId);
|
||||
|
||||
// transfer requires TRANSFER in source and APPEND on destination workbasket
|
||||
|
@ -391,7 +389,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
destinationWorkbasketId);
|
||||
return task;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from transfer(). Returning result {} ", task);
|
||||
}
|
||||
}
|
||||
|
@ -403,7 +401,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
destinationWorkbasketKey, domain);
|
||||
TaskImpl task = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
task = (TaskImpl) getTask(taskId);
|
||||
|
||||
// transfer requires TRANSFER in source and APPEND on destination workbasket
|
||||
|
@ -427,7 +425,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
destinationWorkbasket.getId());
|
||||
return task;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from transfer(). Returning result {} ", task);
|
||||
}
|
||||
}
|
||||
|
@ -436,7 +434,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
public BulkOperationResults<String, TaskanaException> transferTasks(String destinationWorkbasketId,
|
||||
List<String> taskIds) throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
LOGGER.debug("entry to transferBulk(targetWbId = {}, taskIds = {})", destinationWorkbasketId, taskIds);
|
||||
// Check pre-conditions with trowing Exceptions
|
||||
if (destinationWorkbasketId == null || taskIds == null) {
|
||||
|
@ -448,7 +446,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
return transferTasks(taskIds, destinationWorkbasket);
|
||||
} finally {
|
||||
LOGGER.debug("exit from transferBulk(targetWbKey = {}, taskIds = {})", destinationWorkbasketId, taskIds);
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,7 +455,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
String destinationWorkbasketDomain, List<String> taskIds)
|
||||
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
LOGGER.debug("entry to transferBulk(targetWbKey = {}, domain = {}, taskIds = {})", destinationWorkbasketKey,
|
||||
destinationWorkbasketDomain, taskIds);
|
||||
// Check pre-conditions with trowing Exceptions
|
||||
|
@ -472,7 +470,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
} finally {
|
||||
LOGGER.debug("exit from transferBulk(targetWbKey = {}, taskIds = {})", destinationWorkbasketKey,
|
||||
destinationWorkbasketDomain, taskIds);
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -545,7 +543,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
LOGGER.debug("entry to setTaskRead(taskId = {}, isRead = {})", taskId, isRead);
|
||||
Task result = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
TaskImpl task = (TaskImpl) getTask(taskId);
|
||||
task.setRead(true);
|
||||
task.setModified(Instant.now());
|
||||
|
@ -554,7 +552,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
LOGGER.debug("Method setTaskRead() set read property of Task '{}' to {} ", result, isRead);
|
||||
return result;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from setTaskRead(taskId, isRead). Returning result {} ", result);
|
||||
}
|
||||
}
|
||||
|
@ -574,7 +572,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
TaskImpl newTaskImpl = (TaskImpl) task;
|
||||
TaskImpl oldTaskImpl = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
oldTaskImpl = (TaskImpl) getTask(newTaskImpl.getId());
|
||||
standardUpdateActions(oldTaskImpl, newTaskImpl);
|
||||
handleAttachmentsOnTaskUpdate(oldTaskImpl, newTaskImpl);
|
||||
|
@ -584,7 +582,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
LOGGER.debug("Method updateTask() updated task '{}' for user '{}'.", task.getId(), userId);
|
||||
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from claim()");
|
||||
}
|
||||
return task;
|
||||
|
@ -914,16 +912,18 @@ public class TaskServiceImpl implements TaskService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException {
|
||||
public void deleteTask(String taskId) throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
||||
deleteTask(taskId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTask(String taskId, boolean forceDelete) throws TaskNotFoundException, InvalidStateException {
|
||||
public void deleteTask(String taskId, boolean forceDelete)
|
||||
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
||||
LOGGER.debug("entry to deleteTask(taskId = {} , forceDelete = {} )", taskId, forceDelete);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.ADMIN);
|
||||
TaskImpl task = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
task = (TaskImpl) getTask(taskId);
|
||||
|
||||
// reset read flag and set transferred flag
|
||||
|
@ -936,7 +936,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
taskMapper.delete(taskId);
|
||||
LOGGER.debug("Method deleteTask() deleted Task {}", taskId);
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from deleteTask(). ");
|
||||
}
|
||||
}
|
||||
|
@ -948,7 +948,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
LOGGER.debug("entry to deleteTasks(tasks = {})", LoggerUtils.listToString(taskIds));
|
||||
}
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
if (taskIds == null) {
|
||||
throw new InvalidArgumentException("TaskIds can´t be NULL as parameter for deleteTasks().");
|
||||
}
|
||||
|
@ -985,7 +985,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
return bulkLog;
|
||||
} finally {
|
||||
LOGGER.debug("exit from deleteTasks()");
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import pro.taskana.WorkbasketService;
|
|||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.AutocommitFailedException;
|
||||
import pro.taskana.exceptions.ConnectionNotSetException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.SystemException;
|
||||
import pro.taskana.exceptions.UnsupportedDatabaseException;
|
||||
import pro.taskana.impl.persistence.MapTypeHandler;
|
||||
|
@ -51,6 +52,7 @@ import pro.taskana.mappings.TaskMapper;
|
|||
import pro.taskana.mappings.TaskMonitorMapper;
|
||||
import pro.taskana.mappings.WorkbasketAccessMapper;
|
||||
import pro.taskana.mappings.WorkbasketMapper;
|
||||
import pro.taskana.security.CurrentUserContext;
|
||||
|
||||
/**
|
||||
* This is the implementation of TaskanaEngine.
|
||||
|
@ -230,6 +232,47 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
return this.sessionManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether current user is member of any of the specified roles.
|
||||
*
|
||||
* @param roles
|
||||
* The roles that are checked for membership of the current user
|
||||
* @throws NotAuthorizedException
|
||||
* If the current user is not member of any specified role
|
||||
*/
|
||||
void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException {
|
||||
if (isUserInRole(roles)) {
|
||||
return;
|
||||
} else {
|
||||
throw new NotAuthorizedException("current user is not member of role(s) " + Arrays.toString(roles));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether the current user is member of one of the roles specified.
|
||||
*
|
||||
* @param roles
|
||||
* The roles that are checked for membership of the current user
|
||||
* @return true if the current user is a member of at least one of the specified groups
|
||||
*/
|
||||
boolean isUserInRole(TaskanaRole... roles) {
|
||||
if (!getConfiguration().isSecurityEnabled()) {
|
||||
return true;
|
||||
} else {
|
||||
List<String> accessIds = CurrentUserContext.getAccessIds();
|
||||
Set<String> rolesMembers = new HashSet<>();
|
||||
for (TaskanaRole role : roles) {
|
||||
rolesMembers.addAll(roleMap.get(role));
|
||||
}
|
||||
for (String accessId : accessIds) {
|
||||
if (rolesMembers.contains(accessId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates the sqlSessionManager of myBatis. It integrates all the SQL mappers and sets the databaseId
|
||||
* attribute.
|
||||
|
@ -332,7 +375,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
String token = st.nextToken().toLowerCase().trim();
|
||||
roleMemberSet.add(token);
|
||||
}
|
||||
TaskanaRole key = TaskanaRole.fromProperyName(propertyName);
|
||||
TaskanaRole key = TaskanaRole.fromPropertyName(propertyName);
|
||||
if (key != null) {
|
||||
roleMap.put(key, roleMemberSet);
|
||||
} else {
|
||||
|
|
|
@ -14,7 +14,7 @@ public enum TaskanaRole {
|
|||
this.propertyName = propertyName;
|
||||
}
|
||||
|
||||
public static TaskanaRole fromProperyName(String name) {
|
||||
public static TaskanaRole fromPropertyName(String name) {
|
||||
if (USER.propertyName.equalsIgnoreCase(name)) {
|
||||
return TaskanaRole.USER;
|
||||
} else if (BUSINESS_ADMIN.propertyName.equalsIgnoreCase(name)) {
|
||||
|
|
|
@ -29,11 +29,11 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
|
|||
private String[] workbasketIdIn;
|
||||
private String[] idIn;
|
||||
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
private TaskanaEngineImpl taskanaEngine;
|
||||
private List<String> orderBy;
|
||||
|
||||
WorkbasketAccessItemQueryImpl(TaskanaEngine taskanaEngine) {
|
||||
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
|
||||
orderBy = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
@ -76,13 +76,13 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
|
|||
LOGGER.debug("entry to list(), this = {}", this);
|
||||
List<WorkbasketAccessItem> result = new ArrayList<>();
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
List<WorkbasketAccessItemImpl> foundAccessItms = taskanaEngineImpl.getSqlSession()
|
||||
taskanaEngine.openConnection();
|
||||
List<WorkbasketAccessItemImpl> foundAccessItms = taskanaEngine.getSqlSession()
|
||||
.selectList(LINK_TO_MAPPER, this);
|
||||
result.addAll(foundAccessItms);
|
||||
return result;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||
LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects,
|
||||
|
@ -96,9 +96,9 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
|
|||
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
|
||||
List<WorkbasketAccessItem> result = new ArrayList<>();
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
RowBounds rowBounds = new RowBounds(offset, limit);
|
||||
List<WorkbasketAccessItemImpl> foundAccessItms = taskanaEngineImpl.getSqlSession()
|
||||
List<WorkbasketAccessItemImpl> foundAccessItms = taskanaEngine.getSqlSession()
|
||||
.selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
result.addAll(foundAccessItms);
|
||||
return result;
|
||||
|
@ -111,7 +111,7 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
|
|||
}
|
||||
throw e;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = result == null ? 0 : result.size();
|
||||
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects,
|
||||
|
@ -125,11 +125,11 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
|
|||
LOGGER.debug("entry to single(), this = {}", this);
|
||||
WorkbasketAccessItem accessItm = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
accessItm = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||
taskanaEngine.openConnection();
|
||||
accessItm = taskanaEngine.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||
return accessItm;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from single(). Returning result {} ", accessItm);
|
||||
}
|
||||
}
|
||||
|
@ -139,11 +139,11 @@ public class WorkbasketAccessItemQueryImpl implements WorkbasketAccessItemQuery
|
|||
LOGGER.debug("entry to count(), this = {}", this);
|
||||
Long rowCount = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
rowCount = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_COUNTER, this);
|
||||
taskanaEngine.openConnection();
|
||||
rowCount = taskanaEngine.getSqlSession().selectOne(LINK_TO_COUNTER, this);
|
||||
return (rowCount == null) ? 0L : rowCount;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from count(). Returning result {} ", rowCount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import pro.taskana.WorkbasketQuery;
|
|||
import pro.taskana.WorkbasketSummary;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskanaRuntimeException;
|
||||
import pro.taskana.impl.util.LoggerUtils;
|
||||
import pro.taskana.security.CurrentUserContext;
|
||||
|
@ -60,11 +61,11 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
private String[] orgLevel3Like;
|
||||
private String[] orgLevel4In;
|
||||
private String[] orgLevel4Like;
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
private TaskanaEngineImpl taskanaEngine;
|
||||
private List<String> orderBy;
|
||||
|
||||
WorkbasketQueryImpl(TaskanaEngine taskanaEngine) {
|
||||
this.taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
|
||||
this.orderBy = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
@ -324,7 +325,8 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
|
||||
@Override
|
||||
public WorkbasketQuery accessIdsHavePermission(WorkbasketAuthorization permission, String... accessIds)
|
||||
throws InvalidArgumentException {
|
||||
throws InvalidArgumentException, NotAuthorizedException {
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN);
|
||||
// Checking pre-conditions
|
||||
if (permission == null) {
|
||||
throw new InvalidArgumentException("Permission can´t be null.");
|
||||
|
@ -352,12 +354,12 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
LOGGER.debug("entry to list(), this = {}", this);
|
||||
List<WorkbasketSummary> workbaskets = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
addAccessIdsOfCallerToQuery();
|
||||
workbaskets = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this);
|
||||
workbaskets = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this);
|
||||
return workbaskets;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = workbaskets == null ? 0 : workbaskets.size();
|
||||
LOGGER.debug("exit from list(). Returning {} resulting Objects: {} ", numberOfResultObjects,
|
||||
|
@ -371,10 +373,10 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
LOGGER.debug("entry to list(offset = {}, limit = {}), this = {}", offset, limit, this);
|
||||
List<WorkbasketSummary> workbaskets = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
RowBounds rowBounds = new RowBounds(offset, limit);
|
||||
addAccessIdsOfCallerToQuery();
|
||||
workbaskets = taskanaEngineImpl.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
workbaskets = taskanaEngine.getSqlSession().selectList(LINK_TO_MAPPER, this, rowBounds);
|
||||
return workbaskets;
|
||||
} catch (Exception e) {
|
||||
if (e instanceof PersistenceException) {
|
||||
|
@ -387,7 +389,7 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
}
|
||||
throw e;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
int numberOfResultObjects = workbaskets == null ? 0 : workbaskets.size();
|
||||
LOGGER.debug("exit from list(offset,limit). Returning {} resulting Objects: {} ", numberOfResultObjects,
|
||||
|
@ -401,12 +403,12 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
LOGGER.debug("entry to single(), this = {}", this);
|
||||
WorkbasketSummary workbasket = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
addAccessIdsOfCallerToQuery();
|
||||
workbasket = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||
workbasket = taskanaEngine.getSqlSession().selectOne(LINK_TO_MAPPER, this);
|
||||
return workbasket;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from single(). Returning result {} ", workbasket);
|
||||
}
|
||||
}
|
||||
|
@ -544,12 +546,12 @@ public class WorkbasketQueryImpl implements WorkbasketQuery {
|
|||
LOGGER.debug("entry to count(), this = {}", this);
|
||||
Long rowCount = null;
|
||||
try {
|
||||
taskanaEngineImpl.openConnection();
|
||||
taskanaEngine.openConnection();
|
||||
addAccessIdsOfCallerToQuery();
|
||||
rowCount = taskanaEngineImpl.getSqlSession().selectOne(LINK_TO_COUNTER, this);
|
||||
rowCount = taskanaEngine.getSqlSession().selectOne(LINK_TO_COUNTER, this);
|
||||
return (rowCount == null) ? 0L : rowCount;
|
||||
} finally {
|
||||
taskanaEngineImpl.returnConnection();
|
||||
taskanaEngine.returnConnection();
|
||||
LOGGER.debug("exit from count(). Returning result {} ", rowCount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,8 +126,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
|
||||
@Override
|
||||
public Workbasket createWorkbasket(Workbasket newWorkbasket)
|
||||
throws InvalidWorkbasketException {
|
||||
throws InvalidWorkbasketException, NotAuthorizedException {
|
||||
LOGGER.debug("entry to createtWorkbasket(workbasket)", newWorkbasket);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
Workbasket result = null;
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) newWorkbasket;
|
||||
try {
|
||||
|
@ -154,6 +155,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
public Workbasket updateWorkbasket(Workbasket workbasketToUpdate)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
|
||||
LOGGER.debug("entry to updateWorkbasket(workbasket)", workbasketToUpdate);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
|
||||
Workbasket result = null;
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketToUpdate;
|
||||
|
@ -180,8 +182,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
|
||||
@Override
|
||||
public WorkbasketAccessItem createWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem)
|
||||
throws InvalidArgumentException {
|
||||
throws InvalidArgumentException, NotAuthorizedException {
|
||||
LOGGER.debug("entry to createWorkbasketAuthorization(workbasketAccessItem = {})", workbasketAccessItem);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
|
@ -243,8 +246,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteWorkbasketAuthorization(String accessItemId) {
|
||||
public void deleteWorkbasketAuthorization(String accessItemId) throws NotAuthorizedException {
|
||||
LOGGER.debug("entry to deleteWorkbasketAuthorization(id = {})", accessItemId);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
workbasketAccessMapper.delete(accessItemId);
|
||||
|
@ -282,8 +286,9 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
|
||||
@Override
|
||||
public WorkbasketAccessItem updateWorkbasketAuthorization(WorkbasketAccessItem workbasketAccessItem)
|
||||
throws InvalidArgumentException {
|
||||
throws InvalidArgumentException, NotAuthorizedException {
|
||||
LOGGER.debug("entry to updateWorkbasketAuthorization(workbasketAccessItem = {}", workbasketAccessItem);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
|
@ -526,6 +531,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
sourceWorkbasketId,
|
||||
LoggerUtils.listToString(targetWorkbasketIds));
|
||||
}
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
// check existence of source workbasket
|
||||
|
@ -561,6 +567,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
LOGGER.debug("entry to addDistributionTarget(sourceWorkbasketId = {}, targetWorkbasketId = {})",
|
||||
sourceWorkbasketId, targetWorkbasketId);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
// check existence of source workbasket
|
||||
|
@ -594,6 +601,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
throws NotAuthorizedException {
|
||||
LOGGER.debug("entry to removeDistributionTarget(sourceWorkbasketId = {}, targetWorkbasketId = {})",
|
||||
sourceWorkbasketId, targetWorkbasketId);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
// don't check existence of source / target workbasket to enable cleanup even if the db is corrupted
|
||||
|
@ -630,6 +638,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
public void deleteWorkbasket(String workbasketId)
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException, InvalidArgumentException {
|
||||
LOGGER.debug("entry to deleteWorkbasket(workbasketId = {})", workbasketId);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
if (workbasketId == null || workbasketId.isEmpty()) {
|
||||
|
@ -659,7 +668,8 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() {
|
||||
public WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException {
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.ADMIN, TaskanaRole.BUSINESS_ADMIN);
|
||||
return new WorkbasketAccessItemQueryImpl(this.taskanaEngine);
|
||||
}
|
||||
|
||||
|
@ -671,6 +681,11 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
if (workbasketAuthorization == null) {
|
||||
throw new SystemException("checkAuthorization was called with an invalid parameter combination");
|
||||
}
|
||||
if (taskanaEngine.isUserInRole(TaskanaRole.ADMIN)) {
|
||||
LOGGER.debug("Skipping permissions check since user is in role ADMIN.");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isAuthorized = false;
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
|
|
|
@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
@ -34,6 +35,9 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
|
|||
classificationService = taskanaEngine.getClassificationService();
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testDeleteClassificationInDomain()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
|
||||
|
@ -47,6 +51,16 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
|
|||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1", "group_2"})
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testDeleteClassificationInDomainUserIsNotAuthorized()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
|
||||
classificationService.deleteClassification("L140101", "DOMAIN_A");
|
||||
fail("NotAuthorizedException should have been thrown");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1", "businessadmin"})
|
||||
@Test(expected = ClassificationInUseException.class)
|
||||
public void testThrowExeptionIfDeleteClassificationWithExistingTasks()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
|
||||
|
@ -55,13 +69,16 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1", "group_2"})
|
||||
groupNames = {"group_1", "businessadmin"})
|
||||
@Test(expected = ClassificationInUseException.class)
|
||||
public void testThrowExeptionIfDeleteMasterClassificationWithExistingTasks()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
|
||||
classificationService.deleteClassification("L1050", "");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testDeleteMasterClassification()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
|
||||
|
@ -78,8 +95,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1"})
|
||||
|
||||
groupNames = {"group_1", "businessadmin"})
|
||||
@Test
|
||||
public void testThrowExceptionWhenChildClassificationIsInUseAndRollback()
|
||||
throws ClassificationInUseException, NotAuthorizedException, ClassificationNotFoundException {
|
||||
|
@ -106,15 +122,21 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
|
|||
assertNotEquals(rollbackMaster.getDomain(), rollbackA.getDomain());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test(expected = ClassificationNotFoundException.class)
|
||||
public void testThrowClassificationNotFoundIfClassificationNotExists()
|
||||
throws ClassificationNotFoundException, ClassificationInUseException {
|
||||
throws ClassificationNotFoundException, ClassificationInUseException, NotAuthorizedException {
|
||||
classificationService.deleteClassification("not existing classification key", "");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test(expected = ClassificationNotFoundException.class)
|
||||
public void testThrowClassificationNotFoundIfClassificationNotExistsInDomain()
|
||||
throws ClassificationNotFoundException, ClassificationInUseException {
|
||||
throws ClassificationNotFoundException, ClassificationInUseException, NotAuthorizedException {
|
||||
classificationService.deleteClassification("L10000", "DOMAIN_B");
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
|
|||
super();
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testUpdateClassification()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException {
|
||||
|
@ -67,6 +70,43 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
|
|||
assertThat(updatedClassification.getApplicationEntryPoint(), equalTo(newEntryPoint));
|
||||
}
|
||||
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testUpdateClassificationFails()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException {
|
||||
String newName = "updated Name";
|
||||
String newEntryPoint = "updated EntryPoint";
|
||||
ClassificationService classificationService = taskanaEngine.getClassificationService();
|
||||
Classification classification = classificationService.getClassification("T2100", "DOMAIN_A");
|
||||
|
||||
classification.setApplicationEntryPoint(newEntryPoint);
|
||||
classification.setCategory("PROCESS");
|
||||
classification.setCustom1("newCustom1");
|
||||
classification.setCustom2("newCustom2");
|
||||
classification.setCustom3("newCustom3");
|
||||
classification.setCustom4("newCustom4");
|
||||
classification.setCustom5("newCustom5");
|
||||
classification.setCustom6("newCustom6");
|
||||
classification.setCustom7("newCustom7");
|
||||
classification.setCustom8("newCustom8");
|
||||
classification.setDescription("newDescription");
|
||||
classification.setIsValidInDomain(false);
|
||||
classification.setName(newName);
|
||||
classification.setParentId("T2000");
|
||||
classification.setPriority(1000);
|
||||
classification.setServiceLevel("P2DT3H4M");
|
||||
|
||||
classificationService.updateClassification(classification);
|
||||
|
||||
// Get and check the new value
|
||||
Classification updatedClassification = classificationService.getClassification("T2100", "DOMAIN_A");
|
||||
assertNotNull(updatedClassification);
|
||||
assertThat(updatedClassification.getName(), equalTo(newName));
|
||||
assertThat(updatedClassification.getApplicationEntryPoint(), equalTo(newEntryPoint));
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testUpdateUnpersistedClassification()
|
||||
throws SQLException, ClassificationNotFoundException, NotAuthorizedException {
|
||||
|
@ -111,7 +151,7 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1", "group_2"})
|
||||
groupNames = {"group_1", "businessadmin"})
|
||||
@Test
|
||||
public void testUpdateTaskOnClassificationKeyCategoryChange()
|
||||
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException {
|
||||
|
|
|
@ -39,8 +39,8 @@ public class TaskanaRoleConfigAccTest extends TaskanaEngineImpl {
|
|||
assertTrue(users.contains("user_1_2"));
|
||||
|
||||
Set<String> admins = roleMap.get(TaskanaRole.ADMIN);
|
||||
assertTrue(admins.contains("teamlead_1"));
|
||||
assertTrue(admins.contains("teamlead_2"));
|
||||
assertTrue(admins.contains("name=konrad,organisation=novatec"));
|
||||
assertTrue(admins.contains("admin"));
|
||||
|
||||
Set<String> businessAdmins = roleMap.get(TaskanaRole.BUSINESS_ADMIN);
|
||||
assertTrue(businessAdmins.contains("max"));
|
||||
|
|
|
@ -18,6 +18,7 @@ import pro.taskana.Task;
|
|||
import pro.taskana.TaskService;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidStateException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.TaskNotFoundException;
|
||||
import pro.taskana.exceptions.TaskanaException;
|
||||
import pro.taskana.impl.BulkOperationResults;
|
||||
|
@ -37,8 +38,20 @@ public class DeleteTaskAccTest extends AbstractAccTest {
|
|||
@WithAccessId(
|
||||
userName = "user_1_2",
|
||||
groupNames = {"group_1"})
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testDeleteSingleTaskNotAuthorized()
|
||||
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
taskService.deleteTask("TKI:000000000000000000000000000000000037");
|
||||
fail("NotAuthorizedException should have been thrown");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_2",
|
||||
groupNames = {"group_1", "admin"})
|
||||
@Test(expected = TaskNotFoundException.class)
|
||||
public void testDeleteSingleTask() throws TaskNotFoundException, InvalidStateException {
|
||||
public void testDeleteSingleTask() throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
||||
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000036");
|
||||
|
@ -50,10 +63,10 @@ public class DeleteTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_2",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = {"group_1", "admin"})
|
||||
@Test(expected = InvalidStateException.class)
|
||||
public void testThrowsExceptionIfTaskIsNotCompleted()
|
||||
throws TaskNotFoundException, InvalidStateException, SQLException {
|
||||
throws TaskNotFoundException, InvalidStateException, SQLException, NotAuthorizedException {
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000029");
|
||||
|
||||
|
@ -62,9 +75,10 @@ public class DeleteTaskAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_2",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = {"group_1", "admin"})
|
||||
@Test(expected = TaskNotFoundException.class)
|
||||
public void testForceDeleteTaskIfNotCompleted() throws SQLException, TaskNotFoundException, InvalidStateException {
|
||||
public void testForceDeleteTaskIfNotCompleted()
|
||||
throws SQLException, TaskNotFoundException, InvalidStateException, NotAuthorizedException {
|
||||
TaskService taskService = taskanaEngine.getTaskService();
|
||||
Task task = taskService.getTask("TKI:000000000000000000000000000000000027");
|
||||
try {
|
||||
|
|
|
@ -33,7 +33,7 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_2",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testCreateWorkbasket()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
|
@ -60,6 +60,25 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
|
|||
assertEquals(createdWorkbasket, createdWorkbasket2);
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy")
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testCreateWorkbasketNotAuthorized()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
InvalidWorkbasketException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
|
||||
Workbasket workbasket = workbasketService.newWorkbasket("key3", "novatec");
|
||||
workbasket.setName("Megabasket");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setOrgLevel1("company");
|
||||
workbasketService.createWorkbasket(workbasket);
|
||||
fail("NotAuthorizedException should have been thrown");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testCreateWorkbasketWithMissingRequiredField()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException {
|
||||
|
|
|
@ -38,7 +38,7 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
|
|||
workbasketService = taskanaEngine.getWorkbasketService();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "teamlead_2")
|
||||
@WithAccessId(userName = "teamlead_2", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testDeleteWorkbasket()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
|
||||
|
@ -53,7 +53,18 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
|
|||
}
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "user_1_1", groupNames = {"teamlead_1", "group_1"})
|
||||
@WithAccessId(userName = "elena")
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testDeleteWorkbasketNotAuthorized()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
|
||||
Workbasket wb = workbasketService.getWorkbasket("TEAMLEAD_2", "DOMAIN_A");
|
||||
workbasketService.deleteWorkbasket(wb.getId());
|
||||
|
||||
workbasketService.getWorkbasket("TEAMLEAD_2", "DOMAIN_A");
|
||||
fail("NotAuthorizedException was expected.");
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "user_1_1", groupNames = {"teamlead_1", "group_1", "businessadmin"})
|
||||
@Test
|
||||
public void testDeleteWorkbasketAlsoAsDistributionTarget()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
|
||||
|
@ -76,6 +87,9 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
|
|||
assertTrue(newDistTargets < distTargets);
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testDeleteWorkbasketWithNullOrEmptyParam()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException {
|
||||
|
@ -96,13 +110,17 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
|
|||
}
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void testDeleteWorkbasketButNotExisting()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
|
||||
workbasketService.deleteWorkbasket("SOME NOT EXISTING ID");
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "user_1_1")
|
||||
@WithAccessId(userName = "user_1_1",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test(expected = WorkbasketInUseException.class)
|
||||
public void testDeleteWorkbasketWhichIsUsed()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
|
||||
|
|
|
@ -2,6 +2,7 @@ package acceptance.workbasket;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -84,7 +85,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"teamlead_1", "group_1", "group_2"})
|
||||
groupNames = {"teamlead_1", "group_1", "group_2", "businessadmin"})
|
||||
@Test
|
||||
public void testDistributionTargetCallsWithNonExistingWorkbaskets()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
|
@ -124,7 +125,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
|
|||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_3_1")
|
||||
userName = "user_3_1", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testDistributionTargetCallsFailWithNotAuthorizedException()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException {
|
||||
|
@ -167,7 +168,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_2_2",
|
||||
groupNames = {"group_1", "group_2"})
|
||||
groupNames = {"group_1", "group_2", "businessadmin"})
|
||||
@Test
|
||||
public void testAddAndRemoveDistributionTargets()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
|
||||
|
@ -199,6 +200,24 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
|
|||
@WithAccessId(
|
||||
userName = "user_2_2",
|
||||
groupNames = {"group_1", "group_2"})
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testAddDistributionTargetsFailsNotAuthorized()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
|
||||
|
||||
List<WorkbasketSummary> distributionTargets = workbasketService.getDistributionTargets(workbasket.getId());
|
||||
assertEquals(4, distributionTargets.size());
|
||||
|
||||
// add a new distribution target
|
||||
Workbasket newTarget = workbasketService.getWorkbasket("GPK_B_KSC_2", "DOMAIN_B");
|
||||
workbasketService.addDistributionTarget(workbasket.getId(), newTarget.getId());
|
||||
fail("NotAuthorizedException should have been thrown");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_2_2",
|
||||
groupNames = {"group_1", "group_2", "businessadmin"})
|
||||
@Test
|
||||
public void testSetDistributionTargets()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package acceptance.workbasket;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -17,6 +19,7 @@ import pro.taskana.WorkbasketService;
|
|||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
import pro.taskana.security.WithAccessId;
|
||||
|
||||
/**
|
||||
* Acceptance test for all "query access items for workbaskets" scenarios.
|
||||
|
@ -31,6 +34,9 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
|
|||
super();
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testQueryAccessItemsForAccessIds()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
|
@ -41,6 +47,21 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
|
|||
Assert.assertEquals(8L, results.size());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy")
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testQueryAccessItemsForAccessIdsNotAuthorized()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
List<WorkbasketAccessItem> results = workbasketService.createWorkbasketAccessItemQuery()
|
||||
.accessIdIn("user_1_1", "group_1")
|
||||
.list();
|
||||
fail("NotAuthorizedException was expected");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testQueryAccessItemsForAccessIdsOrderedAscending()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
|
@ -56,6 +77,9 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
|
|||
Assert.assertEquals("WAI:100000000000000000000000000000000003", results.get(0).getId());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testQueryAccessItemsForAccessIdsAndWorkbasketKey()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
|
@ -67,6 +91,9 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
|
|||
Assert.assertEquals(3L, results.size());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testQueryAccessItemsByWorkbasketKey()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
|
@ -77,6 +104,9 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
|
|||
Assert.assertEquals(3L, results.size());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testQueryAccessItemsByWorkbasketKeyOrderedDescending()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package acceptance.workbasket;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -34,6 +36,9 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
|
|||
super();
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testQueryAllTransferTargetsForUser()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
|
@ -45,6 +50,21 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
|
|||
Assert.assertEquals("USER_1_1", results.get(0).getKey());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy")
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testQueryAllTransferTargetsForUserNotAuthorized()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
workbasketService.createWorkbasketQuery()
|
||||
.accessIdsHavePermission(WorkbasketAuthorization.APPEND, "user_1_1")
|
||||
.list();
|
||||
fail("NotAuthorizedException was expected");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testQueryAllTransferTargetsForUserAndGroup()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
|
||||
|
@ -55,6 +75,9 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
|
|||
Assert.assertEquals(7, results.size());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testQueryAllTransferTargetsForUserAndGroupSortedByNameAscending()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException,
|
||||
|
@ -68,6 +91,9 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
|
|||
Assert.assertEquals("GPK_KSC_1", results.get(0).getKey());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testQueryAllTransferTargetsForUserAndGroupSortedByNameDescending()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException,
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.time.Instant;
|
|||
import org.h2.store.fs.FileUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
|
@ -33,7 +32,7 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = {"group_1", "businessadmin"})
|
||||
@Test
|
||||
public void testUpdateWorkbasket()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
|
@ -64,16 +63,15 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
|
|||
Assert.assertEquals(WorkbasketType.TOPIC, updatedWorkbasket.getType());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_1"})
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testCheckAuthorizationToUpdateWorkbasket()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
InvalidWorkbasketException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A");
|
||||
Workbasket workbasket = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A");
|
||||
|
||||
workbasket.setName("new name");
|
||||
workbasketService.updateWorkbasket(workbasket);
|
||||
|
|
|
@ -47,9 +47,9 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = {"group_1", "businessadmin"})
|
||||
@Test
|
||||
public void testUpdateWorkbasketAccessItemSucceeds() throws InvalidArgumentException {
|
||||
public void testUpdateWorkbasketAccessItemSucceeds() throws InvalidArgumentException, NotAuthorizedException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
WorkbasketAccessItem accessItem = workbasketService
|
||||
.newWorkbasketAccessItem("key1000000000000000000000000000000000000", "user1");
|
||||
|
@ -71,7 +71,7 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"group_1"})
|
||||
groupNames = {"group_1", "businessadmin"})
|
||||
@Test
|
||||
public void testUpdateWorkbasketAccessItemRejected()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
|
@ -113,7 +113,7 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
|
|||
|
||||
@WithAccessId(
|
||||
userName = "user_1_1",
|
||||
groupNames = {"group_2"})
|
||||
groupNames = {"group_2", "businessadmin"})
|
||||
@Test
|
||||
public void testUpdatedAccessItemLeadsToNotAuthorizedException()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
|
@ -236,8 +236,11 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
|
|||
assertFalse(item0.isPermTransfer());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "teamlead_1",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testDeleteAccessItemsForAccessId() {
|
||||
public void testDeleteAccessItemsForAccessId() throws NotAuthorizedException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
final String accessId = "group_1";
|
||||
final long accessIdCountBefore = workbasketService
|
||||
|
|
|
@ -59,7 +59,7 @@ public class ClassificationServiceImplTest {
|
|||
|
||||
@Test(expected = ClassificationAlreadyExistException.class)
|
||||
public void testCreateClassificationAlreadyExisting()
|
||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException {
|
||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException {
|
||||
Classification classification = createDummyClassification();
|
||||
doReturn(classification).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(),
|
||||
classification.getDomain());
|
||||
|
@ -71,6 +71,7 @@ public class ClassificationServiceImplTest {
|
|||
verify(classificationMapperMock, times(1)).findByKeyAndDomain(classification.getKey(),
|
||||
classification.getDomain());
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -78,7 +79,8 @@ public class ClassificationServiceImplTest {
|
|||
|
||||
@Test
|
||||
public void testCreateClassificationInOwnDomainButExistingInRoot()
|
||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException, InterruptedException {
|
||||
throws ClassificationAlreadyExistException, ClassificationNotFoundException, InterruptedException,
|
||||
NotAuthorizedException {
|
||||
Instant beforeTimestamp = Instant.now();
|
||||
Thread.sleep(10L);
|
||||
Classification classification = createDummyClassification();
|
||||
|
@ -96,6 +98,7 @@ public class ClassificationServiceImplTest {
|
|||
verify(classificationMapperMock, times(1)).findByKeyAndDomain(key, "");
|
||||
verify(classificationMapperMock, times(1)).insert(any());
|
||||
verify(taskanaEngineImplMock, times(2)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
|
||||
Thread.sleep(15);
|
||||
assertThat(classification.getCreated().toString().substring(0, 10), equalTo(todaysDate));
|
||||
|
@ -107,7 +110,7 @@ public class ClassificationServiceImplTest {
|
|||
|
||||
@Test
|
||||
public void testCreateClassificationInOwnDomainAndCopyInRootDomain()
|
||||
throws ClassificationAlreadyExistException {
|
||||
throws ClassificationAlreadyExistException, NotAuthorizedException {
|
||||
Classification classification = createDummyClassification();
|
||||
String domain = classification.getDomain();
|
||||
String key = classification.getKey();
|
||||
|
@ -122,6 +125,7 @@ public class ClassificationServiceImplTest {
|
|||
verify(classificationMapperMock, times(2)).findByKeyAndDomain(key, "");
|
||||
verify(classificationMapperMock, times(2)).insert(any());
|
||||
verify(taskanaEngineImplMock, times(2)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
|
||||
assertThat(classification.getCreated().toString().substring(0, 10), equalTo(todaysDate));
|
||||
assertThat(classification.getDomain(), equalTo(domain));
|
||||
|
@ -130,7 +134,7 @@ public class ClassificationServiceImplTest {
|
|||
|
||||
@Test
|
||||
public void testCreateClassificationIntoRootDomain()
|
||||
throws ClassificationAlreadyExistException {
|
||||
throws ClassificationAlreadyExistException, NotAuthorizedException {
|
||||
ClassificationImpl classification = (ClassificationImpl) createDummyClassification();
|
||||
classification.setDomain("");
|
||||
doReturn(null).when(classificationMapperMock).findByKeyAndDomain(classification.getKey(),
|
||||
|
@ -143,6 +147,7 @@ public class ClassificationServiceImplTest {
|
|||
classification.getDomain());
|
||||
verify(classificationMapperMock, times(1)).insert(classification);
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
|
||||
assertThat(classification.getCreated().toString().substring(0, 10), equalTo(todaysDate));
|
||||
}
|
||||
|
@ -158,6 +163,7 @@ public class ClassificationServiceImplTest {
|
|||
verify(taskanaEngineImplMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(2)).getClassification(classification.getKey(), classification.getDomain());
|
||||
verify(classificationMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(classificationMapperMock, taskanaEngineImplMock, classificationQueryImplMock);
|
||||
}
|
||||
|
|
|
@ -79,9 +79,6 @@ public class TaskServiceImplTest {
|
|||
@Mock
|
||||
private TaskanaEngineImpl taskanaEngineMock;
|
||||
|
||||
@Mock
|
||||
private TaskanaEngineImpl taskanaEngineImpl;
|
||||
|
||||
@Mock
|
||||
private TaskMapper taskMapperMock;
|
||||
|
||||
|
@ -116,8 +113,8 @@ public class TaskServiceImplTest {
|
|||
} catch (NotAuthorizedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Mockito.doNothing().when(taskanaEngineImpl).openConnection();
|
||||
Mockito.doNothing().when(taskanaEngineImpl).returnConnection();
|
||||
Mockito.doNothing().when(taskanaEngineMock).openConnection();
|
||||
Mockito.doNothing().when(taskanaEngineMock).returnConnection();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -144,16 +141,16 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task actualTask = cutSpy.createTask(expectedTask);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(any(), any());
|
||||
verify(classificationServiceImplMock, times(1)).getClassification(any(), any());
|
||||
verify(taskanaEngineMock, times(1)).getConfiguration();
|
||||
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceImplMock);
|
||||
|
||||
|
@ -221,7 +218,7 @@ public class TaskServiceImplTest {
|
|||
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
|
||||
Task actualTask = cutSpy.createTask(expectedTask);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(wb.getKey(), wb.getDomain());
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(wb.getId(),
|
||||
WorkbasketAuthorization.APPEND);
|
||||
|
@ -230,9 +227,9 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineMock, times(1)).getConfiguration();
|
||||
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceImplMock);
|
||||
assertNull(actualTask.getOwner());
|
||||
|
@ -274,7 +271,7 @@ public class TaskServiceImplTest {
|
|||
Task actualTask = cutSpy.createTask(expectedTask);
|
||||
expectedTask.getPrimaryObjRef().setId(actualTask.getPrimaryObjRef().getId()); // get only new ID
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(expectedTask.getWorkbasketKey(),
|
||||
expectedTask.getDomain());
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(expectedTask.getWorkbasketSummary().getId(),
|
||||
|
@ -284,9 +281,9 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineMock, times(1)).getConfiguration();
|
||||
verify(taskanaEngineConfigurationMock, times(1)).isSecurityEnabled();
|
||||
verify(taskMapperMock, times(1)).insert(expectedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceImplMock);
|
||||
assertNull(actualTask.getOwner());
|
||||
|
@ -344,7 +341,7 @@ public class TaskServiceImplTest {
|
|||
|
||||
cutSpy.createTask(task2);
|
||||
|
||||
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||
verify(taskanaEngineMock, times(2)).openConnection();
|
||||
verify(workbasketServiceMock, times(2)).getWorkbasket(any());
|
||||
verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any());
|
||||
verify(classificationServiceImplMock, times(2)).getClassification(any(), any());
|
||||
|
@ -352,9 +349,9 @@ public class TaskServiceImplTest {
|
|||
verify(taskanaEngineConfigurationMock, times(2)).isSecurityEnabled();
|
||||
verify(taskMapperMock, times(1)).insert(task);
|
||||
verify(taskMapperMock, times(1)).insert(task2);
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verify(taskanaEngineMock, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceImplMock);
|
||||
|
||||
|
@ -384,11 +381,11 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.createTask(task);
|
||||
} catch (TaskAlreadyExistException ex) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskanaEngineMock, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceImplMock);
|
||||
throw ex;
|
||||
|
@ -412,14 +409,14 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.createTask(task);
|
||||
} catch (NotAuthorizedException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(task.getWorkbasketSummary().getId());
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getWorkbasketSummary().getId(),
|
||||
WorkbasketAuthorization.APPEND);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceImplMock);
|
||||
throw e;
|
||||
|
@ -438,13 +435,13 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.createTask(task);
|
||||
} catch (WorkbasketNotFoundException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(task.getWorkbasketKey(),
|
||||
task.getWorkbasketSummary().getDomain());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock,
|
||||
classificationServiceImplMock);
|
||||
throw e;
|
||||
|
@ -460,7 +457,7 @@ public class TaskServiceImplTest {
|
|||
cutSpy.claim(expectedTask.getId());
|
||||
verify(cutSpy, times(1)).claim(expectedTask.getId(), false);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
}
|
||||
|
||||
|
@ -476,12 +473,12 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task acturalTask = cutSpy.claim(expectedTask.getId(), true);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(expectedTask.getId());
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(acturalTask.getState(), equalTo(TaskState.CLAIMED));
|
||||
|
@ -500,12 +497,12 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cut.claim("1", true);
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||
verify(taskanaEngineMock, times(2)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findById(any());
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verify(taskanaEngineMock, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -521,12 +518,12 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.claim("1", true);
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -543,12 +540,12 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.claim("1");
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -566,11 +563,11 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.cancelClaim(expectedTask.getId());
|
||||
} catch (InvalidStateException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(expectedTask.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -591,11 +588,11 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.cancelClaim(expectedTask.getId());
|
||||
} catch (InvalidOwnerException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(expectedTask.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -610,7 +607,7 @@ public class TaskServiceImplTest {
|
|||
cutSpy.cancelClaim(expectedTask.getId());
|
||||
verify(cutSpy, times(1)).cancelClaim(expectedTask.getId(), false);
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
}
|
||||
|
||||
|
@ -630,12 +627,12 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task acturalTask = cutSpy.cancelClaim(expectedTask.getId(), true);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(expectedTask.getId());
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(acturalTask.getState(), equalTo(TaskState.READY));
|
||||
|
@ -660,12 +657,12 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task acturalTask = cutSpy.cancelClaim(expectedTask.getId(), true);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(expectedTask.getId());
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(acturalTask.getState(), equalTo(TaskState.READY));
|
||||
|
@ -703,7 +700,7 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task actualTask = cut.completeTask(task.getId());
|
||||
|
||||
verify(taskanaEngineImpl, times(2)).openConnection();
|
||||
verify(taskanaEngineMock, times(2)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findById(task.getId());
|
||||
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(task.getId());
|
||||
verify(classificationServiceImplMock, times(1)).createClassificationQuery();
|
||||
|
@ -711,9 +708,9 @@ public class TaskServiceImplTest {
|
|||
verify(classificationQueryImplMock, times(1)).keyIn(any());
|
||||
verify(classificationQueryImplMock, times(1)).list();
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(2)).returnConnection();
|
||||
verify(taskanaEngineMock, times(2)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
|
@ -740,12 +737,12 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task actualTask = cutSpy.completeTask(task.getId(), isForced);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(taskMapperMock, times(1)).update(task);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
|
@ -768,12 +765,12 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.completeTask(task.getId(), isForced);
|
||||
} catch (InvalidStateException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -794,12 +791,12 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.completeTask(task.getId(), isForced);
|
||||
} catch (InvalidOwnerException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -815,12 +812,12 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.completeTask(taskId, isForced);
|
||||
} catch (InvalidOwnerException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(taskId);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -844,12 +841,12 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task actualTask = cutSpy.completeTask(task.getId(), isForced);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(taskMapperMock, times(1)).update(task);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
|
@ -880,13 +877,13 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task actualTask = cutSpy.completeTask(task.getId(), isForced);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(cutSpy, times(1)).claim(task.getId(), isForced);
|
||||
verify(taskMapperMock, times(1)).update(claimedTask);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
assertThat(actualTask.getState(), equalTo(TaskState.COMPLETED));
|
||||
assertThat(actualTask.getCreated(), not(equalTo(claimedTask.getModified())));
|
||||
|
@ -918,16 +915,16 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasket.getId(),
|
||||
WorkbasketAuthorization.APPEND);
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(sourceWorkbasket.getId(),
|
||||
WorkbasketAuthorization.TRANSFER);
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(destinationWorkbasket.getId());
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(actualTask.isRead(), equalTo(false));
|
||||
|
@ -954,15 +951,15 @@ public class TaskServiceImplTest {
|
|||
// doNothing().when(workbasketServiceMock).checkAuthorizationById(any(), WorkbasketAuthorization.TRANSFER);
|
||||
Task actualTask = cutSpy.transfer(task.getId(), destinationWorkbasket.getId());
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(2)).checkAuthorization(any(), any());
|
||||
verify(workbasketServiceMock, times(1)).getWorkbasket(destinationWorkbasket.getId());
|
||||
verify(taskanaEngineMock, times(0)).getConfiguration();
|
||||
verify(taskanaEngineConfigurationMock, times(0)).isSecurityEnabled();
|
||||
verify(taskMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
|
||||
assertThat(actualTask.isRead(), equalTo(false));
|
||||
|
@ -986,13 +983,13 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.transfer(task.getId(), destinationWorkbasketId);
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId,
|
||||
WorkbasketAuthorization.APPEND);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -1010,11 +1007,11 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.transfer(task.getId(), "2");
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -1035,13 +1032,13 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.transfer(task.getId(), destinationWorkbasketId);
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId,
|
||||
WorkbasketAuthorization.APPEND);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -1064,15 +1061,15 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.transfer(task.getId(), destinationWorkbasketId);
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(destinationWorkbasketId,
|
||||
WorkbasketAuthorization.APPEND);
|
||||
verify(workbasketServiceMock, times(1)).checkAuthorization(task.getWorkbasketSummary().getId(),
|
||||
WorkbasketAuthorization.TRANSFER);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -1090,11 +1087,11 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task actualTask = cutSpy.setTaskRead("1", true);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(taskMapperMock, times(1)).update(task);
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
assertThat(actualTask.getModified(), not(equalTo(null)));
|
||||
assertThat(actualTask.isRead(), equalTo(true));
|
||||
|
@ -1111,11 +1108,10 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.setTaskRead("1", true);
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
|
@ -1142,16 +1138,16 @@ public class TaskServiceImplTest {
|
|||
.list();
|
||||
Task actualTask = cut.getTask(expectedTask.getId());
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findById(expectedTask.getId());
|
||||
verify(attachmentMapperMock, times(1)).findAttachmentsByTaskId(expectedTask.getId());
|
||||
verify(classificationServiceImplMock, times(1)).createClassificationQuery();
|
||||
verify(classificationQueryImplMock, times(1)).domainIn(any());
|
||||
verify(classificationQueryImplMock, times(1)).keyIn(any());
|
||||
verify(classificationQueryImplMock, times(1)).list();
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock, taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
assertThat(actualTask, equalTo(expectedTask));
|
||||
}
|
||||
|
@ -1165,12 +1161,12 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cut.getTask(task.getId());
|
||||
} catch (Exception e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(taskMapperMock, times(1)).findById(task.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
verifyNoMoreInteractions(attachmentMapperMock, taskanaEngineConfigurationMock,
|
||||
taskanaEngineMock,
|
||||
taskanaEngineImpl, taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
taskMapperMock, objectReferenceMapperMock, workbasketServiceMock, sqlSessionMock,
|
||||
classificationQueryImplMock);
|
||||
throw e;
|
||||
}
|
||||
|
@ -1197,10 +1193,10 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task actualTask = cutSpy.updateTask(task);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(attachmentMapperMock, times(1)).insert(((AttachmentImpl) attachment));
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
assertThat(actualTask.getAttachments().size(), equalTo(1));
|
||||
}
|
||||
|
||||
|
@ -1226,10 +1222,10 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task actualTask = cutSpy.updateTask(task);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(attachmentMapperMock, times(1)).insert(((AttachmentImpl) attachment));
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
assertThat(actualTask.getAttachments().size(), equalTo(1));
|
||||
}
|
||||
|
||||
|
@ -1259,10 +1255,10 @@ public class TaskServiceImplTest {
|
|||
try {
|
||||
cutSpy.updateTask(task);
|
||||
} catch (AttachmentPersistenceException e) {
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(attachmentMapperMock, times(1)).insert(((AttachmentImpl) attachment));
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -1293,10 +1289,10 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task actualTask = cutSpy.updateTask(task);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(attachmentMapperMock, times(1)).update(((AttachmentImpl) attachmentToUpdate));
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
assertThat(actualTask.getAttachments().size(), equalTo(1));
|
||||
assertThat(actualTask.getAttachments().get(0).getChannel(), equalTo(channelUpdate));
|
||||
}
|
||||
|
@ -1323,10 +1319,10 @@ public class TaskServiceImplTest {
|
|||
|
||||
Task actualTask = cutSpy.updateTask(task);
|
||||
|
||||
verify(taskanaEngineImpl, times(1)).openConnection();
|
||||
verify(taskanaEngineMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getTask(task.getId());
|
||||
verify(attachmentMapperMock, times(1)).deleteAttachment(attachment.getId());
|
||||
verify(taskanaEngineImpl, times(1)).returnConnection();
|
||||
verify(taskanaEngineMock, times(1)).returnConnection();
|
||||
assertThat(actualTask.getAttachments().size(), equalTo(0));
|
||||
}
|
||||
|
||||
|
|
|
@ -218,6 +218,7 @@ public class WorkbasketServiceImplTest {
|
|||
} catch (InvalidWorkbasketException ex) {
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).openConnection();
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -234,6 +235,7 @@ public class WorkbasketServiceImplTest {
|
|||
} catch (InvalidWorkbasketException ex) {
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).openConnection();
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -251,6 +253,7 @@ public class WorkbasketServiceImplTest {
|
|||
} catch (InvalidWorkbasketException ex) {
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).openConnection();
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -267,6 +270,7 @@ public class WorkbasketServiceImplTest {
|
|||
} catch (InvalidWorkbasketException ex) {
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).openConnection();
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -284,6 +288,7 @@ public class WorkbasketServiceImplTest {
|
|||
} catch (InvalidWorkbasketException ex) {
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).openConnection();
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -301,6 +306,7 @@ public class WorkbasketServiceImplTest {
|
|||
} catch (InvalidWorkbasketException ex) {
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).openConnection();
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(serviceCalls)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -330,6 +336,8 @@ public class WorkbasketServiceImplTest {
|
|||
verify(workbasketMapperMock, times(2)).findById(expectedWb.getId());
|
||||
verify(workbasketMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImplMock, times(5)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(2)).checkRoleMembership(any());
|
||||
verify(taskanaEngineImplMock, times(2)).isUserInRole(any());
|
||||
verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsBySourceId(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
|
@ -364,6 +372,8 @@ public class WorkbasketServiceImplTest {
|
|||
verify(workbasketMapperMock, times(3)).findById(any());
|
||||
verify(workbasketMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImplMock, times(5)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(4)).checkRoleMembership(any());
|
||||
verify(taskanaEngineImplMock, times(1)).isUserInRole(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -392,6 +402,7 @@ public class WorkbasketServiceImplTest {
|
|||
verify(workbasketMapperMock, times(2)).findById(any());
|
||||
verify(cutSpy, times(1)).getWorkbasket(any());
|
||||
verify(taskanaEngineImplMock, times(3)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(2)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -432,6 +443,7 @@ public class WorkbasketServiceImplTest {
|
|||
} catch (InvalidArgumentException e) {
|
||||
verify(taskanaEngineImplMock, times(1)).openConnection();
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -444,6 +456,7 @@ public class WorkbasketServiceImplTest {
|
|||
} catch (InvalidArgumentException e) {
|
||||
verify(taskanaEngineImplMock, times(2)).openConnection();
|
||||
verify(taskanaEngineImplMock, times(2)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(2)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -461,6 +474,7 @@ public class WorkbasketServiceImplTest {
|
|||
verify(taskanaEngineImplMock, times(1)).openConnection();
|
||||
verify(cutSpy, times(1)).getWorkbasket(workbasketId);
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -519,6 +533,7 @@ public class WorkbasketServiceImplTest {
|
|||
verify(workbasketAccessMapperMock, times(1)).deleteAllAccessItemsForWorkbasketId(wb.getId());
|
||||
verify(workbasketMapperMock, times(1)).delete(wb.getId());
|
||||
verify(taskanaEngineImplMock, times(1)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(1)).checkRoleMembership(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
@Before
|
||||
public void setup() throws FileNotFoundException, SQLException, LoginException {
|
||||
dataSource = TaskanaEngineConfigurationTest.getDataSource();
|
||||
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
|
||||
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, false);
|
||||
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
classificationService = taskanaEngine.getClassificationService();
|
||||
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
|
@ -159,7 +159,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFindAllClassifications() throws ClassificationAlreadyExistException {
|
||||
public void testFindAllClassifications() throws ClassificationAlreadyExistException, NotAuthorizedException {
|
||||
Classification classification0 = this.createDummyClassificationWithUniqueKey("", "type1");
|
||||
classificationService.createClassification(classification0);
|
||||
Classification classification1 = this.createDummyClassificationWithUniqueKey("", "type1");
|
||||
|
@ -223,7 +223,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperDomainAndCategory() throws ClassificationAlreadyExistException {
|
||||
public void testFindWithClassificationMapperDomainAndCategory()
|
||||
throws ClassificationAlreadyExistException, NotAuthorizedException {
|
||||
Classification classification1 = this.createDummyClassificationWithUniqueKey("domain1", "type1");
|
||||
classification1.setCategory("category1");
|
||||
classificationService.createClassification(classification1);
|
||||
|
@ -244,7 +245,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperCustomAndCategory() throws ClassificationAlreadyExistException {
|
||||
public void testFindWithClassificationMapperCustomAndCategory()
|
||||
throws ClassificationAlreadyExistException, NotAuthorizedException {
|
||||
Classification classification1 = this.createDummyClassificationWithUniqueKey("", "type1");
|
||||
classification1.setDescription("DESC1");
|
||||
classification1.setCategory("category1");
|
||||
|
@ -281,7 +283,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperPriorityTypeAndParent()
|
||||
throws ClassificationAlreadyExistException, NumberFormatException {
|
||||
throws ClassificationAlreadyExistException, NumberFormatException, NotAuthorizedException {
|
||||
Classification classification = this.createDummyClassificationWithUniqueKey("", "type1");
|
||||
classification.setPriority(Integer.decode("5"));
|
||||
classificationService.createClassification(classification);
|
||||
|
@ -315,7 +317,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperServiceLevelNameAndDescription()
|
||||
throws ClassificationAlreadyExistException {
|
||||
throws ClassificationAlreadyExistException, NotAuthorizedException {
|
||||
int all = 0;
|
||||
Classification classification = this.createDummyClassificationWithUniqueKey("", "type1");
|
||||
classification.setServiceLevel("P1D");
|
||||
|
@ -395,7 +397,8 @@ public class ClassificationServiceImplIntAutoCommitTest {
|
|||
return new TimeInterval(begin, end);
|
||||
}
|
||||
|
||||
private Classification createDummyClassificationWithUniqueKey(String domain, String type) {
|
||||
private Classification createDummyClassificationWithUniqueKey(String domain, String type)
|
||||
throws NotAuthorizedException {
|
||||
Classification classification = classificationService.newClassification("TEST" + counter, domain, type);
|
||||
counter++;
|
||||
return classification;
|
||||
|
|
|
@ -72,7 +72,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
@Before
|
||||
public void setup() throws SQLException {
|
||||
dataSource = TaskanaEngineConfigurationTest.getDataSource();
|
||||
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
|
||||
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, false);
|
||||
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
|
||||
classificationService = taskanaEngine.getClassificationService();
|
||||
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
|
||||
|
@ -83,7 +83,8 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
|
||||
@Test
|
||||
public void testInsertClassification()
|
||||
throws SQLException, ClassificationNotFoundException, ClassificationAlreadyExistException {
|
||||
throws SQLException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
NotAuthorizedException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
|
@ -168,7 +169,8 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFindAllClassifications() throws SQLException, ClassificationAlreadyExistException {
|
||||
public void testFindAllClassifications()
|
||||
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
Classification classification0 = this.createNewClassificationWithUniqueKey("", "t1");
|
||||
|
@ -205,7 +207,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
|
||||
@Test
|
||||
public void testInsertAndClassificationQuery()
|
||||
throws SQLException, ClassificationAlreadyExistException {
|
||||
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
Classification classification = this.createNewClassificationWithUniqueKey("", "t1");
|
||||
|
@ -248,7 +250,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperDomainAndCategory()
|
||||
throws SQLException, ClassificationAlreadyExistException {
|
||||
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
Classification classification1 = this.createNewClassificationWithUniqueKey("domain1", "t1");
|
||||
|
@ -274,7 +276,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperCustomAndCategory()
|
||||
throws SQLException, ClassificationAlreadyExistException {
|
||||
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
Classification classification1 = this.createNewClassificationWithUniqueKey("", "t1");
|
||||
|
@ -314,7 +316,7 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
|
||||
@Test
|
||||
public void testFindWithClassificationMapperPriorityTypeAndParent()
|
||||
throws SQLException, ClassificationAlreadyExistException {
|
||||
throws SQLException, ClassificationAlreadyExistException, NotAuthorizedException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
Classification classification = this.createNewClassificationWithUniqueKey("", "type1");
|
||||
|
@ -436,7 +438,8 @@ public class ClassificationServiceImplIntExplicitTest {
|
|||
taskanaEngineImpl.setConnection(null);
|
||||
}
|
||||
|
||||
private Classification createNewClassificationWithUniqueKey(String domain, String type) {
|
||||
private Classification createNewClassificationWithUniqueKey(String domain, String type)
|
||||
throws NotAuthorizedException {
|
||||
Classification classification = classificationService.newClassification("TEST" + counter, domain, type);
|
||||
counter++;
|
||||
return classification;
|
||||
|
|
|
@ -280,7 +280,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1");
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "User")
|
||||
@WithAccessId(userName = "User", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException,
|
||||
ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException,
|
||||
|
@ -401,7 +401,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
}
|
||||
|
||||
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
|
||||
boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException {
|
||||
boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException, NotAuthorizedException {
|
||||
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), accessId);
|
||||
accessItem.setPermOpen(permOpen);
|
||||
accessItem.setPermRead(permRead);
|
||||
|
|
|
@ -101,7 +101,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
cleaner.clearDb(dataSource, false);
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test(expected = TaskNotFoundException.class)
|
||||
public void testStartTransactionFail()
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
|
||||
|
@ -136,7 +136,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
connection.commit();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testCreateTask()
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
|
||||
|
@ -167,6 +167,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
connection.commit();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testCreateTaskInTaskanaWithDefaultDb()
|
||||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
|
||||
|
@ -205,7 +206,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
te.setConnection(null);
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testCreateTaskWithPlannedAndName() throws SQLException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
|
@ -272,7 +273,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
Assert.assertFalse(resultTask.getName().equals(resultTask2.getName()));
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void createTaskShouldThrowWorkbasketNotFoundException()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException,
|
||||
|
@ -288,7 +289,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
taskServiceImpl.createTask(test);
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test(expected = ClassificationNotFoundException.class)
|
||||
public void createManualTaskShouldThrowClassificationNotFoundException()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException,
|
||||
|
@ -316,7 +317,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
taskServiceImpl.createTask(task);
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"DummyGroup"})
|
||||
@WithAccessId(userName = "Elena", groupNames = {"DummyGroup", "businessadmin"})
|
||||
@Test
|
||||
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
|
@ -360,7 +361,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
connection.commit();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void shouldTransferTaskToOtherWorkbasket()
|
||||
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
|
@ -438,7 +439,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1");
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "User")
|
||||
@WithAccessId(userName = "User", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException,
|
||||
ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException,
|
||||
|
@ -540,7 +541,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
return task;
|
||||
}
|
||||
|
||||
private void generateSampleAccessItems() throws InvalidArgumentException {
|
||||
private void generateSampleAccessItems() throws InvalidArgumentException, NotAuthorizedException {
|
||||
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
|
||||
accessItem.setPermAppend(true);
|
||||
accessItem.setPermRead(true);
|
||||
|
@ -554,7 +555,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
|
||||
boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException {
|
||||
boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException, NotAuthorizedException {
|
||||
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), accessId);
|
||||
accessItem.setPermOpen(permOpen);
|
||||
accessItem.setPermRead(permRead);
|
||||
|
|
|
@ -86,7 +86,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
now = Instant.now();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testSelectWorkbasket()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
||||
|
@ -105,7 +105,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
workBasketService.getWorkbasket("fail");
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testSelectWorkbasketWithDistribution()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
||||
|
@ -132,7 +132,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testUpdateWorkbasket() throws Exception {
|
||||
String id0 = IdGenerator.generateWithPrefix("TWB");
|
||||
|
@ -177,6 +177,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
workBasketService.getWorkbasket(id3).getModified());
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testInsertWorkbasketAccessUser() throws NotAuthorizedException, InvalidArgumentException {
|
||||
WorkbasketAccessItem accessItem = workBasketService
|
||||
|
@ -189,6 +190,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
workBasketService.getWorkbasketAuthorizations("k100000000000000000000000000000000000000").size());
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, InvalidArgumentException {
|
||||
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(
|
||||
|
@ -238,7 +240,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
}
|
||||
|
||||
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
|
||||
boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException {
|
||||
boolean permRead, boolean permAppend, boolean permTransfer)
|
||||
throws InvalidArgumentException, NotAuthorizedException {
|
||||
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(wb.getId(), accessId);
|
||||
accessItem.setPermOpen(permOpen);
|
||||
accessItem.setPermRead(permRead);
|
||||
|
@ -247,7 +250,8 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
workBasketService.createWorkbasketAuthorization(accessItem);
|
||||
}
|
||||
|
||||
private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type) {
|
||||
private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type)
|
||||
throws NotAuthorizedException {
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket(key, domain);
|
||||
wb.setId(id);
|
||||
wb.setName(name);
|
||||
|
|
|
@ -73,7 +73,7 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
cleaner.clearDb(dataSource, false);
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testSelectWorkbasket()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, InvalidWorkbasketException,
|
||||
|
@ -111,7 +111,7 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
connection.commit();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testSelectWorkbasketWithDistribution()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, InvalidWorkbasketException,
|
||||
|
@ -144,7 +144,7 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
connection.commit();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testUpdateWorkbasket() throws Exception {
|
||||
Connection connection = dataSource.getConnection();
|
||||
|
@ -193,6 +193,7 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
connection.commit();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testInsertWorkbasketAccessUser() throws NotAuthorizedException, SQLException, InvalidArgumentException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
|
@ -209,6 +210,7 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
connection.commit();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testUpdateWorkbasketAccessUser() throws NotAuthorizedException, SQLException, InvalidArgumentException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
|
@ -227,7 +229,8 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
}
|
||||
|
||||
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
|
||||
boolean permRead, boolean permAppend, boolean permTransfer) throws InvalidArgumentException {
|
||||
boolean permRead, boolean permAppend, boolean permTransfer)
|
||||
throws InvalidArgumentException, NotAuthorizedException {
|
||||
WorkbasketAccessItem accessItem = workBasketService.newWorkbasketAccessItem(
|
||||
wb.getId(), accessId);
|
||||
accessItem.setPermOpen(permOpen);
|
||||
|
@ -237,7 +240,8 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
workBasketService.createWorkbasketAuthorization(accessItem);
|
||||
}
|
||||
|
||||
private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type) {
|
||||
private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type)
|
||||
throws NotAuthorizedException {
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket(key, domain);
|
||||
wb.setId(id);
|
||||
wb.setName(name);
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
taskana.roles.user = group1 | group2|teamlead_1 |teamlead_2 |user_1_1| user_1_1| user_1_2| user_2_1| user_2_2| max|elena|simone
|
||||
taskana.roles.Admin=teamlead_1|teamlead_2
|
||||
taskana.roles.businessadmin=max|Moritz
|
||||
taskana.roles.Admin=name=konrad,Organisation=novatec|admin
|
||||
taskana.roles.businessadmin=max|Moritz|businessadmin
|
||||
|
|
|
@ -61,7 +61,7 @@ public class TaskanaConfig {
|
|||
|
||||
@Bean
|
||||
public SpringTaskanaEngineConfiguration taskanaEngineConfiguration(DataSource dataSource) {
|
||||
SpringTaskanaEngineConfiguration taskanaEngineConfiguration = new SpringTaskanaEngineConfiguration();
|
||||
SpringTaskanaEngineConfiguration taskanaEngineConfiguration = new SpringTaskanaEngineConfiguration(false);
|
||||
taskanaEngineConfiguration.setDataSource(dataSource);
|
||||
return taskanaEngineConfiguration;
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public class TaskanaTestController {
|
|||
return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM GESCHBUCH.TEST", Integer.class);
|
||||
}
|
||||
|
||||
private Workbasket createWorkBasket(String key, String name) {
|
||||
private Workbasket createWorkBasket(String key, String name) throws NotAuthorizedException {
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) taskanaEngine.getWorkbasketService().newWorkbasket(key,
|
||||
"generali");
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
|
|
|
@ -134,7 +134,8 @@ public class WorkbasketController {
|
|||
|
||||
@PostMapping
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<WorkbasketResource> createWorkbasket(@RequestBody WorkbasketResource workbasketResource) {
|
||||
public ResponseEntity<WorkbasketResource> createWorkbasket(@RequestBody WorkbasketResource workbasketResource)
|
||||
throws NotAuthorizedException {
|
||||
try {
|
||||
Workbasket workbasket = workbasketMapper.toModel(workbasketResource);
|
||||
workbasket = workbasketService.createWorkbasket(workbasket);
|
||||
|
@ -189,7 +190,7 @@ public class WorkbasketController {
|
|||
@PostMapping(path = "/authorizations")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<WorkbasketAccessItemResource> createWorkbasketAuthorization(
|
||||
@RequestBody WorkbasketAccessItemResource workbasketAccessItemResource) {
|
||||
@RequestBody WorkbasketAccessItemResource workbasketAccessItemResource) throws NotAuthorizedException {
|
||||
try {
|
||||
WorkbasketAccessItem workbasketAccessItem = workbasketAccessItemMapper
|
||||
.toModel(workbasketAccessItemResource);
|
||||
|
@ -210,7 +211,7 @@ public class WorkbasketController {
|
|||
.toModel(workbasketAccessItemResource);
|
||||
workbasketAccessItem = workbasketService.updateWorkbasketAuthorization(workbasketAccessItem);
|
||||
return new ResponseEntity<>(workbasketAccessItemMapper.toResource(workbasketAccessItem), HttpStatus.OK);
|
||||
} catch (InvalidArgumentException e) {
|
||||
} catch (InvalidArgumentException | NotAuthorizedException e) {
|
||||
return new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED);
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +235,8 @@ public class WorkbasketController {
|
|||
|
||||
@DeleteMapping(path = "/authorizations/{authId}")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<?> deleteWorkbasketAuthorization(@PathVariable(value = "authId") String authId) {
|
||||
public ResponseEntity<?> deleteWorkbasketAuthorization(@PathVariable(value = "authId") String authId)
|
||||
throws NotAuthorizedException {
|
||||
workbasketService.deleteWorkbasketAuthorization(authId);
|
||||
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
|
||||
}
|
||||
|
|
|
@ -9,12 +9,14 @@ import org.springframework.stereotype.Component;
|
|||
import pro.taskana.Classification;
|
||||
import pro.taskana.ClassificationService;
|
||||
import pro.taskana.impl.ClassificationImpl;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.rest.resource.ClassificationResource;
|
||||
|
||||
@Component
|
||||
public class ClassificationMapper {
|
||||
|
||||
@Autowired ClassificationService classificationService;
|
||||
@Autowired
|
||||
ClassificationService classificationService;
|
||||
|
||||
public ClassificationResource toResource(Classification classification) {
|
||||
ClassificationResource resource = new ClassificationResource();
|
||||
|
@ -25,7 +27,7 @@ public class ClassificationMapper {
|
|||
return resource;
|
||||
}
|
||||
|
||||
public Classification toModel(ClassificationResource classificationResource) {
|
||||
public Classification toModel(ClassificationResource classificationResource) throws NotAuthorizedException {
|
||||
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification(
|
||||
classificationResource.domain, classificationResource.key, classificationResource.type);
|
||||
BeanUtils.copyProperties(classificationResource, classification);
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.impl.WorkbasketImpl;
|
||||
import pro.taskana.rest.WorkbasketController;
|
||||
import pro.taskana.rest.resource.WorkbasketResource;
|
||||
|
@ -34,7 +35,7 @@ public class WorkbasketMapper {
|
|||
return resource;
|
||||
}
|
||||
|
||||
public Workbasket toModel(WorkbasketResource wbResource) {
|
||||
public Workbasket toModel(WorkbasketResource wbResource) throws NotAuthorizedException {
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket(wbResource.key, wbResource.domain);
|
||||
BeanUtils.copyProperties(wbResource, workbasket);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
|||
|
||||
import pro.taskana.Classification;
|
||||
import pro.taskana.ClassificationService;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.impl.ClassificationImpl;
|
||||
import pro.taskana.rest.RestApplication;
|
||||
import pro.taskana.rest.resource.ClassificationResource;
|
||||
|
@ -21,12 +22,14 @@ import pro.taskana.rest.resource.ClassificationResource;
|
|||
@WebAppConfiguration
|
||||
public class ClassificationMapperTest {
|
||||
|
||||
@Autowired ClassificationMapper classificationMapper;
|
||||
@Autowired ClassificationService classificationService;
|
||||
@Autowired
|
||||
ClassificationMapper classificationMapper;
|
||||
@Autowired
|
||||
ClassificationService classificationService;
|
||||
|
||||
@Test
|
||||
public void classificationToResource() {
|
||||
//given
|
||||
// given
|
||||
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification("DOMAIN_A",
|
||||
"1", "A");
|
||||
classification.setId("1");
|
||||
|
@ -47,15 +50,15 @@ public class ClassificationMapperTest {
|
|||
classification.setServiceLevel("P1D");
|
||||
classification.setDescription("Test");
|
||||
classification.setCreated(Instant.parse("2010-01-01T12:00:00Z"));
|
||||
//when
|
||||
// when
|
||||
ClassificationResource classificationResource = classificationMapper.toResource(classification);
|
||||
//then
|
||||
// then
|
||||
testEquality(classification, classificationResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resourceToClassification() {
|
||||
//given
|
||||
public void resourceToClassification() throws NotAuthorizedException {
|
||||
// given
|
||||
ClassificationResource classificationResource = new ClassificationResource();
|
||||
classificationResource.setClassificationId("1");
|
||||
classificationResource.setKey("12");
|
||||
|
@ -79,9 +82,9 @@ public class ClassificationMapperTest {
|
|||
classificationResource.setApplicationEntryPoint("12");
|
||||
classificationResource.setServiceLevel("P1D");
|
||||
classificationResource.setDescription("Test");
|
||||
//when
|
||||
// when
|
||||
ClassificationImpl classification = (ClassificationImpl) classificationMapper.toModel(classificationResource);
|
||||
//then
|
||||
// then
|
||||
testEquality(classification, classificationResource);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
|
|||
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.impl.WorkbasketImpl;
|
||||
import pro.taskana.impl.WorkbasketType;
|
||||
import pro.taskana.rest.RestApplication;
|
||||
|
@ -22,12 +23,14 @@ import pro.taskana.rest.resource.WorkbasketResource;
|
|||
@WebAppConfiguration
|
||||
public class WorkbasketMapperTest {
|
||||
|
||||
@Autowired WorkbasketService workbasketService;
|
||||
@Autowired WorkbasketMapper workbasketMapper;
|
||||
@Autowired
|
||||
WorkbasketService workbasketService;
|
||||
@Autowired
|
||||
WorkbasketMapper workbasketMapper;
|
||||
|
||||
@Test
|
||||
public void workbasketToResource() {
|
||||
//given
|
||||
// given
|
||||
Workbasket workbasket = workbasketService.newWorkbasket("1", "DOMAIN_A");
|
||||
((WorkbasketImpl) workbasket).setId("ID");
|
||||
workbasket.setType(WorkbasketType.PERSONAL);
|
||||
|
@ -44,15 +47,15 @@ public class WorkbasketMapperTest {
|
|||
workbasket.setOwner("Lars");
|
||||
((WorkbasketImpl) workbasket).setCreated(Instant.parse("2010-01-01T12:00:00Z"));
|
||||
((WorkbasketImpl) workbasket).setModified(Instant.parse("2010-01-01T12:00:00Z"));
|
||||
//when
|
||||
// when
|
||||
WorkbasketResource workbasketResource = workbasketMapper.toResource(workbasket);
|
||||
//then
|
||||
// then
|
||||
testEquality(workbasket, workbasketResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resourceToWorkbasket() {
|
||||
//given
|
||||
public void resourceToWorkbasket() throws NotAuthorizedException {
|
||||
// given
|
||||
WorkbasketResource workbasketResource = new WorkbasketResource();
|
||||
workbasketResource.setWorkbasketId("1");
|
||||
workbasketResource.setCreated("2010-01-01T12:00:00Z");
|
||||
|
@ -71,9 +74,9 @@ public class WorkbasketMapperTest {
|
|||
workbasketResource.setOrgLevel4("Org4");
|
||||
workbasketResource.setOwner("Lars");
|
||||
workbasketResource.setType(WorkbasketType.PERSONAL);
|
||||
//when
|
||||
// when
|
||||
Workbasket workbasket = workbasketMapper.toModel(workbasketResource);
|
||||
//then
|
||||
// then
|
||||
testEquality(workbasket, workbasketResource);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue