TSK-512: Improve general exception handling

- Add root cause to taskana exceptions
- Either throw an exception or log the error
- Remove unnecessary exceptions from method signatures
This commit is contained in:
Konstantin Kläger 2018-06-06 17:00:22 +02:00 committed by Holger Hagen
parent 63c3b7ee53
commit 3230e35c2c
83 changed files with 1684 additions and 1961 deletions

View File

@ -10,7 +10,6 @@ import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidOwnerException;
import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.TaskNotFoundException;
@ -25,8 +24,8 @@ public class ExampleBootstrap {
@PostConstruct
public void init(@Observes @Initialized(ApplicationScoped.class) Object init)
throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException,
ClassificationNotFoundException, InvalidStateException, InvalidOwnerException, InvalidWorkbasketException,
TaskAlreadyExistException, InvalidArgumentException {
ClassificationNotFoundException, InvalidStateException, InvalidOwnerException, TaskAlreadyExistException,
InvalidArgumentException {
System.out.println("---------------------------> Start App");
Task task = taskanaEjb.getTaskService().newTask(null);
ObjectReference objRef = new ObjectReference();

View File

@ -1,8 +1,9 @@
package pro.taskana;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.Properties;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
@ -12,64 +13,65 @@ import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.configuration.TaskanaEngineConfiguration;
@ApplicationScoped
public class TaskanaProducers {
private static final Logger logger = LoggerFactory.getLogger(TaskanaProducers.class);
private static final Logger logger = LoggerFactory.getLogger(TaskanaProducers.class);
private static final String TASKANA_PROPERTIES = "taskana.properties";
private static final String TASKANA_PROPERTIES = "taskana.properties";
@Inject
private TaskanaEngine taskanaEngine;
@Inject
private TaskanaEngine taskanaEngine;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
@PostConstruct
public void init() {
// Load Properties and get Datasource via Context
// Load DataSource via Container
Context ctx;
DataSource dataSource;
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
try (InputStream propertyStream = classloader.getResourceAsStream(TASKANA_PROPERTIES)) {
Properties properties = new Properties();
ctx = new InitialContext();
properties.load(propertyStream);
dataSource = (DataSource) ctx.lookup(properties.getProperty("datasource.jndi"));
logger.debug("---------------> " + dataSource.getConnection().getMetaData());
this.taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, true, false);
} catch (NamingException | SQLException | IOException e) {
logger.error("Could not start Taskana: ", e);
}
}
@PostConstruct
public void init() {
// Load Properties and get Datasource via Context
// Load DataSource via Container
Context ctx;
DataSource dataSource;
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
try (InputStream propertyStream = classloader.getResourceAsStream(TASKANA_PROPERTIES)) {
Properties properties = new Properties();
ctx = new InitialContext();
properties.load(propertyStream);
dataSource = (DataSource) ctx.lookup(properties.getProperty("datasource.jndi"));
logger.debug("---------------> " + dataSource.getConnection().getMetaData());
this.taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, true, false);
} catch (NamingException | SQLException | IOException e) {
logger.error("Could not start Taskana: ", e);
}
}
@ApplicationScoped
@Produces
public TaskanaEngine generateTaskEngine() throws SQLException {
return taskanaEngineConfiguration.buildTaskanaEngine();
}
@ApplicationScoped
@Produces
public TaskanaEngine generateTaskEngine() {
return taskanaEngineConfiguration.buildTaskanaEngine();
}
@ApplicationScoped
@Produces
public TaskService generateTaskService() {
return taskanaEngine.getTaskService();
}
@ApplicationScoped
@Produces
public TaskService generateTaskService() {
return taskanaEngine.getTaskService();
}
@ApplicationScoped
@Produces
public ClassificationService generateClassificationService() {
return taskanaEngine.getClassificationService();
}
@ApplicationScoped
@Produces
public ClassificationService generateClassificationService() {
return taskanaEngine.getClassificationService();
}
@ApplicationScoped
@Produces
public WorkbasketService generateWorkbasketService() {
return taskanaEngine.getWorkbasketService();
}
@ApplicationScoped
@Produces
public WorkbasketService generateWorkbasketService() {
return taskanaEngine.getWorkbasketService();
}
}

View File

@ -5,7 +5,6 @@ import javax.inject.Inject;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
@ -35,8 +34,7 @@ public class TaskanaEjb {
}
public void triggerRollback() throws NotAuthorizedException, WorkbasketNotFoundException,
ClassificationNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException,
InvalidArgumentException {
ClassificationNotFoundException, TaskAlreadyExistException, InvalidArgumentException {
Task task = taskService.newTask(null);
ObjectReference objRef = new ObjectReference();
objRef.setCompany("aCompany");

View File

@ -5,7 +5,6 @@ import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.naming.NamingException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@ -14,7 +13,6 @@ import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.swarm.Swarm;
@ -45,12 +43,8 @@ public class TaskanaProducersTest {
return swarm;
}
@Before
public void init() throws SQLException, ClassNotFoundException {
}
@Test
public void testCommit() throws SQLException, ClassNotFoundException, NamingException {
public void testCommit() throws SQLException, ClassNotFoundException {
Client client = ClientBuilder.newClient();
client.target("http://127.0.0.1:8090/rest/test").request().get();
@ -70,7 +64,7 @@ public class TaskanaProducersTest {
}
@Test
public void testRollback() throws SQLException, ClassNotFoundException, NamingException {
public void testRollback() throws SQLException, ClassNotFoundException {
Client client = ClientBuilder.newClient();
client.target("http://127.0.0.1:8090/rest/test").request().post(null);

View File

@ -66,7 +66,7 @@ public class TaskanaRestTest {
@POST
public Response rollbackTask()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidWorkbasketException, TaskAlreadyExistException, InvalidArgumentException {
TaskAlreadyExistException, InvalidArgumentException {
taskanaEjb.triggerRollback();
return Response.status(204).build();
}
@ -74,8 +74,7 @@ public class TaskanaRestTest {
@DELETE
@Path("{id}")
public void completeTask(@PathParam("id") String id)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, ClassificationNotFoundException,
NotAuthorizedException {
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException {
logger.info(id);
taskanaEjb.getTaskService().forceCompleteTask(id);
}

View File

@ -1,343 +1,342 @@
package pro.taskana.configuration;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.SQLException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import javax.sql.DataSource;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaRole;
import pro.taskana.exceptions.SystemException;
import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.util.LoggerUtils;
/**
* This central class creates the TaskanaEngine and holds all the information about DB and Security.<br>
* Security is enabled by default.
*/
public class TaskanaEngineConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineConfiguration.class);
private static final String USER_NAME = "sa";
private static final String USER_PASSWORD = "sa";
private static final String JDBC_H2_MEM_TASKANA = "jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0;INIT=CREATE SCHEMA IF NOT EXISTS TASKANA";
private static final String H2_DRIVER = "org.h2.Driver";
private static final String TASKANA_PROPERTIES = "/taskana.properties";
private static final String TASKANA_ROLES_SEPARATOR = "|";
private static final String TASKANA_DOMAINS_PROPERTY = "taskana.domains";
private static final String TASKANA_CLASSIFICATION_TYPES_PROPERTY = "taskana.classification.types";
private static final String TASKANA_CLASSIFICATION_CATEGORIES_PROPERTY = "taskana.classification.categories";
// Taskana properties file
protected String propertiesFileName = TASKANA_PROPERTIES;
// Taskana datasource configuration
protected DataSource dataSource;
protected DbSchemaCreator dbScriptRunner;
// Taskana role configuration
protected String rolesSeparator = TASKANA_ROLES_SEPARATOR;
protected Map<TaskanaRole, Set<String>> roleMap = new HashMap<>();
// global switch to enable JAAS based authentication and Taskana
// authorizations
protected boolean securityEnabled = true;
protected boolean useManagedTransactions;
// Properties for the monitor
private boolean germanPublicHolidaysEnabled;
private List<LocalDate> customHolidays;
// List of configured domain names
protected List<String> domains = new ArrayList<String>();
// List of configured classification types
protected List<String> classificationTypes = new ArrayList<String>();
// List of configured classification categories
protected List<String> classificationCategories = new ArrayList<String>();
public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions)
throws SQLException {
this(dataSource, useManagedTransactions, true);
}
public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions,
boolean securityEnabled) throws SQLException {
this(dataSource, useManagedTransactions, securityEnabled, null, null);
}
public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions,
boolean securityEnabled, String propertiesFileName, String rolesSeparator) throws SQLException {
this.useManagedTransactions = useManagedTransactions;
this.securityEnabled = securityEnabled;
if (propertiesFileName != null) {
this.propertiesFileName = propertiesFileName;
}
if (rolesSeparator != null) {
this.rolesSeparator = rolesSeparator;
}
initTaskanaProperties(this.propertiesFileName, this.rolesSeparator);
if (dataSource != null) {
this.dataSource = dataSource;
} else {
// use default In Memory datasource
this.dataSource = createDefaultDataSource();
}
dbScriptRunner = new DbSchemaCreator(this.dataSource);
dbScriptRunner.run();
}
public void initTaskanaProperties(String propertiesFile, String rolesSeparator) {
LOGGER.debug("Reading taskana configuration from {} with role separator {}", propertiesFile, rolesSeparator);
Properties props = readPropertiesFromFile(propertiesFile);
initTaskanaRoles(props, rolesSeparator);
initDomains(props);
initClassificationTypes(props);
initClassificationCategories(props);
}
private void initDomains(Properties props) {
String domainNames = props.getProperty(TASKANA_DOMAINS_PROPERTY);
if (domainNames != null && !domainNames.isEmpty()) {
StringTokenizer st = new StringTokenizer(domainNames, ",");
while (st.hasMoreTokens()) {
domains.add(st.nextToken().trim().toUpperCase());
}
}
LOGGER.debug("Configured domains: {}", domains);
}
private void initClassificationTypes(Properties props) {
String classificationTypesNames = props.getProperty(TASKANA_CLASSIFICATION_TYPES_PROPERTY);
if (classificationTypesNames != null && !classificationTypesNames.isEmpty()) {
StringTokenizer st = new StringTokenizer(classificationTypesNames, ",");
while (st.hasMoreTokens()) {
classificationTypes.add(st.nextToken().trim().toUpperCase());
}
}
LOGGER.debug("Configured domains: {}", domains);
}
private void initClassificationCategories(Properties props) {
String classificationCategoryNames = props.getProperty(TASKANA_CLASSIFICATION_CATEGORIES_PROPERTY);
if (classificationCategoryNames != null && !classificationCategoryNames.isEmpty()) {
StringTokenizer st = new StringTokenizer(classificationCategoryNames, ",");
while (st.hasMoreTokens()) {
classificationCategories.add(st.nextToken().trim().toUpperCase());
}
}
LOGGER.debug("Configured domains: {}", domains);
}
private void initTaskanaRoles(Properties props, String rolesSeparator) {
List<String> validPropertyNames = Arrays.stream(TaskanaRole.values())
.map(TaskanaRole::getPropertyName)
.collect(Collectors.toList());
for (Object obj : props.keySet()) {
String propertyName = ((String) obj);
if (validPropertyNames.contains(propertyName.toLowerCase().trim())) {
String propertyValue = props.getProperty(propertyName);
Set<String> roleMemberSet = new HashSet<>();
StringTokenizer st = new StringTokenizer(propertyValue, rolesSeparator);
while (st.hasMoreTokens()) {
String token = st.nextToken().toLowerCase().trim();
roleMemberSet.add(token);
}
TaskanaRole key = TaskanaRole.fromPropertyName(propertyName);
if (key != null) {
roleMap.put(key, roleMemberSet);
} else {
LOGGER.error("Internal System error when processing role property {}.", propertyName);
throw new SystemException(
"Internal System error when processing role property " + propertyName);
}
}
}
ensureRoleMapIsFullyInitialized();
roleMap.forEach(
(k, v) -> LOGGER.debug("Found Taskana RoleConfig {} : {} ", k, LoggerUtils.setToString(v)));
}
private Properties readPropertiesFromFile(String propertiesFile) {
Properties props = new Properties();
boolean loadFromClasspath = loadFromClasspath(propertiesFile);
try {
if (loadFromClasspath) {
InputStream inputStream = this.getClass().getResourceAsStream(propertiesFile);
if (inputStream == null) {
LOGGER.error("taskana properties file {} was not found on classpath.",
propertiesFile);
} else {
props.load(new InputStreamReader(inputStream));
LOGGER.debug("Role properties were loaded from file {} from classpath.", propertiesFile);
}
} else {
props.load(new FileInputStream(propertiesFile));
LOGGER.debug("Role properties were loaded from file {}.", propertiesFile);
}
} catch (IOException e) {
LOGGER.error("caught IOException when processing properties file {}.", propertiesFile);
throw new SystemException("internal System error when processing properties file " + propertiesFile);
}
return props;
}
private boolean loadFromClasspath(String propertiesFile) {
boolean loadFromClasspath = true;
File f = new File(propertiesFile);
if (f.exists() && !f.isDirectory()) {
loadFromClasspath = false;
}
return loadFromClasspath;
}
private void ensureRoleMapIsFullyInitialized() {
// make sure that roleMap does not return null for any role
Arrays.stream(TaskanaRole.values())
.forEach(role -> roleMap.putIfAbsent(role, new HashSet<>()));
}
public static DataSource createDefaultDataSource() {
LOGGER.info("No datasource is provided. A inmemory db is used: "
+ "'org.h2.Driver', 'jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0;INIT=CREATE SCHEMA IF NOT EXISTS TASKANA', 'sa', 'sa'");
return createDatasource(H2_DRIVER, JDBC_H2_MEM_TASKANA, USER_NAME, USER_PASSWORD);
}
/**
* This method creates the TaskanaEngine without an sqlSessionFactory.
*
* @return the TaskanaEngine
*/
public TaskanaEngine buildTaskanaEngine() {
return TaskanaEngineImpl.createTaskanaEngine(this);
}
/**
* This method creates a PooledDataSource, if the needed properties are provided.
*
* @param driver
* the name of the jdbc driver
* @param jdbcUrl
* the url to which the jdbc driver connects
* @param username
* the user name for database access
* @param password
* the password for database access
* @return DataSource
*/
public static DataSource createDatasource(String driver, String jdbcUrl, String username, String password) {
return new PooledDataSource(driver, jdbcUrl, username, password);
}
public boolean isSecurityEnabled() {
return this.securityEnabled;
}
public DataSource getDatasource() {
return this.dataSource;
}
public boolean getUseManagedTransactions() {
return this.useManagedTransactions;
}
public String getPropertiesFileName() {
return this.propertiesFileName;
}
public void setPropertiesFileName(String propertiesFileName) {
this.propertiesFileName = propertiesFileName;
}
public String getPropertiesSeparator() {
return this.rolesSeparator;
}
public void setPropertiesSeparator(String propertiesSeparator) {
this.rolesSeparator = propertiesSeparator;
}
public boolean isGermanPublicHolidaysEnabled() {
return this.germanPublicHolidaysEnabled;
}
public void setGermanPublicHolidaysEnabled(boolean germanPublicHolidaysEnabled) {
this.germanPublicHolidaysEnabled = germanPublicHolidaysEnabled;
}
public List<LocalDate> getCustomHolidays() {
return customHolidays;
}
public void setCustomHolidays(List<LocalDate> customHolidays) {
this.customHolidays = customHolidays;
}
public Map<TaskanaRole, Set<String>> getRoleMap() {
return roleMap;
}
public void setRoleMap(Map<TaskanaRole, Set<String>> roleMap) {
this.roleMap = roleMap;
}
public List<String> getDomains() {
return domains;
}
public void setDomains(List<String> domains) {
this.domains = domains;
}
public List<String> getClassificationTypes() {
return classificationTypes;
}
public void setClassificationTypes(List<String> classificationTypes) {
this.classificationTypes = classificationTypes;
}
public List<String> getClassificationCategories() {
return classificationCategories;
}
public void setClassificationCategories(List<String> classificationCategories) {
this.classificationCategories = classificationCategories;
}
/**
* Helper method to determine whether all access ids (user Id and group ids) should be used in lower case.
*
* @return true if all access ids should be used in lower case, false otherwise
*/
public static boolean shouldUseLowerCaseForAccessIds() {
return true;
}
}
package pro.taskana.configuration;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.SQLException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import javax.sql.DataSource;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaRole;
import pro.taskana.exceptions.SystemException;
import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.util.LoggerUtils;
/**
* This central class creates the TaskanaEngine and holds all the information about DB and Security.<br>
* Security is enabled by default.
*/
public class TaskanaEngineConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineConfiguration.class);
private static final String USER_NAME = "sa";
private static final String USER_PASSWORD = "sa";
private static final String JDBC_H2_MEM_TASKANA = "jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0;INIT=CREATE SCHEMA IF NOT EXISTS TASKANA";
private static final String H2_DRIVER = "org.h2.Driver";
private static final String TASKANA_PROPERTIES = "/taskana.properties";
private static final String TASKANA_ROLES_SEPARATOR = "|";
private static final String TASKANA_DOMAINS_PROPERTY = "taskana.domains";
private static final String TASKANA_CLASSIFICATION_TYPES_PROPERTY = "taskana.classification.types";
private static final String TASKANA_CLASSIFICATION_CATEGORIES_PROPERTY = "taskana.classification.categories";
// Taskana properties file
protected String propertiesFileName = TASKANA_PROPERTIES;
// Taskana datasource configuration
protected DataSource dataSource;
protected DbSchemaCreator dbScriptRunner;
// Taskana role configuration
protected String rolesSeparator = TASKANA_ROLES_SEPARATOR;
protected Map<TaskanaRole, Set<String>> roleMap = new HashMap<>();
// global switch to enable JAAS based authentication and Taskana
// authorizations
protected boolean securityEnabled = true;
protected boolean useManagedTransactions;
// Properties for the monitor
private boolean germanPublicHolidaysEnabled;
private List<LocalDate> customHolidays;
// List of configured domain names
protected List<String> domains = new ArrayList<String>();
// List of configured classification types
protected List<String> classificationTypes = new ArrayList<String>();
// List of configured classification categories
protected List<String> classificationCategories = new ArrayList<String>();
public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions)
throws SQLException {
this(dataSource, useManagedTransactions, true);
}
public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions,
boolean securityEnabled) throws SQLException {
this(dataSource, useManagedTransactions, securityEnabled, null, null);
}
public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions,
boolean securityEnabled, String propertiesFileName, String rolesSeparator) throws SQLException {
this.useManagedTransactions = useManagedTransactions;
this.securityEnabled = securityEnabled;
if (propertiesFileName != null) {
this.propertiesFileName = propertiesFileName;
}
if (rolesSeparator != null) {
this.rolesSeparator = rolesSeparator;
}
initTaskanaProperties(this.propertiesFileName, this.rolesSeparator);
if (dataSource != null) {
this.dataSource = dataSource;
} else {
// use default In Memory datasource
this.dataSource = createDefaultDataSource();
}
dbScriptRunner = new DbSchemaCreator(this.dataSource);
dbScriptRunner.run();
}
public void initTaskanaProperties(String propertiesFile, String rolesSeparator) {
LOGGER.debug("Reading taskana configuration from {} with role separator {}", propertiesFile, rolesSeparator);
Properties props = readPropertiesFromFile(propertiesFile);
initTaskanaRoles(props, rolesSeparator);
initDomains(props);
initClassificationTypes(props);
initClassificationCategories(props);
}
private void initDomains(Properties props) {
String domainNames = props.getProperty(TASKANA_DOMAINS_PROPERTY);
if (domainNames != null && !domainNames.isEmpty()) {
StringTokenizer st = new StringTokenizer(domainNames, ",");
while (st.hasMoreTokens()) {
domains.add(st.nextToken().trim().toUpperCase());
}
}
LOGGER.debug("Configured domains: {}", domains);
}
private void initClassificationTypes(Properties props) {
String classificationTypesNames = props.getProperty(TASKANA_CLASSIFICATION_TYPES_PROPERTY);
if (classificationTypesNames != null && !classificationTypesNames.isEmpty()) {
StringTokenizer st = new StringTokenizer(classificationTypesNames, ",");
while (st.hasMoreTokens()) {
classificationTypes.add(st.nextToken().trim().toUpperCase());
}
}
LOGGER.debug("Configured domains: {}", domains);
}
private void initClassificationCategories(Properties props) {
String classificationCategoryNames = props.getProperty(TASKANA_CLASSIFICATION_CATEGORIES_PROPERTY);
if (classificationCategoryNames != null && !classificationCategoryNames.isEmpty()) {
StringTokenizer st = new StringTokenizer(classificationCategoryNames, ",");
while (st.hasMoreTokens()) {
classificationCategories.add(st.nextToken().trim().toUpperCase());
}
}
LOGGER.debug("Configured domains: {}", domains);
}
private void initTaskanaRoles(Properties props, String rolesSeparator) {
List<String> validPropertyNames = Arrays.stream(TaskanaRole.values())
.map(TaskanaRole::getPropertyName)
.collect(Collectors.toList());
for (Object obj : props.keySet()) {
String propertyName = ((String) obj);
if (validPropertyNames.contains(propertyName.toLowerCase().trim())) {
String propertyValue = props.getProperty(propertyName);
Set<String> roleMemberSet = new HashSet<>();
StringTokenizer st = new StringTokenizer(propertyValue, rolesSeparator);
while (st.hasMoreTokens()) {
String token = st.nextToken().toLowerCase().trim();
roleMemberSet.add(token);
}
TaskanaRole key = TaskanaRole.fromPropertyName(propertyName);
if (key != null) {
roleMap.put(key, roleMemberSet);
} else {
throw new SystemException(
"Internal System error when processing role property " + propertyName);
}
}
}
ensureRoleMapIsFullyInitialized();
roleMap.forEach(
(k, v) -> LOGGER.debug("Found Taskana RoleConfig {} : {} ", k, LoggerUtils.setToString(v)));
}
private Properties readPropertiesFromFile(String propertiesFile) {
Properties props = new Properties();
boolean loadFromClasspath = loadFromClasspath(propertiesFile);
try {
if (loadFromClasspath) {
InputStream inputStream = this.getClass().getResourceAsStream(propertiesFile);
if (inputStream == null) {
LOGGER.error("taskana properties file {} was not found on classpath.",
propertiesFile);
} else {
props.load(new InputStreamReader(inputStream));
LOGGER.debug("Role properties were loaded from file {} from classpath.", propertiesFile);
}
} else {
props.load(new FileInputStream(propertiesFile));
LOGGER.debug("Role properties were loaded from file {}.", propertiesFile);
}
} catch (IOException e) {
throw new SystemException("internal System error when processing properties file " + propertiesFile,
e.getCause());
}
return props;
}
private boolean loadFromClasspath(String propertiesFile) {
boolean loadFromClasspath = true;
File f = new File(propertiesFile);
if (f.exists() && !f.isDirectory()) {
loadFromClasspath = false;
}
return loadFromClasspath;
}
private void ensureRoleMapIsFullyInitialized() {
// make sure that roleMap does not return null for any role
Arrays.stream(TaskanaRole.values())
.forEach(role -> roleMap.putIfAbsent(role, new HashSet<>()));
}
public static DataSource createDefaultDataSource() {
LOGGER.info("No datasource is provided. A inmemory db is used: "
+ "'org.h2.Driver', 'jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0;INIT=CREATE SCHEMA IF NOT EXISTS TASKANA', 'sa', 'sa'");
return createDatasource(H2_DRIVER, JDBC_H2_MEM_TASKANA, USER_NAME, USER_PASSWORD);
}
/**
* This method creates the TaskanaEngine without an sqlSessionFactory.
*
* @return the TaskanaEngine
*/
public TaskanaEngine buildTaskanaEngine() {
return TaskanaEngineImpl.createTaskanaEngine(this);
}
/**
* This method creates a PooledDataSource, if the needed properties are provided.
*
* @param driver
* the name of the jdbc driver
* @param jdbcUrl
* the url to which the jdbc driver connects
* @param username
* the user name for database access
* @param password
* the password for database access
* @return DataSource
*/
public static DataSource createDatasource(String driver, String jdbcUrl, String username, String password) {
return new PooledDataSource(driver, jdbcUrl, username, password);
}
public boolean isSecurityEnabled() {
return this.securityEnabled;
}
public DataSource getDatasource() {
return this.dataSource;
}
public boolean getUseManagedTransactions() {
return this.useManagedTransactions;
}
public String getPropertiesFileName() {
return this.propertiesFileName;
}
public void setPropertiesFileName(String propertiesFileName) {
this.propertiesFileName = propertiesFileName;
}
public String getPropertiesSeparator() {
return this.rolesSeparator;
}
public void setPropertiesSeparator(String propertiesSeparator) {
this.rolesSeparator = propertiesSeparator;
}
public boolean isGermanPublicHolidaysEnabled() {
return this.germanPublicHolidaysEnabled;
}
public void setGermanPublicHolidaysEnabled(boolean germanPublicHolidaysEnabled) {
this.germanPublicHolidaysEnabled = germanPublicHolidaysEnabled;
}
public List<LocalDate> getCustomHolidays() {
return customHolidays;
}
public void setCustomHolidays(List<LocalDate> customHolidays) {
this.customHolidays = customHolidays;
}
public Map<TaskanaRole, Set<String>> getRoleMap() {
return roleMap;
}
public void setRoleMap(Map<TaskanaRole, Set<String>> roleMap) {
this.roleMap = roleMap;
}
public List<String> getDomains() {
return domains;
}
public void setDomains(List<String> domains) {
this.domains = domains;
}
public List<String> getClassificationTypes() {
return classificationTypes;
}
public void setClassificationTypes(List<String> classificationTypes) {
this.classificationTypes = classificationTypes;
}
public List<String> getClassificationCategories() {
return classificationCategories;
}
public void setClassificationCategories(List<String> classificationCategories) {
this.classificationCategories = classificationCategories;
}
/**
* Helper method to determine whether all access ids (user Id and group ids) should be used in lower case.
*
* @return true if all access ids should be used in lower case, false otherwise
*/
public static boolean shouldUseLowerCaseForAccessIds() {
return true;
}
}

View File

@ -9,7 +9,7 @@ public class AttachmentPersistenceException extends TaskanaException {
private static final long serialVersionUID = 123L;
public AttachmentPersistenceException(String attachmentId) {
super("AttachmentId=" + attachmentId);
public AttachmentPersistenceException(String msg, Throwable cause) {
super(msg, cause);
}
}

View File

@ -9,5 +9,9 @@ public class ClassificationInUseException extends TaskanaException {
super(msg);
}
public ClassificationInUseException(String msg, Throwable cause) {
super(msg, cause);
}
private static final long serialVersionUID = 1L;
}

View File

@ -11,5 +11,9 @@ public class InvalidArgumentException extends TaskanaException {
super(msg);
}
public InvalidArgumentException(String msg, Throwable cause) {
super(msg, cause);
}
private static final long serialVersionUID = 1L;
}

View File

@ -9,6 +9,10 @@ public class NotAuthorizedToQueryWorkbasketException extends TaskanaRuntimeExcep
super(msg);
}
public NotAuthorizedToQueryWorkbasketException(String msg, Throwable cause) {
super(msg, cause);
}
private static final long serialVersionUID = 1L;
}

View File

@ -9,5 +9,9 @@ public class SystemException extends TaskanaRuntimeException {
super(msg);
}
public SystemException(String msg, Throwable cause) {
super(msg, cause);
}
private static final long serialVersionUID = 1L;
}

View File

@ -237,7 +237,8 @@ public class ClassificationServiceImpl implements ClassificationService {
try {
Duration.parse(classification.getServiceLevel());
} catch (Exception e) {
throw new InvalidArgumentException("Invalid service level. Please use the format defined by ISO 8601");
throw new InvalidArgumentException("Invalid service level. Please use the format defined by ISO 8601",
e.getCause());
}
}
@ -278,7 +279,6 @@ public class ClassificationServiceImpl implements ClassificationService {
taskanaEngine.openConnection();
result = classificationMapper.findById(id);
if (result == null) {
LOGGER.error("Classification for id {} was not found. Throwing ClassificationNotFoundException", id);
throw new ClassificationNotFoundException(id, "Classification for id " + id + " was not found");
}
return result;
@ -303,9 +303,6 @@ public class ClassificationServiceImpl implements ClassificationService {
if (result == null) {
result = classificationMapper.findByKeyAndDomain(key, "");
if (result == null) {
LOGGER.error(
"Classification for key {} and domain {} was not found. Throwing ClassificationNotFoundException",
key, domain);
throw new ClassificationNotFoundException(key, domain,
"Classification for key " + key + " was not found");
}
@ -400,7 +397,8 @@ public class ClassificationServiceImpl implements ClassificationService {
} catch (PersistenceException e) {
if (isReferentialIntegrityConstraintViolation(e)) {
throw new ClassificationInUseException("The classification " + classificationId
+ " is in use and cannot be deleted. There are either tasks or attachments associated with the classification.");
+ " is in use and cannot be deleted. There are either tasks or attachments associated with the classification.",
e.getCause());
}
}
} finally {

View File

@ -332,7 +332,8 @@ public class TaskImpl implements Task {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
"Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16");
"Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16",
e.getCause());
}
switch (num) {
@ -382,7 +383,8 @@ public class TaskImpl implements Task {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
"Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16");
"Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16",
e.getCause());
}
switch (num) {

View File

@ -400,7 +400,8 @@ public class TaskQueryImpl implements TaskQuery {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
"Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16");
"Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16",
e.getCause());
}
switch (num) {
@ -467,7 +468,8 @@ public class TaskQueryImpl implements TaskQuery {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
"Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16");
"Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16",
e.getCause());
}
switch (num) {
@ -851,7 +853,7 @@ public class TaskQueryImpl implements TaskQuery {
}
}
} catch (NotAuthorizedException e) {
throw new NotAuthorizedToQueryWorkbasketException(e.getMessage());
throw new NotAuthorizedToQueryWorkbasketException(e.getMessage(), e.getCause());
}
}

View File

@ -38,7 +38,6 @@ import pro.taskana.exceptions.ConcurrencyException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidOwnerException;
import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.SystemException;
import pro.taskana.exceptions.TaskAlreadyExistException;
@ -78,8 +77,7 @@ public class TaskServiceImpl implements TaskService {
this.converter = DaysToWorkingDaysConverter
.initialize(Collections.singletonList(new TimeIntervalColumnHeader(0)), Instant.now());
} catch (InvalidArgumentException e) {
LOGGER.error("could not initialize DaysToWorkingDaysConverter. Caught exception " + e);
throw new SystemException("Internal error. Cannot initialize DaysToWorkingDaysConverter");
throw new SystemException("Internal error. Cannot initialize DaysToWorkingDaysConverter", e.getCause());
}
this.taskanaEngine = (TaskanaEngineImpl) taskanaEngine;
this.taskMapper = taskMapper;
@ -363,8 +361,6 @@ public class TaskServiceImpl implements TaskService {
.list();
if (workbaskets.isEmpty()) {
String currentUser = CurrentUserContext.getUserid();
LOGGER.error("The current user {} has no read permission for workbasket {}.", currentUser,
workbasketId);
throw new NotAuthorizedException(
"The current user " + currentUser + " has no read permission for workbasket " + workbasketId);
} else {
@ -388,7 +384,6 @@ public class TaskServiceImpl implements TaskService {
.findFirst()
.orElse(null);
if (classification == null) {
LOGGER.error("Could not find a Classification for task {} ", resultTask);
throw new SystemException(
"Could not find a Classification for task " + resultTask.getId());
}
@ -396,7 +391,6 @@ public class TaskServiceImpl implements TaskService {
resultTask.setClassificationSummary(classification);
return resultTask;
} else {
LOGGER.warn("Method getTaskById() didn't find task with id {}. Throwing TaskNotFoundException", id);
throw new TaskNotFoundException(id, "Task with id " + id + " was not found");
}
} finally {
@ -407,8 +401,7 @@ public class TaskServiceImpl implements TaskService {
@Override
public Task transfer(String taskId, String destinationWorkbasketId)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
InvalidStateException {
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidStateException {
LOGGER.debug("entry to transfer(taskId = {}, destinationWorkbasketId = {})", taskId, destinationWorkbasketId);
TaskImpl task = null;
try {
@ -447,8 +440,7 @@ public class TaskServiceImpl implements TaskService {
@Override
public Task transfer(String taskId, String destinationWorkbasketKey, String domain)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
InvalidStateException {
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidStateException {
LOGGER.debug("entry to transfer(taskId = {}, destinationWorkbasketKey = {}, domain = {})", taskId,
destinationWorkbasketKey, domain);
TaskImpl task = null;
@ -652,8 +644,7 @@ public class TaskServiceImpl implements TaskService {
@Override
public Task updateTask(Task task)
throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException, WorkbasketNotFoundException,
ClassificationNotFoundException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException {
ClassificationNotFoundException, NotAuthorizedException, AttachmentPersistenceException {
String userId = CurrentUserContext.getUserid();
LOGGER.debug("entry to updateTask(task = {}, userId = {})", task, userId);
TaskImpl newTaskImpl = (TaskImpl) task;
@ -778,11 +769,9 @@ public class TaskServiceImpl implements TaskService {
.findFirst()
.orElse(null);
if (aClassification == null) {
LOGGER.error("Didnt find a Classification for task ");
throw new SystemException(
"Did not find a Classification for task (Id=" + task.getTaskId() + ",classification="
+ task.getClassificationSummary().getId()
+ ")");
+ task.getClassificationSummary().getId() + ")");
}
// set the classification on the task object
task.setClassificationSummary(aClassification);
@ -908,7 +897,6 @@ public class TaskServiceImpl implements TaskService {
.findFirst()
.orElse(null);
if (aClassification == null) {
LOGGER.error("Could not find a Classification for attachment {}.", att);
throw new SystemException("Could not find a Classification for attachment " + att);
}
att.setClassificationSummary(aClassification);
@ -930,7 +918,6 @@ public class TaskServiceImpl implements TaskService {
.orElse(null);
if (aClassification == null) {
LOGGER.error("Could not find a Classification for attachment {}.", att);
throw new SystemException("Could not find a Classification for attachment " + att);
}
att.setClassificationSummary(aClassification);
@ -1052,8 +1039,6 @@ public class TaskServiceImpl implements TaskService {
}
if (customFieldsToUpdate == null || customFieldsToUpdate.isEmpty()) {
LOGGER.warn(
"The customFieldsToUpdate argument to updateTasks must not be empty. Throwing InvalidArgumentException.");
throw new InvalidArgumentException("The customFieldsToUpdate argument to updateTasks must not be empty.");
}
validateObjectReference(selectionCriteria, "ObjectReference", "updateTasks call");
@ -1070,7 +1055,6 @@ public class TaskServiceImpl implements TaskService {
for (Map.Entry<String, String> entry : customFieldsToUpdate.entrySet()) {
String key = entry.getKey();
if (!allowedKeys.contains(key)) {
LOGGER.warn("The customFieldsToUpdate argument to updateTasks contains invalid key {}.", key);
throw new InvalidArgumentException(
"The customFieldsToUpdate argument to updateTasks contains invalid key " + key);
} else {
@ -1165,8 +1149,7 @@ public class TaskServiceImpl implements TaskService {
private void standardUpdateActions(TaskImpl oldTaskImpl, TaskImpl newTaskImpl,
PrioDurationHolder prioDurationFromAttachments)
throws InvalidArgumentException, ConcurrencyException, WorkbasketNotFoundException,
ClassificationNotFoundException {
throws InvalidArgumentException, ConcurrencyException, ClassificationNotFoundException {
validateObjectReference(newTaskImpl.getPrimaryObjRef(), "primary ObjectReference", "Task");
if (oldTaskImpl.getModified() != null && !oldTaskImpl.getModified().equals(newTaskImpl.getModified())
|| oldTaskImpl.getClaimed() != null && !oldTaskImpl.getClaimed().equals(newTaskImpl.getClaimed())
@ -1312,10 +1295,10 @@ public class TaskServiceImpl implements TaskService {
newTaskImpl.getId(),
attachmentImpl);
} catch (PersistenceException e) {
LOGGER.error(
"TaskService.updateTask() for TaskId={} can NOT INSERT the current Attachment, because it was added fored multiple times and wasn´t persisted before. ID={}",
newTaskImpl.getId(), attachmentImpl.getId());
throw new AttachmentPersistenceException(attachmentImpl.getId());
throw new AttachmentPersistenceException(
"Cannot insert the Attachement " + attachmentImpl.getId() + " for Task "
+ newTaskImpl.getId() + " because it already exists.",
e.getCause());
}
}
@ -1412,7 +1395,7 @@ public class TaskServiceImpl implements TaskService {
}
BulkOperationResults<String, Exception> classificationChanged(String taskId, String classificationId)
throws TaskNotFoundException, ClassificationNotFoundException {
throws ClassificationNotFoundException {
LOGGER.debug("entry to classificationChanged(taskId = {} , classificationId = {} )", taskId, classificationId);
TaskImpl task = null;
BulkOperationResults<String, Exception> bulkLog = new BulkOperationResults<>();

View File

@ -372,7 +372,8 @@ public class TaskSummaryImpl implements TaskSummary {
num = Integer.parseInt(number);
} catch (NumberFormatException e) {
throw new InvalidArgumentException(
"Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16");
"Argument '" + number + "' to getCustomAttribute cannot be converted to a number between 1 and 16",
e.getCause());
}
switch (num) {

View File

@ -1,400 +1,394 @@
package pro.taskana.impl;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.ibatis.session.SqlSessionManager;
import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.ClassificationService;
import pro.taskana.TaskMonitorService;
import pro.taskana.TaskService;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaRole;
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;
import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.mappings.AttachmentMapper;
import pro.taskana.mappings.ClassificationMapper;
import pro.taskana.mappings.DistributionTargetMapper;
import pro.taskana.mappings.JobMapper;
import pro.taskana.mappings.ObjectReferenceMapper;
import pro.taskana.mappings.QueryMapper;
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.
*/
public class TaskanaEngineImpl implements TaskanaEngine {
private static final String DEFAULT = "default";
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineImpl.class);
protected static ThreadLocal<Deque<SqlSessionManager>> sessionStack = new ThreadLocal<>();
protected TaskanaEngineConfiguration taskanaEngineConfiguration;
protected TransactionFactory transactionFactory;
protected SqlSessionManager sessionManager;
protected SqlSessionFactory sessionFactory;
protected ConnectionManagementMode mode = ConnectionManagementMode.PARTICIPATE;
protected java.sql.Connection connection = null;
protected TaskanaEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration) {
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
createTransactionFactory(taskanaEngineConfiguration.getUseManagedTransactions());
this.sessionManager = createSqlSessionManager();
}
public static TaskanaEngine createTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration) {
return new TaskanaEngineImpl(taskanaEngineConfiguration);
}
/**
* With sessionStack, we maintain a Stack of SqlSessionManager objects on a per thread basis. SqlSessionManager is
* the MyBatis object that wraps database connections. The purpose of this stack is to keep track of nested calls.
* Each external API call is wrapped into taskanaEngineImpl.openConnection(); .....
* taskanaEngineImpl.returnConnection(); calls. In order to avoid duplicate opening / closing of connections, we use
* the sessionStack in the following way: Each time, an openConnection call is received, we push the current
* sessionManager onto the stack. On the first call to openConnection, we call sessionManager.startManagedSession()
* to open a database connection. On each call to returnConnection() we pop one instance of sessionManager from the
* stack. When the stack becomes empty, we close the database connection by calling sessionManager.close()
*
* @return Stack of SqlSessionManager
*/
protected static Deque<SqlSessionManager> getSessionStack() {
Deque<SqlSessionManager> stack = sessionStack.get();
if (stack == null) {
stack = new ArrayDeque<>();
sessionStack.set(stack);
}
return stack;
}
protected static SqlSessionManager getSessionFromStack() {
Deque<SqlSessionManager> stack = getSessionStack();
if (stack.isEmpty()) {
return null;
}
return stack.peek();
}
protected static void pushSessionToStack(SqlSessionManager session) {
getSessionStack().push(session);
}
protected static void popSessionFromStack() {
Deque<SqlSessionManager> stack = getSessionStack();
if (!stack.isEmpty()) {
stack.pop();
}
}
public static boolean isDb2(String dbProductName) {
return dbProductName.contains("DB2");
}
public static boolean isH2(String databaseProductName) {
return databaseProductName.contains("H2");
}
public static boolean isPostgreSQL(String databaseProductName) {
return databaseProductName.equals("PostgreSQL");
}
@Override
public TaskService getTaskService() {
SqlSession session = this.sessionManager;
return new TaskServiceImpl(this, session.getMapper(TaskMapper.class),
session.getMapper(AttachmentMapper.class));
}
@Override
public TaskMonitorService getTaskMonitorService() {
SqlSession session = this.sessionManager;
return new TaskMonitorServiceImpl(this,
session.getMapper(TaskMonitorMapper.class));
}
@Override
public WorkbasketService getWorkbasketService() {
SqlSession session = this.sessionManager;
return new WorkbasketServiceImpl(this,
session.getMapper(WorkbasketMapper.class),
session.getMapper(DistributionTargetMapper.class),
session.getMapper(WorkbasketAccessMapper.class));
}
@Override
public ClassificationService getClassificationService() {
SqlSession session = this.sessionManager;
return new ClassificationServiceImpl(this, session.getMapper(ClassificationMapper.class),
session.getMapper(TaskMapper.class));
}
@Override
public TaskanaEngineConfiguration getConfiguration() {
return this.taskanaEngineConfiguration;
}
/**
* sets the connection management mode.
*
* @param mode
* - the connection management mode Valid values are:
* <ul>
* <li>PARTICIPATE - taskana participates in global transaction. This is the default mode.</li>
* <li>AUTOCOMMIT - taskana commits each API call separately</li>
* <li>EXPLICIT - commit processing is managed explicitly by the client</li>
* </ul>
*/
@Override
public void setConnectionManagementMode(ConnectionManagementMode mode) {
if (this.mode == ConnectionManagementMode.EXPLICIT && connection != null
&& mode != ConnectionManagementMode.EXPLICIT) {
if (sessionManager.isManagedSessionStarted()) {
sessionManager.close();
}
connection = null;
}
this.mode = mode;
}
/**
* Set the database connection to be used by taskana. If this Api is called, taskana uses the connection passed by
* the client for database access in all subsequent API calls until the client resets this connection. Control over
* commit and rollback is the responsibility of the client. In order to close the connection, the client can call
* TaskanaEngine.closeConnection() or TaskanaEngine.setConnection(null). Both calls have the same effect.
*
* @param connection
* The connection that passed into TaskanaEngine
*/
@Override
public void setConnection(java.sql.Connection connection) throws SQLException {
if (connection != null) {
this.connection = connection;
// disabling auto commit for passed connection in order to gain full control over the connection management
connection.setAutoCommit(false);
mode = ConnectionManagementMode.EXPLICIT;
sessionManager.startManagedSession(connection);
} else if (this.connection != null) {
closeConnection();
}
}
/**
* closes the connection to the database in mode EXPLICIT. In mode EXPLICIT, closes the client's connection, sets it
* to null and switches to mode PARTICIPATE Has the same effect as setConnection(null)
*/
@Override
public void closeConnection() {
if (this.mode == ConnectionManagementMode.EXPLICIT) {
this.connection = null;
if (sessionManager.isManagedSessionStarted()) {
sessionManager.close();
}
mode = ConnectionManagementMode.PARTICIPATE;
}
}
/**
* Open the connection to the database. to be called at the begin of each Api call that accesses the database
*/
void openConnection() {
initSqlSession();
if (mode != ConnectionManagementMode.EXPLICIT) {
pushSessionToStack(this.sessionManager);
}
}
/**
* Initializes the SqlSessionManager.
*/
void initSqlSession() {
if (mode == ConnectionManagementMode.EXPLICIT && this.connection == null) {
throw new ConnectionNotSetException();
} else if (mode != ConnectionManagementMode.EXPLICIT && !this.sessionManager.isManagedSessionStarted()) {
this.sessionManager.startManagedSession();
}
}
/**
* Returns the database connection into the pool. In the case of nested calls, simply pops the latest session from
* the session stack. Closes the connection if the session stack is empty. In mode AUTOCOMMIT commits before the
* connection is closed. To be called at the end of each Api call that accesses the database
*/
void returnConnection() {
if (this.mode != ConnectionManagementMode.EXPLICIT) {
popSessionFromStack();
if (getSessionStack().isEmpty()
&& this.sessionManager != null && this.sessionManager.isManagedSessionStarted()) {
if (this.mode == ConnectionManagementMode.AUTOCOMMIT) {
try {
this.sessionManager.commit();
} catch (Exception e) {
LOGGER.error("closeSession(): Tried to Autocommit and caught exception" + e);
throw new AutocommitFailedException(e);
}
}
this.sessionManager.close();
}
}
}
/**
* retrieve the SqlSession used by taskana.
*
* @return the myBatis SqlSession object used by taskana
*/
SqlSession getSqlSession() {
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
*/
@Override
public void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException {
if (isUserInRole(roles)) {
return;
} else {
if (LOGGER.isErrorEnabled()) {
String accessIds = LoggerUtils.listToString(CurrentUserContext.getAccessIds());
String rolesAsString = Arrays.toString(roles);
LOGGER.error("Throwing NotAuthorizedException because accessIds {} are not member of roles {}",
accessIds,
rolesAsString);
}
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
*/
@Override
public 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(getConfiguration().getRoleMap().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.
*
* @return a {@link SqlSessionFactory}
*/
protected SqlSessionManager createSqlSessionManager() {
Environment environment = new Environment(DEFAULT, this.transactionFactory,
taskanaEngineConfiguration.getDatasource());
Configuration configuration = new Configuration(environment);
// set databaseId
String databaseProductName;
try (Connection con = taskanaEngineConfiguration.getDatasource().getConnection()) {
databaseProductName = con.getMetaData().getDatabaseProductName();
if (isDb2(databaseProductName)) {
configuration.setDatabaseId("db2");
} else if (isH2(databaseProductName)) {
configuration.setDatabaseId("h2");
} else if (isPostgreSQL(databaseProductName)) {
configuration.setDatabaseId("postgres");
} else {
LOGGER.error(
"Method createSqlSessionManager() didn't find database with name {}. Throwing UnsupportedDatabaseException",
databaseProductName);
throw new UnsupportedDatabaseException(databaseProductName);
}
} catch (SQLException e) {
LOGGER.error(
"Method createSqlSessionManager() could not open a connection to the database. No databaseId has been set.",
e);
throw new SystemException(
"Method createSqlSessionManager() could not open a connection to the database. No databaseId has been set.");
}
// add mappers
configuration.addMapper(TaskMapper.class);
configuration.addMapper(TaskMonitorMapper.class);
configuration.addMapper(WorkbasketMapper.class);
configuration.addMapper(DistributionTargetMapper.class);
configuration.addMapper(ClassificationMapper.class);
configuration.addMapper(WorkbasketAccessMapper.class);
configuration.addMapper(ObjectReferenceMapper.class);
configuration.addMapper(QueryMapper.class);
configuration.addMapper(AttachmentMapper.class);
configuration.addMapper(JobMapper.class);
configuration.getTypeHandlerRegistry().register(MapTypeHandler.class);
SqlSessionFactory localSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
return SqlSessionManager.newInstance(localSessionFactory);
}
/**
* creates the MyBatis transaction factory.
*
* @param useManagedTransactions
*/
private void createTransactionFactory(boolean useManagedTransactions) {
if (useManagedTransactions) {
this.transactionFactory = new ManagedTransactionFactory();
} else {
this.transactionFactory = new JdbcTransactionFactory();
}
}
/**
* Returns true if the given domain does exist in the configuration.
*
* @param domain
* the domain specified in the configuration
* @return <code>true</code> if the domain exists
*/
public boolean domainExists(String domain) {
return getConfiguration().getDomains().contains(domain);
}
}
package pro.taskana.impl;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.ibatis.session.SqlSessionManager;
import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.ClassificationService;
import pro.taskana.TaskMonitorService;
import pro.taskana.TaskService;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaRole;
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;
import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.mappings.AttachmentMapper;
import pro.taskana.mappings.ClassificationMapper;
import pro.taskana.mappings.DistributionTargetMapper;
import pro.taskana.mappings.JobMapper;
import pro.taskana.mappings.ObjectReferenceMapper;
import pro.taskana.mappings.QueryMapper;
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.
*/
public class TaskanaEngineImpl implements TaskanaEngine {
private static final String DEFAULT = "default";
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineImpl.class);
protected static ThreadLocal<Deque<SqlSessionManager>> sessionStack = new ThreadLocal<>();
protected TaskanaEngineConfiguration taskanaEngineConfiguration;
protected TransactionFactory transactionFactory;
protected SqlSessionManager sessionManager;
protected SqlSessionFactory sessionFactory;
protected ConnectionManagementMode mode = ConnectionManagementMode.PARTICIPATE;
protected java.sql.Connection connection = null;
protected TaskanaEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration) {
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
createTransactionFactory(taskanaEngineConfiguration.getUseManagedTransactions());
this.sessionManager = createSqlSessionManager();
}
public static TaskanaEngine createTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration) {
return new TaskanaEngineImpl(taskanaEngineConfiguration);
}
/**
* With sessionStack, we maintain a Stack of SqlSessionManager objects on a per thread basis. SqlSessionManager is
* the MyBatis object that wraps database connections. The purpose of this stack is to keep track of nested calls.
* Each external API call is wrapped into taskanaEngineImpl.openConnection(); .....
* taskanaEngineImpl.returnConnection(); calls. In order to avoid duplicate opening / closing of connections, we use
* the sessionStack in the following way: Each time, an openConnection call is received, we push the current
* sessionManager onto the stack. On the first call to openConnection, we call sessionManager.startManagedSession()
* to open a database connection. On each call to returnConnection() we pop one instance of sessionManager from the
* stack. When the stack becomes empty, we close the database connection by calling sessionManager.close()
*
* @return Stack of SqlSessionManager
*/
protected static Deque<SqlSessionManager> getSessionStack() {
Deque<SqlSessionManager> stack = sessionStack.get();
if (stack == null) {
stack = new ArrayDeque<>();
sessionStack.set(stack);
}
return stack;
}
protected static SqlSessionManager getSessionFromStack() {
Deque<SqlSessionManager> stack = getSessionStack();
if (stack.isEmpty()) {
return null;
}
return stack.peek();
}
protected static void pushSessionToStack(SqlSessionManager session) {
getSessionStack().push(session);
}
protected static void popSessionFromStack() {
Deque<SqlSessionManager> stack = getSessionStack();
if (!stack.isEmpty()) {
stack.pop();
}
}
public static boolean isDb2(String dbProductName) {
return dbProductName.contains("DB2");
}
public static boolean isH2(String databaseProductName) {
return databaseProductName.contains("H2");
}
public static boolean isPostgreSQL(String databaseProductName) {
return databaseProductName.equals("PostgreSQL");
}
@Override
public TaskService getTaskService() {
SqlSession session = this.sessionManager;
return new TaskServiceImpl(this, session.getMapper(TaskMapper.class),
session.getMapper(AttachmentMapper.class));
}
@Override
public TaskMonitorService getTaskMonitorService() {
SqlSession session = this.sessionManager;
return new TaskMonitorServiceImpl(this,
session.getMapper(TaskMonitorMapper.class));
}
@Override
public WorkbasketService getWorkbasketService() {
SqlSession session = this.sessionManager;
return new WorkbasketServiceImpl(this,
session.getMapper(WorkbasketMapper.class),
session.getMapper(DistributionTargetMapper.class),
session.getMapper(WorkbasketAccessMapper.class));
}
@Override
public ClassificationService getClassificationService() {
SqlSession session = this.sessionManager;
return new ClassificationServiceImpl(this, session.getMapper(ClassificationMapper.class),
session.getMapper(TaskMapper.class));
}
@Override
public TaskanaEngineConfiguration getConfiguration() {
return this.taskanaEngineConfiguration;
}
/**
* sets the connection management mode.
*
* @param mode
* - the connection management mode Valid values are:
* <ul>
* <li>PARTICIPATE - taskana participates in global transaction. This is the default mode.</li>
* <li>AUTOCOMMIT - taskana commits each API call separately</li>
* <li>EXPLICIT - commit processing is managed explicitly by the client</li>
* </ul>
*/
@Override
public void setConnectionManagementMode(ConnectionManagementMode mode) {
if (this.mode == ConnectionManagementMode.EXPLICIT && connection != null
&& mode != ConnectionManagementMode.EXPLICIT) {
if (sessionManager.isManagedSessionStarted()) {
sessionManager.close();
}
connection = null;
}
this.mode = mode;
}
/**
* Set the database connection to be used by taskana. If this Api is called, taskana uses the connection passed by
* the client for database access in all subsequent API calls until the client resets this connection. Control over
* commit and rollback is the responsibility of the client. In order to close the connection, the client can call
* TaskanaEngine.closeConnection() or TaskanaEngine.setConnection(null). Both calls have the same effect.
*
* @param connection
* The connection that passed into TaskanaEngine
*/
@Override
public void setConnection(java.sql.Connection connection) throws SQLException {
if (connection != null) {
this.connection = connection;
// disabling auto commit for passed connection in order to gain full control over the connection management
connection.setAutoCommit(false);
mode = ConnectionManagementMode.EXPLICIT;
sessionManager.startManagedSession(connection);
} else if (this.connection != null) {
closeConnection();
}
}
/**
* closes the connection to the database in mode EXPLICIT. In mode EXPLICIT, closes the client's connection, sets it
* to null and switches to mode PARTICIPATE Has the same effect as setConnection(null)
*/
@Override
public void closeConnection() {
if (this.mode == ConnectionManagementMode.EXPLICIT) {
this.connection = null;
if (sessionManager.isManagedSessionStarted()) {
sessionManager.close();
}
mode = ConnectionManagementMode.PARTICIPATE;
}
}
/**
* Open the connection to the database. to be called at the begin of each Api call that accesses the database
*/
void openConnection() {
initSqlSession();
if (mode != ConnectionManagementMode.EXPLICIT) {
pushSessionToStack(this.sessionManager);
}
}
/**
* Initializes the SqlSessionManager.
*/
void initSqlSession() {
if (mode == ConnectionManagementMode.EXPLICIT && this.connection == null) {
throw new ConnectionNotSetException();
} else if (mode != ConnectionManagementMode.EXPLICIT && !this.sessionManager.isManagedSessionStarted()) {
this.sessionManager.startManagedSession();
}
}
/**
* Returns the database connection into the pool. In the case of nested calls, simply pops the latest session from
* the session stack. Closes the connection if the session stack is empty. In mode AUTOCOMMIT commits before the
* connection is closed. To be called at the end of each Api call that accesses the database
*/
void returnConnection() {
if (this.mode != ConnectionManagementMode.EXPLICIT) {
popSessionFromStack();
if (getSessionStack().isEmpty()
&& this.sessionManager != null && this.sessionManager.isManagedSessionStarted()) {
if (this.mode == ConnectionManagementMode.AUTOCOMMIT) {
try {
this.sessionManager.commit();
} catch (Exception e) {
throw new AutocommitFailedException(e.getCause());
}
}
this.sessionManager.close();
}
}
}
/**
* retrieve the SqlSession used by taskana.
*
* @return the myBatis SqlSession object used by taskana
*/
SqlSession getSqlSession() {
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
*/
@Override
public void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException {
if (isUserInRole(roles)) {
return;
} else {
if (LOGGER.isErrorEnabled()) {
String accessIds = LoggerUtils.listToString(CurrentUserContext.getAccessIds());
String rolesAsString = Arrays.toString(roles);
LOGGER.error("Throwing NotAuthorizedException because accessIds {} are not member of roles {}",
accessIds,
rolesAsString);
}
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
*/
@Override
public 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(getConfiguration().getRoleMap().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.
*
* @return a {@link SqlSessionFactory}
*/
protected SqlSessionManager createSqlSessionManager() {
Environment environment = new Environment(DEFAULT, this.transactionFactory,
taskanaEngineConfiguration.getDatasource());
Configuration configuration = new Configuration(environment);
// set databaseId
String databaseProductName;
try (Connection con = taskanaEngineConfiguration.getDatasource().getConnection()) {
databaseProductName = con.getMetaData().getDatabaseProductName();
if (isDb2(databaseProductName)) {
configuration.setDatabaseId("db2");
} else if (isH2(databaseProductName)) {
configuration.setDatabaseId("h2");
} else if (isPostgreSQL(databaseProductName)) {
configuration.setDatabaseId("postgres");
} else {
throw new UnsupportedDatabaseException(databaseProductName);
}
} catch (SQLException e) {
throw new SystemException(
"Method createSqlSessionManager() could not open a connection to the database. No databaseId has been set.",
e.getCause());
}
// add mappers
configuration.addMapper(TaskMapper.class);
configuration.addMapper(TaskMonitorMapper.class);
configuration.addMapper(WorkbasketMapper.class);
configuration.addMapper(DistributionTargetMapper.class);
configuration.addMapper(ClassificationMapper.class);
configuration.addMapper(WorkbasketAccessMapper.class);
configuration.addMapper(ObjectReferenceMapper.class);
configuration.addMapper(QueryMapper.class);
configuration.addMapper(AttachmentMapper.class);
configuration.addMapper(JobMapper.class);
configuration.getTypeHandlerRegistry().register(MapTypeHandler.class);
SqlSessionFactory localSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
return SqlSessionManager.newInstance(localSessionFactory);
}
/**
* creates the MyBatis transaction factory.
*
* @param useManagedTransactions
*/
private void createTransactionFactory(boolean useManagedTransactions) {
if (useManagedTransactions) {
this.transactionFactory = new ManagedTransactionFactory();
} else {
this.transactionFactory = new JdbcTransactionFactory();
}
}
/**
* Returns true if the given domain does exist in the configuration.
*
* @param domain
* the domain specified in the configuration
* @return <code>true</code> if the domain exists
*/
public boolean domainExists(String domain) {
return getConfiguration().getDomains().contains(domain);
}
}

View File

@ -67,9 +67,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
taskanaEngine.openConnection();
result = workbasketMapper.findById(workbasketId);
if (result == null) {
LOGGER.error(
"Method getWorkbasket() didn't find workbasket with ID {}. Throwing WorkbasketNotFoundException",
workbasketId);
throw new WorkbasketNotFoundException(workbasketId,
"Workbasket with id " + workbasketId + " was not found.");
}
@ -92,9 +89,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
taskanaEngine.openConnection();
result = workbasketMapper.findByKeyAndDomain(workbasketKey, domain);
if (result == null) {
LOGGER.error(
"Method getWorkbasketByKey() didn't find workbasket with key {}. Throwing WorkbasketNotFoundException",
workbasketKey);
throw new WorkbasketNotFoundException(workbasketKey, domain,
"Workbasket with key " + workbasketKey + " and domain " + domain + " was not found.");
}
@ -150,9 +144,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
Workbasket existingWorkbasket = workbasketMapper.findByKeyAndDomain(newWorkbasket.getKey(),
newWorkbasket.getDomain());
if (existingWorkbasket != null) {
LOGGER.error(
"createWorkbasket failed because Workbasket with key {} and domain {} already exists. Throwing WorkbasketAlreadyExistsException.",
newWorkbasket.getKey(), newWorkbasket.getDomain());
throw new WorkbasketAlreadyExistException(existingWorkbasket);
}
@ -172,7 +163,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override
public Workbasket updateWorkbasket(Workbasket workbasketToUpdate)
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
throws NotAuthorizedException {
LOGGER.debug("entry to updateWorkbasket(workbasket)", workbasketToUpdate);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
@ -208,8 +199,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
accessItem.setId(IdGenerator.generateWithPrefix(ID_PREFIX_WORKBASKET_AUTHORIZATION));
if (workbasketAccessItem.getId() == null || workbasketAccessItem.getAccessId() == null
|| workbasketAccessItem.getWorkbasketId() == null) {
LOGGER.error(
"createWorkbasketAccessItem failed because id, accessId or workbasketId is null. Throwing InvalidArgumentException.");
throw new InvalidArgumentException(
"Checking the preconditions of the current WorkbasketAccessItem failed. WorkbasketAccessItem="
+ workbasketAccessItem.toString());
@ -243,16 +232,10 @@ public class WorkbasketServiceImpl implements WorkbasketService {
for (WorkbasketAccessItem workbasketAccessItem : wbAccessItems) {
WorkbasketAccessItemImpl wbAccessItemImpl = (WorkbasketAccessItemImpl) workbasketAccessItem;
if (wbAccessItemImpl.getWorkbasketId() == null) {
LOGGER.error(
"setWorkbasketAccessItem failed because WorkbasketAccessItem {} has a null workbasketId. Throwing InvalidArgumentException.",
workbasketAccessItem);
throw new InvalidArgumentException(
"Checking the preconditions of the current WorkbasketAccessItem failed - WBID is NULL. WorkbasketAccessItem="
+ workbasketAccessItem.toString());
} else if (!wbAccessItemImpl.getWorkbasketId().equals(workbasketId)) {
LOGGER.error(
"setWorkbasketAccessItem failed because WorkbasketAccessItem {} does not refer to workbasket {}. Throwing InvalidArgumentException.",
workbasketAccessItem, workbasketId);
throw new InvalidArgumentException(
"Checking the preconditions of the current WorkbasketAccessItem failed - the WBID does not match. Target-WBID='"
+ workbasketId + "' WorkbasketAccessItem="
@ -311,8 +294,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
taskanaEngine.openConnection();
if (workbasketMapper.findById(workbasketId) == null) {
LOGGER.error("Throwing WorkbasketNotFoundException because workbasket with id {} does not exist",
workbasketId);
throw new WorkbasketNotFoundException(workbasketId,
"Workbasket with id " + workbasketId + " was not found.");
}
@ -326,9 +307,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
WorkbasketAccessItem wbAcc = workbasketAccessMapper.findByWorkbasketAndAccessId(workbasketId,
accessIds);
if (wbAcc == null) {
LOGGER.error(
"AccessIds {} do not have permission {} on workbasket with id {}. Throwing NotAuthorizedException.",
LoggerUtils.listToString(accessIds), Arrays.toString(requestedPermissions), workbasketId);
throw new NotAuthorizedException(
"Not authorized. Permission '" + Arrays.toString(requestedPermissions) + "' on workbasket '"
+ workbasketId
@ -340,9 +318,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
for (WorkbasketPermission perm : requestedPermissions) {
if (!grantedPermissions.contains(perm)) {
isAuthorized = false;
LOGGER.error(
"AccessIds {} do not have permission {} on workbasket with id {}. Throwing NotAuthorizedException.",
LoggerUtils.listToString(accessIds), perm.name(), workbasketId);
throw new NotAuthorizedException(
"Not authorized. Permission '" + perm.name() + "' on workbasket '" + workbasketId
+ "' is needed.");
@ -363,9 +338,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
taskanaEngine.openConnection();
if (workbasketMapper.findByKeyAndDomain(workbasketKey, domain) == null) {
LOGGER.error(
"Throwing WorkbasketNotFoundException because workbasket with key {} and domain {} does not exist",
workbasketKey, domain);
throw new WorkbasketNotFoundException(workbasketKey, domain,
"Workbasket with key " + workbasketKey + " and domain " + domain + " was not found");
}
@ -377,9 +349,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
WorkbasketAccessItem wbAcc = workbasketAccessMapper.findByWorkbasketKeyDomainAndAccessId(
workbasketKey, domain, accessIds);
if (wbAcc == null) {
LOGGER.error(
"AccessIds {} do not have permission {} on workbasket with key {} and domain {}. Throwing NotAuthorizedException.",
LoggerUtils.listToString(accessIds), Arrays.toString(requestedPermissions), workbasketKey, domain);
throw new NotAuthorizedException(
"Not authorized. Permission '" + Arrays.toString(requestedPermissions)
+ "' on workbasket with key '"
@ -391,9 +360,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
for (WorkbasketPermission perm : requestedPermissions) {
if (!grantedPermissions.contains(perm)) {
isAuthorized = false;
LOGGER.error(
"AccessIds {} do not have permission {} on workbasket with key {} and domain {}. Throwing NotAuthorizedException.",
LoggerUtils.listToString(accessIds), perm.name(), workbasketKey, domain);
throw new NotAuthorizedException(
"Not authorized. Permission '" + perm.name() + "' on workbasket with key '" + workbasketKey
+ "' and domain '" + domain + "' is needed.");
@ -746,7 +712,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override
public void removeDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException {
throws NotAuthorizedException {
LOGGER.debug("entry to removeDistributionTarget(sourceWorkbasketId = {}, targetWorkbasketId = {})",
sourceWorkbasketId, targetWorkbasketId);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);

View File

@ -62,7 +62,7 @@ public class MapTypeHandler extends BaseTypeHandler<Map> {
return null;
}
private Map convertToMap(String fieldValue) throws SQLException {
private Map convertToMap(String fieldValue) {
JSONObject jsonObj = new JSONObject(fieldValue);
return jsonObj.toMap();
}

View File

@ -23,7 +23,6 @@ import pro.taskana.TimeInterval;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.database.TestDataGenerator;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.configuration.DBCleaner;
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
@ -78,7 +77,7 @@ public abstract class AbstractAccTest {
protected Attachment createAttachment(String classificationKey, ObjectReference objRef,
String channel, String receivedDate, Map<String, String> customAttributes)
throws ClassificationNotFoundException, NotAuthorizedException {
throws ClassificationNotFoundException {
Attachment attachment = taskanaEngine.getTaskService().newAttachment();
attachment.setClassificationSummary(

View File

@ -102,7 +102,7 @@ public class CreateClassificationAccTest extends AbstractAccTest {
@Test
public void testCreateClassificationWithInvalidValues()
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
DomainNotFoundException, InvalidArgumentException {
DomainNotFoundException {
long amountOfClassificationsBefore = classificationService.createClassificationQuery().count();
// Check key NULL

View File

@ -6,8 +6,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -38,7 +36,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testDeleteClassificationInDomain()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
throws ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L140101", "DOMAIN_A");
Classification classification = classificationService.getClassification("L140101", "DOMAIN_A");
@ -51,7 +49,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"})
@Test(expected = NotAuthorizedException.class)
public void testDeleteClassificationInDomainUserIsNotAuthorized()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
throws ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L140101", "DOMAIN_A");
fail("NotAuthorizedException should have been thrown");
}
@ -61,7 +59,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"group_1", "businessadmin"})
@Test(expected = ClassificationInUseException.class)
public void testThrowExeptionIfDeleteClassificationWithExistingTasks()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
throws ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L1050", "DOMAIN_A");
}
@ -70,7 +68,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"group_1", "businessadmin"})
@Test(expected = ClassificationInUseException.class)
public void testThrowExeptionIfDeleteMasterClassificationWithExistingTasks()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
throws ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L1050", "");
}
@ -79,7 +77,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testDeleteMasterClassification()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
throws ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L3060", "");
@ -97,7 +95,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test(expected = ClassificationInUseException.class)
public void testDeleteMasterClassificationWithExistingAttachment()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
throws ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L12010", "");
@ -115,7 +113,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"group_1", "businessadmin"})
@Test
public void testThrowExceptionWhenChildClassificationIsInUseAndRollback()
throws ClassificationInUseException, NotAuthorizedException, ClassificationNotFoundException {
throws NotAuthorizedException, ClassificationNotFoundException {
boolean classificationInUse = false;
try {
classificationService.deleteClassification("L11010", "DOMAIN_A");

View File

@ -3,7 +3,6 @@ package acceptance.classification;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.sql.SQLException;
import java.util.List;
import java.util.stream.Collectors;
@ -12,9 +11,6 @@ import org.junit.Test;
import acceptance.AbstractAccTest;
import pro.taskana.ClassificationService;
import pro.taskana.ClassificationSummary;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
/**
* Acceptance test for all "get classification" scenarios.
@ -26,8 +22,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
}
@Test
public void testQueryClassificationValuesForColumnName()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testQueryClassificationValuesForColumnName() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<String> columnValueList = classificationService.createClassificationQuery()
.listValues("NAME", null);
@ -59,8 +54,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
}
@Test
public void testFindClassificationsByCategoryAndDomain()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testFindClassificationsByCategoryAndDomain() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery()
.categoryIn("MANUAL")
@ -72,8 +66,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
}
@Test
public void testGetOneClassificationForMultipleDomains()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testGetOneClassificationForMultipleDomains() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.keyIn("L10000")
@ -85,8 +78,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
}
@Test
public void testGetClassificationsForTypeAndParent()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testGetClassificationsForTypeAndParent() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.typeIn("TASK", "DOCUMENT")
@ -110,8 +102,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
}
@Test
public void testGetClassificationsForKeyAndCategories()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testGetClassificationsForKeyAndCategories() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.keyIn("T2100", "L10000")
@ -135,8 +126,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
}
@Test
public void testGetClassificationsWithParentKey()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testGetClassificationsWithParentKey() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.keyIn("A12", "A13")
@ -159,8 +149,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
}
@Test
public void testGetClassificationsWithCustom1()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testGetClassificationsWithCustom1() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.custom1Like("VNR,RVNR,KOLVNR", "VNR")
@ -171,8 +160,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
}
@Test
public void testGetClassificationsWithCustom1Like()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testGetClassificationsWithCustom1Like() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.custom1Like("%RVNR%")
@ -184,8 +172,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
}
@Test
public void testGetClassificationsWithParentAndCustom2()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testGetClassificationsWithParentAndCustom2() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.parentIdIn("CLI:100000000000000000000000000000000004")
@ -197,8 +184,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
}
@Test
public void testFindClassificationsByCreatedTimestamp()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testFindClassificationsByCreatedTimestamp() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery()
.domainIn("DOMAIN_A")
@ -210,8 +196,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
}
@Test
public void testFindClassificationsByPriorityAndValidInDomain()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testFindClassificationsByPriorityAndValidInDomain() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> list = classificationService.createClassificationQuery()
.validInDomainEquals(Boolean.TRUE)

View File

@ -27,7 +27,7 @@ public class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
}
@Test
public void testGetFirstPageOfClassificationQueryWithOffset() throws NotAuthorizedException {
public void testGetFirstPageOfClassificationQueryWithOffset() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> results = classificationService.createClassificationQuery()
.domainIn("DOMAIN_A")
@ -36,7 +36,7 @@ public class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
}
@Test
public void testGetSecondPageOfClassificationQueryWithOffset() throws NotAuthorizedException {
public void testGetSecondPageOfClassificationQueryWithOffset() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> results = classificationService.createClassificationQuery()
.domainIn("DOMAIN_A")
@ -45,7 +45,7 @@ public class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
}
@Test
public void testListOffsetAndLimitOutOfBounds() throws NotAuthorizedException {
public void testListOffsetAndLimitOutOfBounds() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
// both will be 0, working
@ -68,7 +68,7 @@ public class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
}
@Test
public void testPaginationWithPages() throws NotAuthorizedException {
public void testPaginationWithPages() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
// Getting full page
@ -105,7 +105,7 @@ public class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
}
@Test
public void testPaginationNullAndNegativeLimitsIgnoring() throws NotAuthorizedException {
public void testPaginationNullAndNegativeLimitsIgnoring() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
// 0 limit/size = 0 results
@ -153,8 +153,7 @@ public class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
}
@Test
public void testCountOfClassificationsQuery()
throws NotAuthorizedException {
public void testCountOfClassificationsQuery() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
long count = classificationService.createClassificationQuery()
.domainIn("DOMAIN_A")

View File

@ -7,7 +7,6 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
@ -50,7 +49,7 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testUpdateClassification()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
InvalidArgumentException {
String newName = "updated Name";
String newEntryPoint = "updated EntryPoint";
@ -89,7 +88,7 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
@Test(expected = NotAuthorizedException.class)
public void testUpdateClassificationFails()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
InvalidArgumentException {
String newName = "updated Name";
String newEntryPoint = "updated EntryPoint";
@ -188,7 +187,7 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
groupNames = {"admin"})
@Test
public void testUpdateClassificationPrioServiceLevel()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
InterruptedException, TaskNotFoundException, InvalidArgumentException {
String newEntryPoint = "updated EntryPoint";
Instant before = Instant.now();

View File

@ -54,7 +54,7 @@ public class TaskanaRoleConfigAccTest extends TaskanaEngineImpl {
}
@Test
public void testOtherConfigFileSameDelimiter() throws IOException, SQLException {
public void testOtherConfigFileSameDelimiter() throws IOException {
String propertiesFileName = createNewConfigFileWithSameDelimiter("/dummyTestConfig.properties");
try {
getConfiguration().initTaskanaProperties(propertiesFileName, "|");
@ -81,7 +81,7 @@ public class TaskanaRoleConfigAccTest extends TaskanaEngineImpl {
}
@Test
public void testOtherConfigFileDifferentDelimiter() throws IOException, SQLException {
public void testOtherConfigFileDifferentDelimiter() throws IOException {
String delimiter = ";";
String propertiesFileName = createNewConfigFileWithDifferentDelimiter("/dummyTestConfig.properties", delimiter);
try {

View File

@ -3,7 +3,6 @@ package acceptance.objectreference;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.sql.SQLException;
import java.util.List;
import org.junit.Test;
@ -11,9 +10,6 @@ import org.junit.Test;
import acceptance.AbstractAccTest;
import pro.taskana.ObjectReference;
import pro.taskana.TaskQuery;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
/**
* Acceptance test for all "get classification" scenarios.
@ -42,8 +38,7 @@ public class QueryObjectReferenceAccTest extends AbstractAccTest {
}
@Test
public void testFindObjectReferenceByCompany()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testFindObjectReferenceByCompany() {
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery()
@ -55,8 +50,7 @@ public class QueryObjectReferenceAccTest extends AbstractAccTest {
}
@Test
public void testFindObjectReferenceBySystem()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testFindObjectReferenceBySystem() {
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery()
@ -69,8 +63,7 @@ public class QueryObjectReferenceAccTest extends AbstractAccTest {
}
@Test
public void testFindObjectReferenceBySystemInstance()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testFindObjectReferenceBySystemInstance() {
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery()
@ -83,8 +76,7 @@ public class QueryObjectReferenceAccTest extends AbstractAccTest {
}
@Test
public void testFindObjectReferenceByType()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testFindObjectReferenceByType() {
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery()
@ -96,8 +88,7 @@ public class QueryObjectReferenceAccTest extends AbstractAccTest {
}
@Test
public void testFindObjectReferenceByValue()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testFindObjectReferenceByValue() {
TaskQuery taskQuery = taskanaEngine.getTaskService().createTaskQuery();
List<ObjectReference> objectReferenceList = taskQuery.createObjectReferenceQuery()

View File

@ -41,20 +41,20 @@ public class QueryObjectreferencesWithPaginationAccTest extends AbstractAccTest
}
@Test
public void testGetFirstPageOfObjectRefQueryWithOffset() throws NotAuthorizedException {
public void testGetFirstPageOfObjectRefQueryWithOffset() {
List<ObjectReference> results = objRefQuery.list(0, 5);
assertThat(results.size(), equalTo(3));
}
@Test
public void testGetSecondPageOfObjectRefQueryWithOffset() throws NotAuthorizedException {
public void testGetSecondPageOfObjectRefQueryWithOffset() {
List<ObjectReference> results = objRefQuery.list(2, 5);
assertThat(results.size(), equalTo(1));
}
@Test
public void testListOffsetAndLimitOutOfBounds() throws NotAuthorizedException {
public void testListOffsetAndLimitOutOfBounds() {
// both will be 0, working
List<ObjectReference> results = objRefQuery.list(-1, -3);
assertThat(results.size(), equalTo(0));
@ -69,7 +69,7 @@ public class QueryObjectreferencesWithPaginationAccTest extends AbstractAccTest
}
@Test
public void testPaginationWithPages() throws NotAuthorizedException {
public void testPaginationWithPages() {
// Getting full page
int pageNumber = 1;
int pageSize = 10;
@ -96,7 +96,7 @@ public class QueryObjectreferencesWithPaginationAccTest extends AbstractAccTest
}
@Test
public void testPaginationNullAndNegativeLimitsIgnoring() throws NotAuthorizedException {
public void testPaginationNullAndNegativeLimitsIgnoring() {
// 0 limit/size = 0 results
int pageNumber = 2;
int pageSize = 0;
@ -132,8 +132,7 @@ public class QueryObjectreferencesWithPaginationAccTest extends AbstractAccTest
}
@Test
public void testCountOfClassificationsQuery()
throws NotAuthorizedException {
public void testCountOfClassificationsQuery() {
long count = objRefQuery.count();
assertThat(count, equalTo(3L));
}

View File

@ -3,7 +3,6 @@ package acceptance.security;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.sql.SQLException;
import java.util.List;
import org.junit.Test;
@ -12,9 +11,6 @@ import org.junit.runner.RunWith;
import acceptance.AbstractAccTest;
import pro.taskana.ClassificationService;
import pro.taskana.ClassificationSummary;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
@ -31,8 +27,7 @@ public class ClassificationQueryAccTest extends AbstractAccTest {
}
@Test
public void testFindClassificationsByDomainUnauthenticated()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testFindClassificationsByDomainUnauthenticated() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery()
.domainIn("DOMAIN_A")
@ -44,8 +39,7 @@ public class ClassificationQueryAccTest extends AbstractAccTest {
@WithAccessId(userName = "businessadmin")
@Test
public void testFindClassificationsByDomainBusinessAdmin()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testFindClassificationsByDomainBusinessAdmin() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery()
.domainIn("DOMAIN_A")
@ -57,8 +51,7 @@ public class ClassificationQueryAccTest extends AbstractAccTest {
@WithAccessId(userName = "admin")
@Test
public void testFindClassificationsByDomainAdmin()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
public void testFindClassificationsByDomainAdmin() {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery()
.domainIn("DOMAIN_A")

View File

@ -1,6 +1,5 @@
package acceptance.security;
import java.sql.SQLException;
import java.util.List;
import org.junit.Assert;
@ -27,8 +26,7 @@ public class WorkbasketQueryAccTest extends AbstractAccTest {
}
@Test
public void testQueryWorkbasketByUnauthenticated()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByUnauthenticated() throws InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%")
@ -50,8 +48,7 @@ public class WorkbasketQueryAccTest extends AbstractAccTest {
@WithAccessId(
userName = "unknown")
@Test
public void testQueryWorkbasketByUnknownUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByUnknownUser() throws InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%")
@ -74,8 +71,7 @@ public class WorkbasketQueryAccTest extends AbstractAccTest {
userName = "unknown",
groupNames = "businessadmin")
@Test
public void testQueryWorkbasketByBusinessAdmin()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByBusinessAdmin() throws NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%")
@ -95,8 +91,7 @@ public class WorkbasketQueryAccTest extends AbstractAccTest {
userName = "unknown",
groupNames = "admin")
@Test
public void testQueryWorkbasketByAdmin()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByAdmin() throws NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%")

View File

@ -7,7 +7,6 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.time.Duration;
import java.time.Instant;
import java.util.Collections;
@ -26,9 +25,7 @@ import pro.taskana.TaskState;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.ConcurrencyException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.TaskNotFoundException;
@ -58,8 +55,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testCreateSimpleManualTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -90,8 +87,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testCreateSimpleTaskWithCustomAttributes()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -157,9 +154,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testCreateExternalTaskWithAttachment()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException {
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -223,8 +219,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testCreateExternalTaskWithMultipleAttachments()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -260,8 +256,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testPrioDurationOfTaskFromAttachmentsAtCreate()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -306,8 +302,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testThrowsExceptionIfAttachmentIsInvalid()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
throws NotAuthorizedException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = makeNewTask(taskService);
@ -378,7 +374,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
}
}
private Task makeNewTask(TaskService taskService) throws ClassificationNotFoundException {
private Task makeNewTask(TaskService taskService) {
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
newTask.setClassificationKey("L12010");
newTask.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
@ -391,8 +387,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testUseCustomNameIfSetForNewTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -411,8 +407,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testUseClassificationMetadataFromCorrectDomainForNewTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -431,8 +427,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test(expected = WorkbasketNotFoundException.class)
public void testGetExceptionIfWorkbasketDoesNotExist()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("UNKNOWN");
@ -446,8 +442,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test(expected = NotAuthorizedException.class)
public void testGetExceptionIfAppendIsNotPermitted()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("GPK_KSC", "DOMAIN_A");
@ -461,8 +457,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
throws NotAuthorizedException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");
@ -535,8 +531,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testSetDomainFromWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
TaskService taskService = taskanaEngine.getTaskService();
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
@ -559,8 +555,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testCreatedTaskObjectEqualsReadTaskObject()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");

View File

@ -4,7 +4,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@ -64,7 +63,7 @@ public class DeleteTaskAccTest extends AbstractAccTest {
groupNames = {"group_1", "admin"})
@Test(expected = InvalidStateException.class)
public void testThrowsExceptionIfTaskIsNotCompleted()
throws TaskNotFoundException, InvalidStateException, SQLException, NotAuthorizedException {
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000029");
@ -76,7 +75,7 @@ public class DeleteTaskAccTest extends AbstractAccTest {
groupNames = {"group_1", "admin"})
@Test(expected = TaskNotFoundException.class)
public void testForceDeleteTaskIfNotCompleted()
throws SQLException, TaskNotFoundException, InvalidStateException, NotAuthorizedException {
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000027");
try {

View File

@ -6,7 +6,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -79,8 +78,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testQueryForOwnerLike()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryForOwnerLike() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -102,8 +100,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testQueryForParentBusinessProcessId()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryForParentBusinessProcessId() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -126,8 +123,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testQueryForName()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryForName() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -150,8 +146,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testQueryForClassificationKey()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryForClassificationKey() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -175,7 +170,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryForAttachmentInSummary()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
TaskNotFoundException, WorkbasketNotFoundException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService();
@ -201,8 +196,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryForWorkbasketKeyDomain()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryForWorkbasketKeyDomain() {
TaskService taskService = taskanaEngine.getTaskService();
List<KeyDomain> workbasketIdentifiers = Arrays.asList(new KeyDomain("GPK_KSC", "DOMAIN_A"),
new KeyDomain("USER_1_2", "DOMAIN_A"));
@ -228,7 +222,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryForCustom1()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -262,7 +256,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryForCustom2()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -296,7 +290,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryForCustom3()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -330,7 +324,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryForCustom4()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -364,7 +358,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryForCustom5()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -398,7 +392,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryForCustom6()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -432,7 +426,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryForCustom7()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -466,7 +460,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryForCustom8()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -500,7 +494,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryForCustom9()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -534,7 +528,7 @@ public class QueryTasksAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryForCustom10()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
@ -568,8 +562,8 @@ public class QueryTasksAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryTaskByCustomAttributes()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException {
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException {
TaskService taskService = taskanaEngine.getTaskService();
Task newTask = taskService.newTask("USER_1_1", "DOMAIN_A");

View File

@ -1,6 +1,5 @@
package acceptance.task;
import java.sql.SQLException;
import java.util.List;
import org.junit.Assert;
@ -10,8 +9,6 @@ import org.junit.runner.RunWith;
import acceptance.AbstractAccTest;
import pro.taskana.TaskService;
import pro.taskana.TaskSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.SystemException;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
@ -31,7 +28,7 @@ public class QueryTasksByObjectReferenceAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"})
@Test
public void testQueryTasksByExcactValueOfObjectReference()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
throws SystemException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
.primaryObjectReferenceValueIn("11223344", "22334455")
@ -44,7 +41,7 @@ public class QueryTasksByObjectReferenceAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"})
@Test
public void testQueryTasksByExcactValueAndTypeOfObjectReference()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
throws SystemException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
.primaryObjectReferenceTypeIn("SDNR")
@ -58,7 +55,7 @@ public class QueryTasksByObjectReferenceAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"})
@Test
public void testQueryTasksByValueLikeOfObjectReference()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
throws SystemException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
.primaryObjectReferenceValueLike("%567%")

View File

@ -3,7 +3,6 @@ package acceptance.task;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import java.sql.SQLException;
import java.time.Instant;
import java.util.List;
@ -16,8 +15,6 @@ import pro.taskana.BaseQuery.SortDirection;
import pro.taskana.TaskService;
import pro.taskana.TaskSummary;
import pro.taskana.TimeInterval;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
@ -38,8 +35,7 @@ public class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testCreatedWithin2Intervals()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testCreatedWithin2Intervals() {
TaskService taskService = taskanaEngine.getTaskService();
TimeInterval interval1 = new TimeInterval(
@ -71,8 +67,7 @@ public class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testCreatedBefore()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testCreatedBefore() {
TaskService taskService = taskanaEngine.getTaskService();
TimeInterval interval1 = new TimeInterval(
@ -101,8 +96,7 @@ public class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testCreatedAfter()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testCreatedAfter() {
TaskService taskService = taskanaEngine.getTaskService();
TimeInterval interval1 = new TimeInterval(
@ -130,8 +124,7 @@ public class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testClaimedWithin2Intervals()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testClaimedWithin2Intervals() {
TaskService taskService = taskanaEngine.getTaskService();
TimeInterval interval1 = new TimeInterval(
@ -163,8 +156,7 @@ public class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testCompletedWithin()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testCompletedWithin() {
TaskService taskService = taskanaEngine.getTaskService();
TimeInterval interval = new TimeInterval(
@ -192,8 +184,7 @@ public class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testModifiedWithin()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testModifiedWithin() {
TaskService taskService = taskanaEngine.getTaskService();
TimeInterval interval = new TimeInterval(
@ -221,8 +212,7 @@ public class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testPlannedWithin()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testPlannedWithin() {
TaskService taskService = taskanaEngine.getTaskService();
TimeInterval interval = new TimeInterval(
@ -250,8 +240,7 @@ public class QueryTasksByTimeIntervalsAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testDueWithin()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testDueWithin() {
TaskService taskService = taskanaEngine.getTaskService();
TimeInterval interval = new TimeInterval(

View File

@ -1,7 +1,5 @@
package acceptance.task;
import java.sql.SQLException;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -9,8 +7,6 @@ import org.junit.runner.RunWith;
import acceptance.AbstractAccTest;
import pro.taskana.KeyDomain;
import pro.taskana.TaskService;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
@ -30,8 +26,7 @@ public class QueryTasksByWorkbasketAccTest extends AbstractAccTest {
userName = "user_1_1",
groupNames = {"group_1"})
@Test(expected = NotAuthorizedToQueryWorkbasketException.class)
public void testThrowsExceptionIfNoOpenerPermissionOnQueriedWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testThrowsExceptionIfNoOpenerPermissionOnQueriedWorkbasket() {
TaskService taskService = taskanaEngine.getTaskService();
taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_2_1", "DOMAIN_A"))
@ -43,8 +38,7 @@ public class QueryTasksByWorkbasketAccTest extends AbstractAccTest {
userName = "user_1_1",
groupNames = {"group_1"})
@Test(expected = NotAuthorizedToQueryWorkbasketException.class)
public void testThrowsExceptionIfNoOpenerPermissionOnAtLeastOneQueriedWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testThrowsExceptionIfNoOpenerPermissionOnAtLeastOneQueriedWorkbasket() {
TaskService taskService = taskanaEngine.getTaskService();
taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_1_1", "DOMAIN_A"), new KeyDomain("USER_2_1", "DOMAIN_A"))

View File

@ -34,8 +34,7 @@ public class QueryTasksWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testGetFirstPageOfTaskQueryWithOffset()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testGetFirstPageOfTaskQueryWithOffset() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A"))
@ -47,8 +46,7 @@ public class QueryTasksWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testSecondPageOfTaskQueryWithOffset()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testSecondPageOfTaskQueryWithOffset() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A"))
@ -60,8 +58,7 @@ public class QueryTasksWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testListOffsetAndLimitOutOfBounds()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testListOffsetAndLimitOutOfBounds() {
TaskService taskService = taskanaEngine.getTaskService();
// both will be 0, working
@ -87,8 +84,7 @@ public class QueryTasksWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testPaginationWithPages()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testPaginationWithPages() {
TaskService taskService = taskanaEngine.getTaskService();
// Getting full page
@ -128,8 +124,7 @@ public class QueryTasksWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testPaginationNullAndNegativeLimitsIgnoring()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testPaginationNullAndNegativeLimitsIgnoring() {
TaskService taskService = taskanaEngine.getTaskService();
// 0 limit/size = 0 results
@ -186,8 +181,7 @@ public class QueryTasksWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testCountOfTaskQuery()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testCountOfTaskQuery() {
TaskService taskService = taskanaEngine.getTaskService();
long count = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A"))

View File

@ -3,7 +3,6 @@ package acceptance.task;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import java.sql.SQLException;
import java.util.List;
import org.junit.Assert;
@ -16,8 +15,6 @@ import pro.taskana.KeyDomain;
import pro.taskana.TaskService;
import pro.taskana.TaskState;
import pro.taskana.TaskSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
@ -38,8 +35,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testSortByModifiedAndDomain()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testSortByModifiedAndDomain() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B"))
@ -61,8 +57,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testSortByDomainNameAndCreated()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testSortByDomainNameAndCreated() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B"))
@ -93,8 +88,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testSortByPorSystemNoteDueAndOwner()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testSortByPorSystemNoteDueAndOwner() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B"))
@ -119,8 +113,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testSortByPorSystemInstanceParentProcPlannedAndState()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testSortByPorSystemInstanceParentProcPlannedAndState() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B"))
@ -145,8 +138,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testSortByPorCompanyAndClaimed()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testSortByPorCompanyAndClaimed() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B"))
@ -171,8 +163,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testSortByWbKeyPrioPorValueAndCompleted()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testSortByWbKeyPrioPorValueAndCompleted() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
.stateIn(TaskState.READY)
@ -198,8 +189,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1", "group_2"})
@Test
public void testSortBpIdClassificationIdDescriptionAndPorType()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testSortBpIdClassificationIdDescriptionAndPorType() {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery()
.stateIn(TaskState.READY)

View File

@ -241,7 +241,7 @@ public class TransferTaskAccTest extends AbstractAccTest {
@WithAccessId(userName = "teamlead_1")
@Test(expected = NotAuthorizedException.class)
public void testBulkTransferTaskWithoutAppendPermissionOnTarget()
throws InvalidArgumentException, WorkbasketNotFoundException, TaskNotFoundException, NotAuthorizedException {
throws InvalidArgumentException, WorkbasketNotFoundException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
ArrayList<String> taskIdList = new ArrayList<>();
taskIdList.add("TKI:000000000000000000000000000000000006"); // working

View File

@ -11,7 +11,6 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.time.Instant;
import java.util.HashMap;
import java.util.List;
@ -54,8 +53,8 @@ public class UpdateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testUpdatePrimaryObjectReferenceOfTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService();
@ -84,8 +83,8 @@ public class UpdateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, ClassificationNotFoundException,
WorkbasketNotFoundException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService();
@ -141,8 +140,8 @@ public class UpdateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testThrowsExceptionIfTaskHasAlreadyBeenUpdated()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService();
@ -193,9 +192,7 @@ public class UpdateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testUpdateReadFlagOfTask()
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException {
throws TaskNotFoundException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService();
@ -235,8 +232,8 @@ public class UpdateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test(expected = InvalidArgumentException.class)
public void testUpdateOfWorkbasketKeyWhatIsNotAllowed()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService();

View File

@ -8,7 +8,6 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
@ -59,7 +58,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
// since only @Test and not @Before methods are run by JAASRunner, we call this method explicitely at
// the begin of each testcase....
private void setUpMethod()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException, SQLException,
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException {
taskService = taskanaEngine.getTaskService();
@ -81,7 +80,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testAddNewAttachment()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException {
AttachmentPersistenceException {
setUpMethod();
int attachmentCount = task.getAttachments().size();
assertTrue(task.getPriority() == 1);
@ -104,7 +103,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testAddNewAttachmentTwiceWithoutTaskanaMethodWillThrowAttachmentPersistenceException()
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException, SQLException {
AttachmentPersistenceException {
setUpMethod();
int attachmentCount = 0;
task.getAttachments().clear();
@ -127,7 +126,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testAddExistingAttachmentAgainWillUpdateWhenNotEqual()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException {
AttachmentPersistenceException {
setUpMethod();
// Add attachment before
task = taskService.getTask(task.getId());
@ -162,7 +161,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testAddExistingAttachmentAgainWillDoNothingWhenEqual()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException {
AttachmentPersistenceException {
setUpMethod();
// Add Attachment before
int attachmentCount = task.getAttachments().size();
@ -189,7 +188,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testAddAttachmentAsNullValueWillBeIgnored()
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException, SQLException {
AttachmentPersistenceException {
setUpMethod();
// Try to add a single NULL-Element
int attachmentCount = task.getAttachments().size();
@ -226,7 +225,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testRemoveAttachment()
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException, SQLException {
AttachmentPersistenceException {
setUpMethod();
task.addAttachment(attachment);
task = taskService.updateTask(task);
@ -250,7 +249,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testRemoveAttachmentWithNullAndNotAddedId()
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException, SQLException {
AttachmentPersistenceException {
setUpMethod();
task.addAttachment(attachment);
task = taskService.updateTask(task);
@ -276,7 +275,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testUpdateAttachment()
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException, SQLException {
AttachmentPersistenceException {
setUpMethod();
((TaskImpl) task).setAttachments(new ArrayList<>());
task = taskService.updateTask(task);
@ -312,7 +311,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void modifyExistingAttachment()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException {
AttachmentPersistenceException {
setUpMethod();
// setup test
assertThat(task.getAttachments().size(), equalTo(0));
@ -396,7 +395,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void replaceExistingAttachments()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException {
AttachmentPersistenceException {
setUpMethod();
// setup test
assertThat(task.getAttachments().size(), equalTo(0));
@ -441,7 +440,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testPrioDurationOfTaskFromAttachmentsAtUpdate()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException {
@ -491,7 +490,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testAddCustomAttributeToAttachment()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException {
AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService();
task = taskService.getTask("TKI:000000000000000000000000000000000000"); // class T2000, prio 1, SL P1D

View File

@ -9,7 +9,6 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.sql.SQLException;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
@ -23,18 +22,12 @@ import pro.taskana.BulkOperationResults;
import pro.taskana.Task;
import pro.taskana.TaskService;
import pro.taskana.TaskState;
import pro.taskana.exceptions.AttachmentPersistenceException;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.ConcurrencyException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidOwnerException;
import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.TaskanaException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
@ -53,8 +46,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testClaimTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000025");
@ -76,8 +68,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test(expected = InvalidOwnerException.class)
public void testThrowsExceptionIfTaskIsAlreadyClaimed()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000026");
@ -90,8 +81,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testClaimAlreadyClaimedByCallerTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000027");
@ -104,8 +94,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test(expected = InvalidOwnerException.class)
public void testForceClaimTaskWhichIsAlreadyClaimedByAnotherUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000028");
@ -118,8 +107,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testCancelClaimTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000029");
@ -139,8 +127,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test(expected = InvalidOwnerException.class)
public void testThrowsExceptionIfCancelClaimOfTaskFromAnotherUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000030");
@ -153,8 +140,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testForceCancelClaimOfTaskFromAnotherUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000031");
@ -174,8 +160,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testCompleteTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
Instant before = Instant.now().minus(Duration.ofSeconds(3L));
TaskService taskService = taskanaEngine.getTaskService();
@ -199,8 +184,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testForceCompleteUnclaimedTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000033");
@ -221,8 +205,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test(expected = InvalidOwnerException.class)
public void testThrowsExceptionIfCompletingClaimedTaskOfAnotherUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000034");
@ -235,8 +218,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testForceCompleteClaimedTaskOfAnotherUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
throws NotAuthorizedException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000035");
@ -257,9 +239,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testBulkCompleteTasks()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException {
throws NotAuthorizedException, InvalidArgumentException, TaskNotFoundException {
TaskService taskService = taskanaEngine.getTaskService();
List<String> taskIdList = new ArrayList<>();
@ -282,9 +262,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testBulkDeleteTasksWithException()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException {
throws InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<String> taskIdList = new ArrayList<>();

View File

@ -4,7 +4,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.util.List;
import org.junit.Test;
@ -39,7 +38,7 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testCreateWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
@ -67,8 +66,8 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
userName = "dummy")
@Test(expected = NotAuthorizedException.class)
public void testCreateWorkbasketNotAuthorized()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
throws NotAuthorizedException, InvalidWorkbasketException, WorkbasketAlreadyExistException,
DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.newWorkbasket("key3", "DOMAIN_A");
@ -85,8 +84,8 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test(expected = DomainNotFoundException.class)
public void testCreateWorkbasketWithInvalidDomain()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
throws NotAuthorizedException, InvalidWorkbasketException, WorkbasketAlreadyExistException,
DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.newWorkbasket("key3", "UNKNOWN_DOMAIN");
@ -103,7 +102,7 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testCreateWorkbasketWithMissingRequiredField()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketAlreadyExistException,
throws NotAuthorizedException, WorkbasketAlreadyExistException,
DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
@ -151,7 +150,7 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testWorkbasketAccessItemSetName()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();

View File

@ -6,7 +6,6 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.util.List;
import org.junit.Before;
@ -140,8 +139,8 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testCreateAndDeleteWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
throws NotAuthorizedException, InvalidWorkbasketException, WorkbasketAlreadyExistException,
DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();

View File

@ -18,7 +18,6 @@ import acceptance.AbstractAccTest;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.security.JAASRunner;
@ -127,7 +126,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
userName = "user_3_1", groupNames = {"group_1"})
@Test
public void testDistributionTargetCallsFailWithNotAuthorizedException()
throws NotAuthorizedException, WorkbasketNotFoundException {
throws WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
String existingWb = "WBI:100000000000000000000000000000000001";
@ -170,7 +169,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2", "businessadmin"})
@Test
public void testAddAndRemoveDistributionTargets()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
@ -201,7 +200,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testAddAndRemoveDistributionTargetsOnWorkbasketWithoutReadPermission()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("GPK_B_KSC_2", "DOMAIN_B");
@ -227,7 +226,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"})
@Test(expected = NotAuthorizedException.class)
public void testAddDistributionTargetsFailsNotAuthorized()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
@ -277,7 +276,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"})
@Test
public void testGetDistributionSourcesById()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> distributionSources = workbasketService
@ -298,7 +297,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"})
@Test
public void testGetDistributionSourcesByKeyDomain()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> distributionSources = workbasketService
@ -318,7 +317,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"undefinedgroup"})
@Test(expected = NotAuthorizedException.class)
public void testQueryDistributionSourcesThrowsNotAuthorized()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> distributionSources = workbasketService
@ -332,7 +331,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"})
@Test(expected = WorkbasketNotFoundException.class)
public void testQueryDistributionSourcesThrowsWorkbasketNotFound()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException {
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> distributionSources = workbasketService

View File

@ -1,6 +1,5 @@
package acceptance.workbasket;
import java.sql.SQLException;
import java.util.List;
import org.junit.Assert;
@ -12,8 +11,6 @@ import pro.taskana.Workbasket;
import pro.taskana.WorkbasketPermission;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketType;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.security.JAASRunner;
@ -34,8 +31,7 @@ public class GetWorkbasketAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testGetWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException {
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("WBI:100000000000000000000000000000000007");
@ -67,16 +63,14 @@ public class GetWorkbasketAccTest extends AbstractAccTest {
@Test(expected = WorkbasketNotFoundException.class)
public void testThrowsExceptionIfIdIsInvalid()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException {
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
workbasketService.getWorkbasket("INVALID_ID");
}
@Test(expected = NotAuthorizedException.class)
public void testThrowsExceptionIfNotAuthorized()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException {
throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000001");
}

View File

@ -4,7 +4,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.sql.SQLException;
import java.util.List;
import org.junit.Assert;
@ -91,7 +90,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketValuesForColumnName() throws NotAuthorizedException {
public void testQueryWorkbasketValuesForColumnName() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<String> columnValueList = workbasketService.createWorkbasketQuery()
.listValues("NAME", null);
@ -110,8 +109,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByDomain()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByDomain() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.domainIn("DOMAIN_B")
@ -123,8 +121,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByDomainAndType()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByDomainAndType() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.domainIn("DOMAIN_A")
@ -137,8 +134,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByName()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByName() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameIn("Gruppenpostkorb KSC")
@ -151,8 +147,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByNameStartsWith()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByNameStartsWith() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%Gruppenpostkorb KSC%")
@ -164,8 +159,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByNameContains()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByNameContains() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%Teamlead%", "%Gruppenpostkorb KSC%")
@ -177,8 +171,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByNameContainsCaseInsensitive()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByNameContainsCaseInsensitive() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%TEAMLEAD%")
@ -190,8 +183,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByDescription()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByDescription() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.descriptionLike("%ppk%", "%gruppen%")
@ -205,8 +197,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByOwnerLike()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByOwnerLike() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.ownerLike("%an%", "%te%")
@ -219,8 +210,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByKey()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByKey() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.keyIn("GPK_KSC")
@ -232,8 +222,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByMultipleKeys()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByMultipleKeys() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.keyIn("GPK_KSC_1", "GPK_KSC")
@ -245,8 +234,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByMultipleKeysWithUnknownKey()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByMultipleKeysWithUnknownKey() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.keyIn("GPK_KSC_1", "GPK_Ksc", "GPK_KSC_3")
@ -258,8 +246,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByKeyContains()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByKeyContains() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.keyLike("%KSC%")
@ -271,8 +258,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByKeyContainsIgnoreCase()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByKeyContainsIgnoreCase() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.keyLike("%kSc%")
@ -284,8 +270,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByKeyOrNameContainsIgnoreCase()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByKeyOrNameContainsIgnoreCase() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.keyOrNameLike("%kSc%")
@ -297,8 +282,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByNameStartsWithSortedByNameAscending()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByNameStartsWithSortedByNameAscending() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%Gruppenpostkorb KSC%")
@ -322,8 +306,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(
userName = "max")
@Test
public void testQueryWorkbasketByNameStartsWithSortedByNameDescending()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByNameStartsWithSortedByNameDescending() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("basxet%")
@ -344,8 +327,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(
userName = "max")
@Test
public void testQueryWorkbasketByNameStartsWithSortedByKeyAscending()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByNameStartsWithSortedByKeyAscending() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("basxet%")
@ -366,8 +348,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
@WithAccessId(
userName = "max")
@Test
public void testQueryWorkbasketByNameStartsWithSortedByKeyDescending()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByNameStartsWithSortedByKeyDescending() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("basxet%")
@ -389,8 +370,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByCreated()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByCreated() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.createdWithin(todaysInterval())
@ -402,8 +382,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testQueryWorkbasketByModified()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testQueryWorkbasketByModified() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.modifiedWithin(todaysInterval())
@ -416,7 +395,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
groupNames = "admin")
@Test
public void testQueryWorkbasketByAdmin()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%")

View File

@ -5,7 +5,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.util.List;
import org.junit.Assert;
@ -17,7 +16,6 @@ import pro.taskana.BaseQuery.SortDirection;
import pro.taskana.WorkbasketAccessItem;
import pro.taskana.WorkbasketAccessItemQuery;
import pro.taskana.WorkbasketService;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
@ -60,7 +58,7 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testQueryAccessItemsForAccessIds()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketAccessItem> results = workbasketService.createWorkbasketAccessItemQuery()
.accessIdIn("user_1_1", "group_1")
@ -72,7 +70,7 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
userName = "dummy")
@Test(expected = NotAuthorizedException.class)
public void testQueryAccessItemsForAccessIdsNotAuthorized()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
workbasketService.createWorkbasketAccessItemQuery()
.accessIdIn("user_1_1", "group_1")
@ -85,7 +83,7 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testQueryAccessItemsForAccessIdsOrderedAscending()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketAccessItemQuery query = workbasketService.createWorkbasketAccessItemQuery()
.accessIdIn("user_1_1", "group_1")
@ -103,7 +101,7 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testQueryAccessItemsForAccessIdsAndWorkbasketKey()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketAccessItem> results = workbasketService.createWorkbasketAccessItemQuery()
.accessIdIn("user_1_1", "group_1")
@ -117,7 +115,7 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testQueryAccessItemsByWorkbasketKey()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketAccessItem> results = workbasketService.createWorkbasketAccessItemQuery()
.workbasketIdIn("WBI:100000000000000000000000000000000006")
@ -130,7 +128,7 @@ public class QueryWorkbasketAccessItemsAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testQueryAccessItemsByWorkbasketKeyOrderedDescending()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketAccessItem> results = workbasketService.createWorkbasketAccessItemQuery()
.workbasketIdIn("WBI:100000000000000000000000000000000006")

View File

@ -2,7 +2,6 @@ package acceptance.workbasket;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -40,7 +39,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testQueryAllTransferTargetsForUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.accessIdsHavePermission(WorkbasketPermission.APPEND, "user_1_1")
@ -53,7 +52,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
userName = "dummy")
@Test(expected = NotAuthorizedException.class)
public void testQueryAllTransferTargetsForUserNotAuthorized()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
workbasketService.createWorkbasketQuery()
.accessIdsHavePermission(WorkbasketPermission.APPEND, "user_1_1")
@ -66,7 +65,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testQueryAllTransferTargetsForUserAndGroup()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
throws NotAuthorizedException, InvalidArgumentException, SystemException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.accessIdsHavePermission(WorkbasketPermission.APPEND, "user_1_1", "group_1")
@ -79,7 +78,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testQueryAllTransferTargetsForUserAndGroupSortedByNameAscending()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
throws NotAuthorizedException, InvalidArgumentException, SystemException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.accessIdsHavePermission(WorkbasketPermission.APPEND, "user_1_1", "group_1")
@ -94,7 +93,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testQueryAllTransferTargetsForUserAndGroupSortedByNameDescending()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
throws NotAuthorizedException, InvalidArgumentException, SystemException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.accessIdsHavePermission(WorkbasketPermission.APPEND, "user_1_1", "group_1")
@ -110,7 +109,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
groupNames = {"businessadmin"})
@Test
public void testQueryAllTransferSourcesForUserAndGroup()
throws SQLException, NotAuthorizedException, InvalidArgumentException, SystemException {
throws NotAuthorizedException, InvalidArgumentException, SystemException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.accessIdsHavePermission(WorkbasketPermission.DISTRIBUTE, "user_1_1", "group_1")
@ -127,7 +126,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test
public void testQueryAllTransferTargetsForUserAndGroupFromSubject()
throws SQLException, NotAuthorizedException, SystemException {
throws SystemException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.callerHasPermission(WorkbasketPermission.APPEND)
@ -137,8 +136,7 @@ public class QueryWorkbasketByPermissionAccTest extends AbstractAccTest {
@WithAccessId(userName = "user_1_1")
@Test
public void testQueryAllAvailableWorkbasketForOpeningForUserAndGroupFromSubject()
throws SQLException, NotAuthorizedException {
public void testQueryAllAvailableWorkbasketForOpeningForUserAndGroupFromSubject() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.callerHasPermission(WorkbasketPermission.READ)

View File

@ -3,7 +3,6 @@ package acceptance.workbasket;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import java.sql.SQLException;
import java.util.List;
import org.junit.Ignore;
@ -13,7 +12,6 @@ import org.junit.runner.RunWith;
import acceptance.AbstractAccTest;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskanaRuntimeException;
import pro.taskana.security.JAASRunner;
@ -33,8 +31,7 @@ public class QueryWorkbasketsWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testGetFirstPageOfWorkbasketQueryWithOffset()
throws NotAuthorizedException {
public void testGetFirstPageOfWorkbasketQueryWithOffset() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.domainIn("DOMAIN_A")
@ -46,8 +43,7 @@ public class QueryWorkbasketsWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testGetSecondPageOfWorkbasketQueryWithOffset()
throws NotAuthorizedException {
public void testGetSecondPageOfWorkbasketQueryWithOffset() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.domainIn("DOMAIN_A")
@ -59,7 +55,7 @@ public class QueryWorkbasketsWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testListOffsetAndLimitOutOfBounds() throws NotAuthorizedException {
public void testListOffsetAndLimitOutOfBounds() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
// both will be 0, working
@ -85,7 +81,7 @@ public class QueryWorkbasketsWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testPaginationWithPages() throws NotAuthorizedException {
public void testPaginationWithPages() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
// Getting full page
@ -125,8 +121,7 @@ public class QueryWorkbasketsWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testPaginationNullAndNegativeLimitsIgnoring()
throws NotAuthorizedException {
public void testPaginationNullAndNegativeLimitsIgnoring() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
// 0 limit/size = 0 results
@ -163,7 +158,7 @@ public class QueryWorkbasketsWithPaginationAccTest extends AbstractAccTest {
@Ignore
@Test(expected = TaskanaRuntimeException.class)
public void testPaginationThrowingExceptionWhenPageOutOfBounds()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
throws NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
// entrypoint set outside result amount
@ -178,8 +173,7 @@ public class QueryWorkbasketsWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testCountOfWorkbasketQuery()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testCountOfWorkbasketQuery() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
long count = workbasketService.createWorkbasketQuery()
.domainIn("DOMAIN_A")
@ -191,8 +185,7 @@ public class QueryWorkbasketsWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1",
groupNames = {"group_1"})
@Test
public void testWorkbasketQueryDomA()
throws SQLException, NotAuthorizedException, InvalidArgumentException {
public void testWorkbasketQueryDomA() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> result = workbasketService.createWorkbasketQuery()
.domainIn("DOMAIN_A")

View File

@ -1,6 +1,5 @@
package acceptance.workbasket;
import java.sql.SQLException;
import java.time.Instant;
import org.junit.Assert;
@ -11,7 +10,6 @@ import acceptance.AbstractAccTest;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketType;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
@ -33,8 +31,7 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
groupNames = {"group_1", "businessadmin"})
@Test
public void testUpdateWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException {
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A");
Instant modified = workbasket.getModified();
@ -66,8 +63,7 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
groupNames = {"group_1"})
@Test(expected = NotAuthorizedException.class)
public void testCheckAuthorizationToUpdateWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException {
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A");

View File

@ -7,7 +7,6 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.util.List;
import org.junit.Assert;
@ -23,7 +22,6 @@ import pro.taskana.WorkbasketAccessItem;
import pro.taskana.WorkbasketService;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException;
import pro.taskana.exceptions.TaskAlreadyExistException;
@ -83,8 +81,7 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
groupNames = {"group_1", "businessadmin"})
@Test
public void testUpdateWorkbasketAccessItemRejected()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException {
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketAccessItem accessItem = workbasketService
.newWorkbasketAccessItem("WBI:100000000000000000000000000000000001", "user1");
@ -125,8 +122,8 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
groupNames = {"group_2", "businessadmin"})
@Test
public void testUpdatedAccessItemLeadsToNotAuthorizedException()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
ClassificationNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException {
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
ClassificationNotFoundException, TaskAlreadyExistException {
TaskService taskService = taskanaEngine.getTaskService();
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();

View File

@ -13,7 +13,6 @@ import acceptance.AbstractAccTest;
import pro.taskana.BaseQuery.SortDirection;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.security.JAASRunner;
/**
@ -31,8 +30,7 @@ public class WorkbasketQueryWithOrderedPaginationAccTest extends AbstractAccTest
@Ignore
@Test
public void testGetFirstPageOfTaskQueryWithOffset()
throws NotAuthorizedException {
public void testGetFirstPageOfTaskQueryWithOffset() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.domainIn("DOMAIN_A")
@ -53,8 +51,7 @@ public class WorkbasketQueryWithOrderedPaginationAccTest extends AbstractAccTest
@Ignore
@Test
public void testGetSecondPageOfTaskQueryWithOffset()
throws NotAuthorizedException {
public void testGetSecondPageOfTaskQueryWithOffset() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.domainIn("DOMAIN_A")

View File

@ -15,8 +15,6 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import pro.taskana.ClassificationSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
/**
* Test for ClassificationQueryImpl.
@ -40,7 +38,7 @@ public class ClassificationQueryImplTest {
}
@Test
public void should_ReturnList_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException {
public void should_ReturnList_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectList(any(), any())).thenReturn(new ArrayList<>());
@ -53,8 +51,7 @@ public class ClassificationQueryImplTest {
}
@Test
public void should_ReturnListWithOffset_when_BuilderIsUsed()
throws NotAuthorizedException, InvalidArgumentException {
public void should_ReturnListWithOffset_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectList(any(), any(), any())).thenReturn(new ArrayList<>());
@ -67,7 +64,7 @@ public class ClassificationQueryImplTest {
}
@Test
public void should_ReturnOneItem_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException {
public void should_ReturnOneItem_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectOne(any(), any())).thenReturn(new ClassificationSummaryImpl());

View File

@ -215,7 +215,7 @@ public class ClassificationServiceImplTest {
@Test(expected = ClassificationNotFoundException.class)
public void testUpdateClassificationParentNotExisting()
throws ClassificationAlreadyExistException, ClassificationNotFoundException, NotAuthorizedException,
throws ClassificationNotFoundException, NotAuthorizedException,
ConcurrencyException, InvalidArgumentException {
Instant now = Instant.now();
ClassificationImpl oldClassification = (ClassificationImpl) createDummyClassification();

View File

@ -15,9 +15,6 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import pro.taskana.ObjectReference;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
/**
* Test for ObjectReferenceQueryImpl.
*
@ -40,7 +37,7 @@ public class ObjectReferenceQueryImplTest {
}
@Test
public void should_ReturnList_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException {
public void should_ReturnList_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectList(any(), any())).thenReturn(new ArrayList<>());
@ -53,8 +50,7 @@ public class ObjectReferenceQueryImplTest {
}
@Test
public void should_ReturnListWithOffset_when_BuilderIsUsed()
throws NotAuthorizedException, InvalidArgumentException {
public void should_ReturnListWithOffset_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectList(any(), any(), any())).thenReturn(new ArrayList<>());
@ -67,7 +63,7 @@ public class ObjectReferenceQueryImplTest {
}
@Test
public void should_ReturnOneItem_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException {
public void should_ReturnOneItem_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectOne(any(), any())).thenReturn(new ObjectReference());

View File

@ -18,8 +18,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import pro.taskana.TaskState;
import pro.taskana.TaskSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
/**
* Test for TaskQueryImpl.
@ -51,7 +49,7 @@ public class TaskQueryImplTest {
}
@Test
public void should_ReturnList_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException {
public void should_ReturnList_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectList(any(), any())).thenReturn(new ArrayList<>());
List<TaskSummary> intermediate = new ArrayList<>();
@ -66,8 +64,7 @@ public class TaskQueryImplTest {
}
@Test
public void should_ReturnListWithOffset_when_BuilderIsUsed()
throws NotAuthorizedException, InvalidArgumentException {
public void should_ReturnListWithOffset_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectList(any(), any(), any())).thenReturn(new ArrayList<>());
List<TaskSummary> intermediate = new ArrayList<>();
@ -82,7 +79,7 @@ public class TaskQueryImplTest {
}
@Test
public void should_ReturnOneItem_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException {
public void should_ReturnOneItem_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectOne(any(), any())).thenReturn(new TaskSummaryImpl());
List<TaskSummary> intermediate = new ArrayList<>();

View File

@ -47,13 +47,11 @@ import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.AttachmentPersistenceException;
import pro.taskana.exceptions.ClassificationAlreadyExistException;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.ConcurrencyException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidOwnerException;
import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.SystemException;
import pro.taskana.exceptions.TaskAlreadyExistException;
@ -123,8 +121,7 @@ public class TaskServiceImplTest {
@Test
public void testCreateSimpleTask() throws NotAuthorizedException, WorkbasketNotFoundException,
ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException,
TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
ClassificationNotFoundException, TaskAlreadyExistException, TaskNotFoundException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", "k1", dummyClassification);
@ -170,8 +167,7 @@ public class TaskServiceImplTest {
@Test(expected = SystemException.class)
public void testCreateTaskWithSecurityButNoUserId()
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
ClassificationNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException,
InvalidArgumentException {
ClassificationNotFoundException, TaskAlreadyExistException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl expectedTask = createUnitTestTask("", "DUMMYTASK", "k1", dummyClassification);
@ -195,8 +191,7 @@ public class TaskServiceImplTest {
@Test
public void testCreateSimpleTaskWithObjectReference() throws NotAuthorizedException, WorkbasketNotFoundException,
ClassificationNotFoundException, ClassificationAlreadyExistException, TaskAlreadyExistException,
TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
ClassificationNotFoundException, TaskAlreadyExistException, TaskNotFoundException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
ObjectReference expectedObjectReference = JunitHelper.createDefaultObjRef();
WorkbasketImpl wb = new WorkbasketImpl();
@ -248,8 +243,8 @@ public class TaskServiceImplTest {
@Test
public void testCreateSimpleTaskWithObjectReferenceIsNull() throws NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
WorkbasketNotFoundException, ClassificationNotFoundException, TaskAlreadyExistException, TaskNotFoundException,
InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
ObjectReference expectedObjectReference = JunitHelper.createDefaultObjRef();
WorkbasketImpl wb = new WorkbasketImpl();
@ -303,7 +298,7 @@ public class TaskServiceImplTest {
@Test
public void testCreateTaskWithPlanned()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
TaskAlreadyExistException, TaskNotFoundException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
ObjectReference expectedObjectReference = JunitHelper.createDefaultObjRef();
@ -376,7 +371,7 @@ public class TaskServiceImplTest {
@Test(expected = TaskAlreadyExistException.class)
public void testCreateTaskThrowingAlreadyExistException() throws WorkbasketNotFoundException,
ClassificationNotFoundException, NotAuthorizedException, TaskAlreadyExistException, TaskNotFoundException,
InvalidWorkbasketException, InvalidArgumentException {
InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("12", "Task Name", "1", dummyClassification);
@ -399,7 +394,7 @@ public class TaskServiceImplTest {
@Test(expected = NotAuthorizedException.class)
public void testCreateThrowingAuthorizedOnWorkbasket()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, TaskNotFoundException, InvalidWorkbasketException, InvalidArgumentException {
TaskAlreadyExistException, TaskNotFoundException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("", "dummyTask", "1", dummyClassification);
@ -430,7 +425,7 @@ public class TaskServiceImplTest {
@Test(expected = WorkbasketNotFoundException.class)
public void testCreateThrowsWorkbasketNotFoundException()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidWorkbasketException, TaskAlreadyExistException, TaskNotFoundException, InvalidArgumentException {
TaskAlreadyExistException, TaskNotFoundException, InvalidArgumentException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("", "dumma-task", "1", dummyClassification);
@ -679,7 +674,7 @@ public class TaskServiceImplTest {
@Test
public void testCompleteTaskDefault()
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, InterruptedException,
ClassificationNotFoundException, NotAuthorizedException {
NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
final long sleepTime = 100L;
Classification dummyClassification = createDummyClassification();
@ -733,7 +728,7 @@ public class TaskServiceImplTest {
@Test
public void testCompleteTaskNotForcedWorking()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, InterruptedException,
ClassificationNotFoundException, NotAuthorizedException {
NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
final long sleepTime = 100L;
Classification dummyClassification = createDummyClassification();
@ -764,8 +759,7 @@ public class TaskServiceImplTest {
@Test(expected = InvalidStateException.class)
public void testCompleteTaskNotForcedNotClaimedBefore()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, ClassificationNotFoundException,
NotAuthorizedException {
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
@ -789,8 +783,7 @@ public class TaskServiceImplTest {
@Test(expected = InvalidOwnerException.class)
public void testCompleteTaskNotForcedInvalidOwnerException()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, ClassificationNotFoundException,
NotAuthorizedException {
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
@ -815,8 +808,7 @@ public class TaskServiceImplTest {
@Test(expected = TaskNotFoundException.class)
public void testCompleteTaskTaskNotFound()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, ClassificationNotFoundException,
NotAuthorizedException {
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
String taskId = "1";
doThrow(TaskNotFoundException.class).when(cutSpy).getTask(taskId);
@ -837,7 +829,7 @@ public class TaskServiceImplTest {
@Test
public void testCompleteForcedAndAlreadyClaimed()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, InterruptedException,
ClassificationNotFoundException, NotAuthorizedException {
NotAuthorizedException {
final long sleepTime = 100L;
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
@ -868,7 +860,7 @@ public class TaskServiceImplTest {
@Test
public void testCompleteForcedNotClaimed()
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, InterruptedException,
ClassificationNotFoundException, NotAuthorizedException {
NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
final long sleepTime = 100L;
Classification dummyClassification = createDummyClassification();
@ -902,9 +894,7 @@ public class TaskServiceImplTest {
@Test
public void testTransferTaskToDestinationWorkbasketWithoutSecurity()
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
ClassificationAlreadyExistException, InvalidWorkbasketException, ClassificationNotFoundException,
InvalidStateException {
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidStateException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Workbasket destinationWorkbasket = createWorkbasket("2", "k1");
Workbasket sourceWorkbasket = createWorkbasket("47", "key47");
@ -945,9 +935,7 @@ public class TaskServiceImplTest {
@Test
public void testTransferTaskToDestinationWorkbasketUsingSecurityTrue()
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
ClassificationAlreadyExistException, InvalidWorkbasketException, ClassificationNotFoundException,
InvalidStateException {
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidStateException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Workbasket destinationWorkbasket = createWorkbasket("2", "k2");
Classification dummyClassification = createDummyClassification();
@ -1088,8 +1076,7 @@ public class TaskServiceImplTest {
@Test
public void testSetTaskReadWIthExistingTask()
throws TaskNotFoundException, ClassificationAlreadyExistException, ClassificationNotFoundException,
NotAuthorizedException {
throws TaskNotFoundException, NotAuthorizedException {
TaskServiceImpl cutSpy = Mockito.spy(cut);
Classification dummyClassification = createDummyClassification();
TaskImpl task = createUnitTestTask("1", "Unit Test Task 1", "1", dummyClassification);
@ -1132,8 +1119,7 @@ public class TaskServiceImplTest {
@Test
public void testGetTaskByIdWithExistingTask()
throws TaskNotFoundException, ClassificationAlreadyExistException, ClassificationNotFoundException,
NotAuthorizedException {
throws TaskNotFoundException, NotAuthorizedException {
Classification dummyClassification = createDummyClassification();
Task expectedTask = createUnitTestTask("1", "DUMMY-TASK", "1", dummyClassification);
doReturn(expectedTask).when(taskMapperMock).findById(expectedTask.getId());
@ -1196,7 +1182,7 @@ public class TaskServiceImplTest {
@Test
public void testUpdateTaskAddingValidAttachment() throws TaskNotFoundException, SystemException,
WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException,
InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException {
NotAuthorizedException, AttachmentPersistenceException {
Classification classification = createDummyClassification();
Workbasket wb = createWorkbasket("WB-ID", "WB-Key");
Attachment attachment = JunitHelper.createDefaultAttachment();
@ -1224,7 +1210,7 @@ public class TaskServiceImplTest {
@Test
public void testUpdateTaskAddingValidAttachmentTwice() throws TaskNotFoundException, SystemException,
WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException,
InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException {
NotAuthorizedException, AttachmentPersistenceException {
Classification classification = createDummyClassification();
Workbasket wb = createWorkbasket("WB-ID", "WB-Key");
Attachment attachment = JunitHelper.createDefaultAttachment();
@ -1254,7 +1240,7 @@ public class TaskServiceImplTest {
public void testUpdateTaskAddingAttachmentWithSameIdForcedUsingingListMethod()
throws TaskNotFoundException, SystemException,
WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException,
InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException {
NotAuthorizedException, AttachmentPersistenceException {
Classification classification = createDummyClassification();
Workbasket wb = createWorkbasket("WB-ID", "WB-Key");
Attachment attachment = JunitHelper.createDefaultAttachment();
@ -1287,7 +1273,7 @@ public class TaskServiceImplTest {
@Test
public void testUpdateTaskUpdateAttachment() throws TaskNotFoundException, SystemException,
WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException,
InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException {
NotAuthorizedException, AttachmentPersistenceException {
String channelUpdate = "OTHER CHANNEL";
Classification classification = createDummyClassification();
Workbasket wb = createWorkbasket("WB-ID", "WB-Key");
@ -1321,7 +1307,7 @@ public class TaskServiceImplTest {
@Test
public void testUpdateTaskRemovingAttachment() throws TaskNotFoundException, SystemException,
WorkbasketNotFoundException, ClassificationNotFoundException, InvalidArgumentException, ConcurrencyException,
InvalidWorkbasketException, NotAuthorizedException, AttachmentPersistenceException {
NotAuthorizedException, AttachmentPersistenceException {
Classification classification = createDummyClassification();
Workbasket wb = createWorkbasket("WB-ID", "WB-Key");
Attachment attachment = JunitHelper.createDefaultAttachment();

View File

@ -87,7 +87,7 @@ public class WorkbasketServiceImplTest {
private TaskanaEngineConfiguration taskanaEngineConfigurationMock;
@Before
public void setup() throws NotAuthorizedException {
public void setup() {
MockitoAnnotations.initMocks(this);
}
@ -222,7 +222,7 @@ public class WorkbasketServiceImplTest {
@Test
public void testCreateWorkbasket_InvalidWorkbasketCases()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketAlreadyExistException,
throws NotAuthorizedException, WorkbasketAlreadyExistException,
DomainNotFoundException {
WorkbasketImpl wb = new WorkbasketImpl();
int serviceCalls = 1;
@ -464,7 +464,7 @@ public class WorkbasketServiceImplTest {
@Test
public void testDeleteWorkbasketWithNullOrEmptyParam()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException, InvalidArgumentException {
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketInUseException {
// null param
try {
cutSpy.deleteWorkbasket(null);
@ -579,7 +579,7 @@ public class WorkbasketServiceImplTest {
}
private List<String> createTestDistributionTargets(int amount)
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException,
throws InvalidWorkbasketException, NotAuthorizedException,
WorkbasketAlreadyExistException, DomainNotFoundException {
List<String> distributionsTargets = new ArrayList<>();
amount = (amount < 0) ? 0 : amount;

View File

@ -8,7 +8,6 @@ import java.io.InputStream;
import java.sql.SQLException;
import java.util.Properties;
import javax.security.auth.login.LoginException;
import javax.sql.DataSource;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
@ -32,7 +31,7 @@ public class TaskanaEngineConfigurationTest {
private static final int POOL_TIME_TO_WAIT = 50;
@Test
public void testCreateTaskanaEngine() throws FileNotFoundException, SQLException, LoginException {
public void testCreateTaskanaEngine() throws SQLException {
DataSource ds = getDataSource();
TaskanaEngineConfiguration taskEngineConfiguration = new TaskanaEngineConfiguration(ds, false);
@ -45,13 +44,8 @@ public class TaskanaEngineConfigurationTest {
* returns the Datasource used for Junit test. If the file {user.home}/taskanaUnitTest.properties is present, the
* Datasource is created according to the properties jdbcDriver, jdbcUrl, dbUserName and dbPassword. Assuming, the
* database has the name tskdb, a sample properties file for DB2 looks as follows:
*
* jdbcDriver=com.ibm.db2.jcc.DB2Driver
* jdbcUrl=jdbc:db2://localhost:50000/tskdb
* dbUserName=db2user
* dbPassword=db2password
*
* If any of these properties is missing, or the file doesn't exist, the default Datasource
* jdbcDriver=com.ibm.db2.jcc.DB2Driver jdbcUrl=jdbc:db2://localhost:50000/tskdb dbUserName=db2user
* dbPassword=db2password If any of these properties is missing, or the file doesn't exist, the default Datasource
* for h2 in-memory db is created.
*
* @return dataSource for unit test

View File

@ -6,7 +6,6 @@ import static org.hamcrest.core.StringStartsWith.startsWith;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.io.FileNotFoundException;
import java.sql.SQLException;
import java.time.Instant;
import java.time.LocalDate;
@ -15,7 +14,6 @@ import java.time.LocalTime;
import java.time.ZoneId;
import java.util.List;
import javax.security.auth.login.LoginException;
import javax.sql.DataSource;
import org.junit.Assert;
@ -64,7 +62,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
}
@Before
public void setup() throws FileNotFoundException, SQLException, LoginException {
public void setup() throws SQLException {
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
@ -401,8 +399,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
return new TimeInterval(begin, end);
}
private Classification createDummyClassificationWithUniqueKey(String domain, String type)
throws NotAuthorizedException {
private Classification createDummyClassificationWithUniqueKey(String domain, String type) {
Classification classification = classificationService.newClassification("TEST" + counter, domain, type);
counter++;
return classification;

View File

@ -440,8 +440,7 @@ public class ClassificationServiceImplIntExplicitTest {
taskanaEngineImpl.setConnection(null);
}
private Classification createNewClassificationWithUniqueKey(String domain, String type)
throws NotAuthorizedException {
private Classification createNewClassificationWithUniqueKey(String domain, String type) {
Classification classification = classificationService.newClassification("TEST" + counter, domain, type);
counter++;
return classification;

View File

@ -5,12 +5,10 @@ import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.io.FileNotFoundException;
import java.sql.SQLException;
import java.util.List;
import java.util.UUID;
import javax.security.auth.login.LoginException;
import javax.sql.DataSource;
import org.junit.Assert;
@ -81,7 +79,7 @@ public class TaskServiceImplIntAutocommitTest {
}
@Before
public void setup() throws FileNotFoundException, SQLException, LoginException {
public void setup() throws SQLException {
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, false);
@ -96,7 +94,7 @@ public class TaskServiceImplIntAutocommitTest {
}
@Test
public void testStart() throws FileNotFoundException, SQLException, TaskNotFoundException,
public void testStart() throws TaskNotFoundException,
WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException,
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
@ -123,7 +121,7 @@ public class TaskServiceImplIntAutocommitTest {
@Test(expected = TaskNotFoundException.class)
public void testStartTransactionFail()
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
throws TaskNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException {
@ -153,7 +151,7 @@ public class TaskServiceImplIntAutocommitTest {
@Test
public void testCreateTaskInTaskanaWithDefaultDb()
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
throws SQLException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException {
@ -182,7 +180,7 @@ public class TaskServiceImplIntAutocommitTest {
}
@Test
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException,
public void should_ReturnList_when_BuilderIsUsed() throws NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, SystemException,
WorkbasketAlreadyExistException, DomainNotFoundException {
@ -279,8 +277,7 @@ public class TaskServiceImplIntAutocommitTest {
@Test(expected = TaskNotFoundException.class)
public void shouldNotTransferAnyTask()
throws WorkbasketNotFoundException, NotAuthorizedException, TaskNotFoundException, InvalidWorkbasketException,
ClassificationNotFoundException, InvalidStateException {
throws WorkbasketNotFoundException, NotAuthorizedException, TaskNotFoundException, InvalidStateException {
taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1");
}
@ -373,7 +370,7 @@ public class TaskServiceImplIntAutocommitTest {
}
@Test
public void testWithPrimaryObjectRef() throws FileNotFoundException, SQLException, TaskNotFoundException,
public void testWithPrimaryObjectRef() throws TaskNotFoundException,
WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException,
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {

View File

@ -1,496 +1,494 @@
package pro.taskana.impl.integration;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.UUID;
import javax.security.auth.login.LoginException;
import javax.sql.DataSource;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import pro.taskana.Classification;
import pro.taskana.ClassificationService;
import pro.taskana.KeyDomain;
import pro.taskana.Task;
import pro.taskana.TaskState;
import pro.taskana.TaskSummary;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketAccessItem;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketType;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.ClassificationAlreadyExistException;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.DomainNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.SystemException;
import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.ClassificationImpl;
import pro.taskana.impl.ClassificationServiceImpl;
import pro.taskana.impl.JunitHelper;
import pro.taskana.impl.TaskImpl;
import pro.taskana.impl.TaskServiceImpl;
import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.impl.WorkbasketServiceImpl;
import pro.taskana.impl.WorkbasketSummaryImpl;
import pro.taskana.impl.configuration.DBCleaner;
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
import pro.taskana.security.CurrentUserContext;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
/**
* Integration Test for TaskServiceImpl transactions with connection management mode EXPLICIT.
*
* @author EH
*/
@RunWith(JAASRunner.class)
public class TaskServiceImplIntExplicitTest {
private DataSource dataSource;
private TaskServiceImpl taskServiceImpl;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
private TaskanaEngine taskanaEngine;
private TaskanaEngineImpl taskanaEngineImpl;
private ClassificationService classificationService;
private WorkbasketService workbasketService;
@BeforeClass
public static void resetDb() throws SQLException {
DataSource ds = TaskanaEngineConfigurationTest.getDataSource();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(ds, true);
}
@Before
public void setup() throws FileNotFoundException, SQLException, LoginException {
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
classificationService = taskanaEngine.getClassificationService();
taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.EXPLICIT);
workbasketService = taskanaEngine.getWorkbasketService();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(dataSource, false);
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test(expected = TaskNotFoundException.class)
public void testStartTransactionFail()
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
workbasket.setName("workbasket");
workbasket.setId("1"); // set id manually for authorization tests
workbasket.setType(WorkbasketType.GROUP);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
taskanaEngineImpl.getWorkbasketService().createWorkbasket(workbasket);
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
workbasketService.createWorkbasketAccessItem(accessItem);
taskanaEngineImpl.getClassificationService().createClassification(classification);
connection.commit();
Task task = taskServiceImpl.newTask(workbasket.getId());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = taskServiceImpl.createTask(task);
connection.commit();
task = taskServiceImpl.getTask(task.getId());
TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
taskServiceImpl2.getTask(workbasket.getId());
connection.commit();
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test
public void testCreateTask()
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
Task task = this.generateDummyTask();
connection.commit();
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
workbasketService.createWorkbasketAccessItem(accessItem);
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = taskServiceImpl.createTask(task);
connection.commit(); // needed so that the change is visible in the other session
TaskanaEngine te2 = taskanaEngineConfiguration.buildTaskanaEngine();
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
Task resultTask = taskServiceImpl2.getTask(task.getId());
Assert.assertNotNull(resultTask);
connection.commit();
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test
public void testCreateTaskInTaskanaWithDefaultDb()
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException {
DataSource ds = TaskanaEngineConfiguration.createDefaultDataSource();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(ds, false);
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(ds, false, false);
TaskanaEngine te = taskanaEngineConfiguration.buildTaskanaEngine();
Connection connection = ds.getConnection();
te.setConnection(connection);
TaskServiceImpl taskServiceImpl = (TaskServiceImpl) te.getTaskService();
WorkbasketServiceImpl workBasketServiceImpl = (WorkbasketServiceImpl) te.getWorkbasketService();
ClassificationServiceImpl classificationServiceImpl = (ClassificationServiceImpl) te.getClassificationService();
Workbasket workbasket = workbasketService.newWorkbasket("K99", "DOMAIN_A");
workbasket.setName("workbasket");
workbasket.setName("workbasket99");
workbasket.setType(WorkbasketType.GROUP);
workbasket = workBasketServiceImpl.createWorkbasket(workbasket);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
classification = classificationServiceImpl.createClassification(classification);
Task task = taskServiceImpl.newTask(workbasket.getId());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task.addAttachment(null);
task = taskServiceImpl.createTask(task);
Assert.assertNotNull(task);
Assert.assertNotNull(task.getId());
connection.commit();
te.setConnection(null);
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test(expected = WorkbasketNotFoundException.class)
public void createTaskShouldThrowWorkbasketNotFoundException()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException,
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
Task test = this.generateDummyTask();
((WorkbasketSummaryImpl) (test.getWorkbasketSummary())).setId("2");
taskServiceImpl.createTask(test);
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test(expected = ClassificationNotFoundException.class)
public void createManualTaskShouldThrowClassificationNotFoundException()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException,
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
Workbasket wb = workbasketService.newWorkbasket("WB NR.1", "DOMAIN_A");
wb.setName("dummy-WB");
wb.setType(WorkbasketType.PERSONAL);
wb = workbasketService.createWorkbasket(wb);
this.createWorkbasketWithSecurity(wb, CurrentUserContext.getUserid(), true, true,
true, false);
Classification classification = classificationService.newClassification(
UUID.randomUUID().toString(), wb.getDomain(), "t1"); // not persisted,
// not found.
classification.setName("not persisted - so not found.");
Task task = this.generateDummyTask();
((TaskImpl) task).setWorkbasketSummary(wb.asSummary());
task.setClassificationKey(classification.getKey());
taskServiceImpl.createTask(task);
}
@WithAccessId(userName = "Elena", groupNames = {"DummyGroup", "businessadmin"})
@Test
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, SystemException,
WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
workbasket.setName("workbasket");
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
classificationService.createClassification(classification);
workbasket.setId("1"); // set id manually for authorization tests
workbasket.setType(WorkbasketType.GROUP);
workbasket = (WorkbasketImpl) workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
workbasketService.createWorkbasketAccessItem(accessItem);
Task task = taskServiceImpl.newTask(workbasket.getId());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = taskServiceImpl.createTask(task);
List<TaskSummary> results = taskServiceImpl.createTaskQuery()
.nameIn("bla", "test")
.descriptionLike("test")
.priorityIn(1, 2, 2)
.stateIn(TaskState.CLAIMED)
.workbasketKeyDomainIn(new KeyDomain("k1", "DOMAIN_A"))
.ownerIn("test", "test2", "bla")
.customAttributeLike("13", "test")
.classificationKeyIn("pId1", "pId2")
.primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh")
.primaryObjectReferenceSystemIn("sys")
.primaryObjectReferenceTypeIn("type1", "type2")
.primaryObjectReferenceSystemInstanceIn("sysInst1", "sysInst2")
.primaryObjectReferenceValueIn("val1", "val2", "val3")
.list();
Assert.assertEquals(0, results.size());
connection.commit();
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test
public void shouldTransferTaskToOtherWorkbasket()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
ClassificationAlreadyExistException, TaskNotFoundException, InterruptedException, TaskAlreadyExistException,
SQLException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException,
DomainNotFoundException, InvalidStateException {
Workbasket sourceWB;
Workbasket destinationWB;
WorkbasketImpl wb;
ClassificationImpl classification;
TaskImpl task;
Task resultTask;
final int sleepTime = 100;
final String user = CurrentUserContext.getUserid();
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
// Source Workbasket
wb = (WorkbasketImpl) workbasketService.newWorkbasket("sourceWbKey", "DOMAIN_A");
wb.setName("Basic-Workbasket");
wb.setDescription("Just used as base WB for Task here");
wb.setOwner(user);
wb.setType(WorkbasketType.PERSONAL);
sourceWB = workbasketService.createWorkbasket(wb);
createWorkbasketWithSecurity(wb, wb.getOwner(), false, false, false, false);
createWorkbasketWithSecurity(sourceWB, sourceWB.getOwner(), true, true, true, true);
// Destination Workbasket
wb = (WorkbasketImpl) workbasketService.newWorkbasket("wb2Key", "DOMAIN_A");
wb.setName("Desination-WorkBasket");
wb.setDescription("Destination WB where Task should be transfered to");
wb.setOwner(user);
wb.setType(WorkbasketType.TOPIC);
destinationWB = workbasketService.createWorkbasket(wb);
createWorkbasketWithSecurity(destinationWB, destinationWB.getOwner(), false, true, true, true);
// Classification required for Task
classification = (ClassificationImpl) classificationService.newClassification("KEY", "DOMAIN_A", "TASK");
classification.setCategory("EXTERNAL");
classification.setName("Transfert-Task Classification");
classificationService.createClassification(classification);
// Task which should be transfered
task = (TaskImpl) taskServiceImpl.newTask(sourceWB.getId());
task.setName("Task Name");
task.setDescription("Task used for transfer Test");
task.setRead(true);
task.setTransferred(false);
task.setModified(null);
task.setClassificationKey("KEY");
task.setOwner(user);
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = (TaskImpl) taskServiceImpl.createTask(task);
Thread.sleep(sleepTime); // Sleep for modification-timestamp
connection.commit();
resultTask = taskServiceImpl.transfer(task.getId(), destinationWB.getId());
connection.commit();
assertThat(resultTask.isRead(), equalTo(false));
assertThat(resultTask.isTransferred(), equalTo(true));
assertThat(resultTask.getWorkbasketKey(), equalTo(destinationWB.getKey()));
assertThat(resultTask.getModified(), not(equalTo(null)));
assertThat(resultTask.getModified(), not(equalTo(task.getModified())));
assertThat(resultTask.getCreated(), not(equalTo(null)));
assertThat(resultTask.getCreated(), equalTo(task.getCreated()));
}
@Test(expected = TaskNotFoundException.class)
public void shouldNotTransferAnyTask()
throws WorkbasketNotFoundException, NotAuthorizedException, TaskNotFoundException, SQLException,
InvalidWorkbasketException, ClassificationNotFoundException, InvalidStateException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1");
}
@WithAccessId(userName = "User", groupNames = {"businessadmin"})
@Test
public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException,
ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException,
TaskNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException, InvalidStateException {
final String user = "User";
// Set up Security for this Test
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, true);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
classificationService = taskanaEngine.getClassificationService();
workbasketService = taskanaEngine.getWorkbasketService();
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification(
"KEY", "DOMAIN_A", "TASK");
classification.setCategory("EXTERNAL");
classification.setName("Transfert-Task Classification");
classificationService.createClassification(classification);
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("wbKey1", "DOMAIN_A");
wb.setName("BASE WB");
wb.setDescription("Normal base WB");
wb.setOwner(user);
wb.setType(WorkbasketType.GROUP);
wb = (WorkbasketImpl) workbasketService.createWorkbasket(wb);
createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true);
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoAppend", "DOMAIN_B");
wbNoAppend.setName("Test-Security-WorkBasket-APPEND");
wbNoAppend.setDescription("Workbasket without permission APPEND on Task");
wbNoAppend.setOwner(user);
wbNoAppend.setType(WorkbasketType.CLEARANCE);
wbNoAppend = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoAppend);
createWorkbasketWithSecurity(wbNoAppend, wbNoAppend.getOwner(), true, true, false, true);
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoTransfer", "DOMAIN_A");
wbNoTransfer.setName("Test-Security-WorkBasket-TRANSFER");
wbNoTransfer.setDescription("Workbasket without permission TRANSFER on Task");
wbNoTransfer.setOwner(user);
wbNoTransfer.setType(WorkbasketType.GROUP);
wbNoTransfer = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoTransfer);
createWorkbasketWithSecurity(wbNoTransfer, wbNoTransfer.getOwner(), true, true, true, false);
TaskImpl task = (TaskImpl) taskServiceImpl.newTask(wb.getId());
task.setName("Task Name");
task.setDescription("Task used for transfer Test");
task.setOwner(user);
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = (TaskImpl) taskServiceImpl.createTask(task);
// Check failing with missing APPEND
try {
task = (TaskImpl) taskServiceImpl.transfer(task.getId(), wbNoAppend.getId());
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.");
} catch (NotAuthorizedException e) {
if (!e.getMessage().contains("APPEND")) {
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.");
}
assertThat(task.isTransferred(), equalTo(false));
assertThat(task.getWorkbasketKey(), not(equalTo(wbNoAppend.getKey())));
assertThat(task.getWorkbasketKey(), equalTo(wb.getKey()));
}
// Check failing with missing TRANSFER
task.setId("");
task.setWorkbasketKey(wbNoTransfer.getKey());
task.getWorkbasketSummaryImpl().setId(wbNoTransfer.getId());
task = (TaskImpl) taskServiceImpl.createTask(task);
try {
task = (TaskImpl) taskServiceImpl.transfer(task.getId(), wb.getId());
fail("Transfer Task should be FAILD, because there are no TRANSFER-Rights on current WB.");
} catch (NotAuthorizedException e) {
if (!e.getMessage().contains("TRANSFER")) {
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on current WB.");
}
assertThat(task.isTransferred(), equalTo(false));
assertThat(task.getWorkbasketKey(), not(equalTo(wbNoAppend.getKey())));
}
}
private Task generateDummyTask() throws ClassificationAlreadyExistException, ClassificationNotFoundException,
WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException,
WorkbasketAlreadyExistException, DomainNotFoundException, InvalidArgumentException {
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("wb", "DOMAIN_A");
workbasket.setName("wb");
workbasket.setId("1"); // set id manually for authorization tests
workbasket.setType(WorkbasketType.GROUP);
taskanaEngine.getWorkbasketService().createWorkbasket(workbasket);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
taskanaEngine.getClassificationService().createClassification(classification);
Task task = taskServiceImpl.newTask(workbasket.getId());
task.setClassificationKey(classification.getKey());
return task;
}
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
boolean permRead, boolean permAppend, boolean permTransfer)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen);
accessItem.setPermRead(permRead);
accessItem.setPermAppend(permAppend);
accessItem.setPermTransfer(permTransfer);
workbasketService.createWorkbasketAccessItem(accessItem);
}
@After
public void cleanUp() throws SQLException {
taskanaEngineImpl.setConnection(null);
}
}
package pro.taskana.impl.integration;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.UUID;
import javax.sql.DataSource;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import pro.taskana.Classification;
import pro.taskana.ClassificationService;
import pro.taskana.KeyDomain;
import pro.taskana.Task;
import pro.taskana.TaskState;
import pro.taskana.TaskSummary;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketAccessItem;
import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketType;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.ClassificationAlreadyExistException;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.DomainNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.SystemException;
import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.ClassificationImpl;
import pro.taskana.impl.ClassificationServiceImpl;
import pro.taskana.impl.JunitHelper;
import pro.taskana.impl.TaskImpl;
import pro.taskana.impl.TaskServiceImpl;
import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.impl.WorkbasketServiceImpl;
import pro.taskana.impl.WorkbasketSummaryImpl;
import pro.taskana.impl.configuration.DBCleaner;
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
import pro.taskana.security.CurrentUserContext;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
/**
* Integration Test for TaskServiceImpl transactions with connection management mode EXPLICIT.
*
* @author EH
*/
@RunWith(JAASRunner.class)
public class TaskServiceImplIntExplicitTest {
private DataSource dataSource;
private TaskServiceImpl taskServiceImpl;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
private TaskanaEngine taskanaEngine;
private TaskanaEngineImpl taskanaEngineImpl;
private ClassificationService classificationService;
private WorkbasketService workbasketService;
@BeforeClass
public static void resetDb() throws SQLException {
DataSource ds = TaskanaEngineConfigurationTest.getDataSource();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(ds, true);
}
@Before
public void setup() throws SQLException {
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
classificationService = taskanaEngine.getClassificationService();
taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.EXPLICIT);
workbasketService = taskanaEngine.getWorkbasketService();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(dataSource, false);
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test(expected = TaskNotFoundException.class)
public void testStartTransactionFail()
throws SQLException, TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException,
ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
workbasket.setName("workbasket");
workbasket.setId("1"); // set id manually for authorization tests
workbasket.setType(WorkbasketType.GROUP);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
taskanaEngineImpl.getWorkbasketService().createWorkbasket(workbasket);
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
workbasketService.createWorkbasketAccessItem(accessItem);
taskanaEngineImpl.getClassificationService().createClassification(classification);
connection.commit();
Task task = taskServiceImpl.newTask(workbasket.getId());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = taskServiceImpl.createTask(task);
connection.commit();
task = taskServiceImpl.getTask(task.getId());
TaskanaEngineImpl te2 = (TaskanaEngineImpl) taskanaEngineConfiguration.buildTaskanaEngine();
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
taskServiceImpl2.getTask(workbasket.getId());
connection.commit();
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test
public void testCreateTask()
throws SQLException, TaskNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
Task task = this.generateDummyTask();
connection.commit();
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
workbasketService.createWorkbasketAccessItem(accessItem);
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = taskServiceImpl.createTask(task);
connection.commit(); // needed so that the change is visible in the other session
TaskanaEngine te2 = taskanaEngineConfiguration.buildTaskanaEngine();
TaskServiceImpl taskServiceImpl2 = (TaskServiceImpl) te2.getTaskService();
Task resultTask = taskServiceImpl2.getTask(task.getId());
Assert.assertNotNull(resultTask);
connection.commit();
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test
public void testCreateTaskInTaskanaWithDefaultDb()
throws SQLException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException {
DataSource ds = TaskanaEngineConfiguration.createDefaultDataSource();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(ds, false);
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(ds, false, false);
TaskanaEngine te = taskanaEngineConfiguration.buildTaskanaEngine();
Connection connection = ds.getConnection();
te.setConnection(connection);
TaskServiceImpl taskServiceImpl = (TaskServiceImpl) te.getTaskService();
WorkbasketServiceImpl workBasketServiceImpl = (WorkbasketServiceImpl) te.getWorkbasketService();
ClassificationServiceImpl classificationServiceImpl = (ClassificationServiceImpl) te.getClassificationService();
Workbasket workbasket = workbasketService.newWorkbasket("K99", "DOMAIN_A");
workbasket.setName("workbasket");
workbasket.setName("workbasket99");
workbasket.setType(WorkbasketType.GROUP);
workbasket = workBasketServiceImpl.createWorkbasket(workbasket);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
classification = classificationServiceImpl.createClassification(classification);
Task task = taskServiceImpl.newTask(workbasket.getId());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task.addAttachment(null);
task = taskServiceImpl.createTask(task);
Assert.assertNotNull(task);
Assert.assertNotNull(task.getId());
connection.commit();
te.setConnection(null);
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test(expected = WorkbasketNotFoundException.class)
public void createTaskShouldThrowWorkbasketNotFoundException()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException,
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
Task test = this.generateDummyTask();
((WorkbasketSummaryImpl) (test.getWorkbasketSummary())).setId("2");
taskServiceImpl.createTask(test);
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test(expected = ClassificationNotFoundException.class)
public void createManualTaskShouldThrowClassificationNotFoundException()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException,
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
Workbasket wb = workbasketService.newWorkbasket("WB NR.1", "DOMAIN_A");
wb.setName("dummy-WB");
wb.setType(WorkbasketType.PERSONAL);
wb = workbasketService.createWorkbasket(wb);
this.createWorkbasketWithSecurity(wb, CurrentUserContext.getUserid(), true, true,
true, false);
Classification classification = classificationService.newClassification(
UUID.randomUUID().toString(), wb.getDomain(), "t1"); // not persisted,
// not found.
classification.setName("not persisted - so not found.");
Task task = this.generateDummyTask();
((TaskImpl) task).setWorkbasketSummary(wb.asSummary());
task.setClassificationKey(classification.getKey());
taskServiceImpl.createTask(task);
}
@WithAccessId(userName = "Elena", groupNames = {"DummyGroup", "businessadmin"})
@Test
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, SystemException,
WorkbasketAlreadyExistException, DomainNotFoundException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
workbasket.setName("workbasket");
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
classificationService.createClassification(classification);
workbasket.setId("1"); // set id manually for authorization tests
workbasket.setType(WorkbasketType.GROUP);
workbasket = (WorkbasketImpl) workbasketService.createWorkbasket(workbasket);
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "Elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
accessItem.setPermOpen(true);
workbasketService.createWorkbasketAccessItem(accessItem);
Task task = taskServiceImpl.newTask(workbasket.getId());
task.setName("Unit Test Task");
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = taskServiceImpl.createTask(task);
List<TaskSummary> results = taskServiceImpl.createTaskQuery()
.nameIn("bla", "test")
.descriptionLike("test")
.priorityIn(1, 2, 2)
.stateIn(TaskState.CLAIMED)
.workbasketKeyDomainIn(new KeyDomain("k1", "DOMAIN_A"))
.ownerIn("test", "test2", "bla")
.customAttributeLike("13", "test")
.classificationKeyIn("pId1", "pId2")
.primaryObjectReferenceCompanyIn("first comp", "sonstwo gmbh")
.primaryObjectReferenceSystemIn("sys")
.primaryObjectReferenceTypeIn("type1", "type2")
.primaryObjectReferenceSystemInstanceIn("sysInst1", "sysInst2")
.primaryObjectReferenceValueIn("val1", "val2", "val3")
.list();
Assert.assertEquals(0, results.size());
connection.commit();
}
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
@Test
public void shouldTransferTaskToOtherWorkbasket()
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
ClassificationAlreadyExistException, TaskNotFoundException, InterruptedException, TaskAlreadyExistException,
SQLException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException,
DomainNotFoundException, InvalidStateException {
Workbasket sourceWB;
Workbasket destinationWB;
WorkbasketImpl wb;
ClassificationImpl classification;
TaskImpl task;
Task resultTask;
final int sleepTime = 100;
final String user = CurrentUserContext.getUserid();
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
// Source Workbasket
wb = (WorkbasketImpl) workbasketService.newWorkbasket("sourceWbKey", "DOMAIN_A");
wb.setName("Basic-Workbasket");
wb.setDescription("Just used as base WB for Task here");
wb.setOwner(user);
wb.setType(WorkbasketType.PERSONAL);
sourceWB = workbasketService.createWorkbasket(wb);
createWorkbasketWithSecurity(wb, wb.getOwner(), false, false, false, false);
createWorkbasketWithSecurity(sourceWB, sourceWB.getOwner(), true, true, true, true);
// Destination Workbasket
wb = (WorkbasketImpl) workbasketService.newWorkbasket("wb2Key", "DOMAIN_A");
wb.setName("Desination-WorkBasket");
wb.setDescription("Destination WB where Task should be transfered to");
wb.setOwner(user);
wb.setType(WorkbasketType.TOPIC);
destinationWB = workbasketService.createWorkbasket(wb);
createWorkbasketWithSecurity(destinationWB, destinationWB.getOwner(), false, true, true, true);
// Classification required for Task
classification = (ClassificationImpl) classificationService.newClassification("KEY", "DOMAIN_A", "TASK");
classification.setCategory("EXTERNAL");
classification.setName("Transfert-Task Classification");
classificationService.createClassification(classification);
// Task which should be transfered
task = (TaskImpl) taskServiceImpl.newTask(sourceWB.getId());
task.setName("Task Name");
task.setDescription("Task used for transfer Test");
task.setRead(true);
task.setTransferred(false);
task.setModified(null);
task.setClassificationKey("KEY");
task.setOwner(user);
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = (TaskImpl) taskServiceImpl.createTask(task);
Thread.sleep(sleepTime); // Sleep for modification-timestamp
connection.commit();
resultTask = taskServiceImpl.transfer(task.getId(), destinationWB.getId());
connection.commit();
assertThat(resultTask.isRead(), equalTo(false));
assertThat(resultTask.isTransferred(), equalTo(true));
assertThat(resultTask.getWorkbasketKey(), equalTo(destinationWB.getKey()));
assertThat(resultTask.getModified(), not(equalTo(null)));
assertThat(resultTask.getModified(), not(equalTo(task.getModified())));
assertThat(resultTask.getCreated(), not(equalTo(null)));
assertThat(resultTask.getCreated(), equalTo(task.getCreated()));
}
@Test(expected = TaskNotFoundException.class)
public void shouldNotTransferAnyTask()
throws WorkbasketNotFoundException, NotAuthorizedException, TaskNotFoundException, SQLException,
InvalidStateException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1");
}
@WithAccessId(userName = "User", groupNames = {"businessadmin"})
@Test
public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException,
ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException,
TaskNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException, InvalidStateException {
final String user = "User";
// Set up Security for this Test
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, true);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
classificationService = taskanaEngine.getClassificationService();
workbasketService = taskanaEngine.getWorkbasketService();
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification(
"KEY", "DOMAIN_A", "TASK");
classification.setCategory("EXTERNAL");
classification.setName("Transfert-Task Classification");
classificationService.createClassification(classification);
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("wbKey1", "DOMAIN_A");
wb.setName("BASE WB");
wb.setDescription("Normal base WB");
wb.setOwner(user);
wb.setType(WorkbasketType.GROUP);
wb = (WorkbasketImpl) workbasketService.createWorkbasket(wb);
createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true);
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoAppend", "DOMAIN_B");
wbNoAppend.setName("Test-Security-WorkBasket-APPEND");
wbNoAppend.setDescription("Workbasket without permission APPEND on Task");
wbNoAppend.setOwner(user);
wbNoAppend.setType(WorkbasketType.CLEARANCE);
wbNoAppend = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoAppend);
createWorkbasketWithSecurity(wbNoAppend, wbNoAppend.getOwner(), true, true, false, true);
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoTransfer", "DOMAIN_A");
wbNoTransfer.setName("Test-Security-WorkBasket-TRANSFER");
wbNoTransfer.setDescription("Workbasket without permission TRANSFER on Task");
wbNoTransfer.setOwner(user);
wbNoTransfer.setType(WorkbasketType.GROUP);
wbNoTransfer = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoTransfer);
createWorkbasketWithSecurity(wbNoTransfer, wbNoTransfer.getOwner(), true, true, true, false);
TaskImpl task = (TaskImpl) taskServiceImpl.newTask(wb.getId());
task.setName("Task Name");
task.setDescription("Task used for transfer Test");
task.setOwner(user);
task.setClassificationKey(classification.getKey());
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task = (TaskImpl) taskServiceImpl.createTask(task);
// Check failing with missing APPEND
try {
task = (TaskImpl) taskServiceImpl.transfer(task.getId(), wbNoAppend.getId());
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.");
} catch (NotAuthorizedException e) {
if (!e.getMessage().contains("APPEND")) {
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on destination WB.");
}
assertThat(task.isTransferred(), equalTo(false));
assertThat(task.getWorkbasketKey(), not(equalTo(wbNoAppend.getKey())));
assertThat(task.getWorkbasketKey(), equalTo(wb.getKey()));
}
// Check failing with missing TRANSFER
task.setId("");
task.setWorkbasketKey(wbNoTransfer.getKey());
task.getWorkbasketSummaryImpl().setId(wbNoTransfer.getId());
task = (TaskImpl) taskServiceImpl.createTask(task);
try {
task = (TaskImpl) taskServiceImpl.transfer(task.getId(), wb.getId());
fail("Transfer Task should be FAILD, because there are no TRANSFER-Rights on current WB.");
} catch (NotAuthorizedException e) {
if (!e.getMessage().contains("TRANSFER")) {
fail("Transfer Task should be FAILD, because there are no APPEND-Rights on current WB.");
}
assertThat(task.isTransferred(), equalTo(false));
assertThat(task.getWorkbasketKey(), not(equalTo(wbNoAppend.getKey())));
}
}
private Task generateDummyTask() throws ClassificationAlreadyExistException, ClassificationNotFoundException,
InvalidWorkbasketException, NotAuthorizedException,
WorkbasketAlreadyExistException, DomainNotFoundException, InvalidArgumentException {
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("wb", "DOMAIN_A");
workbasket.setName("wb");
workbasket.setId("1"); // set id manually for authorization tests
workbasket.setType(WorkbasketType.GROUP);
taskanaEngine.getWorkbasketService().createWorkbasket(workbasket);
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "TASK");
taskanaEngine.getClassificationService().createClassification(classification);
Task task = taskServiceImpl.newTask(workbasket.getId());
task.setClassificationKey(classification.getKey());
return task;
}
private void createWorkbasketWithSecurity(Workbasket wb, String accessId, boolean permOpen,
boolean permRead, boolean permAppend, boolean permTransfer)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), accessId);
accessItem.setPermOpen(permOpen);
accessItem.setPermRead(permRead);
accessItem.setPermAppend(permAppend);
accessItem.setPermTransfer(permTransfer);
workbasketService.createWorkbasketAccessItem(accessItem);
}
@After
public void cleanUp() throws SQLException {
taskanaEngineImpl.setConnection(null);
}
}

View File

@ -1,6 +1,5 @@
package pro.taskana.impl.integration;
import java.io.FileNotFoundException;
import java.sql.SQLException;
import java.time.Duration;
import java.time.Instant;
@ -12,7 +11,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.security.auth.login.LoginException;
import javax.sql.DataSource;
import org.apache.ibatis.session.SqlSession;
@ -73,7 +71,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
}
@Before
public void setup() throws FileNotFoundException, SQLException, LoginException {
public void setup() throws SQLException {
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
@ -87,7 +85,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
@Test(expected = WorkbasketNotFoundException.class)
public void testGetWorkbasketFail()
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
throws WorkbasketNotFoundException, NotAuthorizedException {
workBasketService.getWorkbasket("fail");
}
@ -224,8 +222,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
workBasketService.createWorkbasketAccessItem(accessItem);
}
private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type)
throws NotAuthorizedException {
private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type) {
WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket(key, domain);
wb.setId(id);
wb.setName(name);

View File

@ -1,13 +1,11 @@
package pro.taskana.impl.integration;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.security.auth.login.LoginException;
import javax.sql.DataSource;
import org.junit.After;
@ -63,7 +61,7 @@ public class WorkbasketServiceImplIntExplicitTest {
}
@Before
public void setup() throws FileNotFoundException, SQLException, LoginException {
public void setup() throws SQLException {
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
@ -178,8 +176,7 @@ public class WorkbasketServiceImplIntExplicitTest {
workBasketService.createWorkbasketAccessItem(accessItem);
}
private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type)
throws NotAuthorizedException {
private Workbasket createTestWorkbasket(String id, String key, String domain, String name, WorkbasketType type) {
WorkbasketImpl wb = (WorkbasketImpl) workBasketService.newWorkbasket(key, domain);
wb.setId(id);
wb.setName(name);

View File

@ -10,7 +10,6 @@ import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidOwnerException;
import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.TaskNotFoundException;
@ -25,8 +24,8 @@ public class ExampleBootstrap {
@PostConstruct
public void test() throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException,
ClassificationNotFoundException, InvalidStateException, InvalidOwnerException, InvalidWorkbasketException,
TaskAlreadyExistException, InvalidArgumentException {
ClassificationNotFoundException, InvalidStateException, InvalidOwnerException, TaskAlreadyExistException,
InvalidArgumentException {
System.out.println("---------------------------> Start App");
Task task = taskService.newTask("1");
task.setName("Spring example task");

View File

@ -67,8 +67,7 @@ public class TaskanaConfig {
}
@Bean
public TaskanaEngine taskanaEngine(SpringTaskanaEngineConfiguration taskanaEngineConfiguration)
throws SQLException {
public TaskanaEngine taskanaEngine(SpringTaskanaEngineConfiguration taskanaEngineConfiguration) {
TaskanaEngine taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
// taskanaEngine.setConnectionManagementMode(TaskanaEngine.ConnectionManagementMode.EXPLICIT);
return taskanaEngine;

View File

@ -15,7 +15,6 @@ import pro.taskana.exceptions.DomainNotFoundException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.impl.util.IdGenerator;
@ -54,7 +53,7 @@ public class TaskanaTestController {
@Transactional(rollbackFor = Exception.class)
@RequestMapping("/transaction")
public @ResponseBody String transaction(@RequestParam(value = "rollback", defaultValue = "false") String rollback)
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException,
throws InvalidWorkbasketException, NotAuthorizedException,
WorkbasketAlreadyExistException, DomainNotFoundException {
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key", "workbasket"));
@ -70,7 +69,7 @@ public class TaskanaTestController {
@RequestMapping("/transaction-many")
public @ResponseBody String transactionMany(
@RequestParam(value = "rollback", defaultValue = "false") String rollback)
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException,
throws InvalidWorkbasketException, NotAuthorizedException,
WorkbasketAlreadyExistException, DomainNotFoundException {
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key1", "workbasket1"));
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key2", "workbasket2"));
@ -87,7 +86,7 @@ public class TaskanaTestController {
@RequestMapping("/geschbuch")
public @ResponseBody String transactionGeschbuch(
@RequestParam(value = "rollback", defaultValue = "false") String rollback)
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException,
throws InvalidWorkbasketException, NotAuthorizedException,
WorkbasketAlreadyExistException, DomainNotFoundException {
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key1", "workbasket1"));
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key2", "workbasket2"));
@ -120,7 +119,7 @@ public class TaskanaTestController {
return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM GESCHBUCH.TEST", Integer.class);
}
private Workbasket createWorkBasket(String key, String name) throws NotAuthorizedException {
private Workbasket createWorkBasket(String key, String name) {
WorkbasketImpl workbasket = (WorkbasketImpl) taskanaEngine.getWorkbasketService().newWorkbasket(key,
"DOMAIN_A");
String id1 = IdGenerator.generateWithPrefix("TWB");

View File

@ -1,26 +1,24 @@
package pro.taskana;
import java.sql.SQLException;
import javax.annotation.PostConstruct;
import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
import pro.taskana.configuration.SpringTaskanaEngineConfiguration;
import pro.taskana.impl.TaskanaEngineImpl;
/**
* This class configures the TaskanaEngine for spring
*/
public class SpringTaskanaEngineImpl extends TaskanaEngineImpl {
public SpringTaskanaEngineImpl(SpringTaskanaEngineConfiguration taskanaEngineConfiguration) {
super(taskanaEngineConfiguration);
}
@PostConstruct
public void init() throws SQLException {
this.transactionFactory = new SpringManagedTransactionFactory();
this.sessionManager = createSqlSessionManager();
}
}
package pro.taskana;
import javax.annotation.PostConstruct;
import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
import pro.taskana.configuration.SpringTaskanaEngineConfiguration;
import pro.taskana.impl.TaskanaEngineImpl;
/**
* This class configures the TaskanaEngine for spring
*/
public class SpringTaskanaEngineImpl extends TaskanaEngineImpl {
public SpringTaskanaEngineImpl(SpringTaskanaEngineConfiguration taskanaEngineConfiguration) {
super(taskanaEngineConfiguration);
}
@PostConstruct
public void init() {
this.transactionFactory = new SpringManagedTransactionFactory();
this.sessionManager = createSqlSessionManager();
}
}

View File

@ -6,7 +6,6 @@ import org.springframework.transaction.annotation.Transactional;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
@ -23,8 +22,7 @@ public class TaskanaComponent {
}
public void triggerRollback() throws NotAuthorizedException, WorkbasketNotFoundException,
ClassificationNotFoundException, InvalidWorkbasketException, TaskAlreadyExistException,
InvalidArgumentException {
ClassificationNotFoundException, TaskAlreadyExistException, InvalidArgumentException {
Task task = taskService.newTask("1");
task.setName("Unit Test Task");
ObjectReference objRef = new ObjectReference();

View File

@ -37,7 +37,7 @@ public class SampleDataGenerator {
runner = new ScriptRunner(dataSource.getConnection());
}
public void generateSampleData() throws SQLException {
public void generateSampleData() {
StringWriter outWriter = new StringWriter();
PrintWriter logWriter = new PrintWriter(outWriter);

View File

@ -120,7 +120,6 @@ public class LdapClient {
message += " taskana.ldap.groupNameAttribute is not configured.";
}
if (!message.equals(emptyMessage)) {
LOGGER.error("Ldap configuration error detected: {}", message);
throw new SystemException(message);
}
active = true;
@ -130,7 +129,6 @@ public class LdapClient {
public List<AccessIdResource> searchUsersAndGroups(final String name) throws InvalidArgumentException {
LOGGER.debug("entry to searchUsersAndGroups(name = {})", name);
if (!active) {
LOGGER.error("LdapClient was called but is not active due to missing configuration: " + message);
throw new SystemException(
"LdapClient was called but is not active due to missing configuration: " + message);
}
@ -155,7 +153,6 @@ public class LdapClient {
public List<AccessIdResource> searchUsersByName(final String name) throws InvalidArgumentException {
LOGGER.debug("entry to searchUsersByName(name = {}).", name);
if (!active) {
LOGGER.error("LdapClient was called but is not active due to missing configuration: " + message);
throw new SystemException(
"LdapClient was called but is not active due to missing configuration: " + message);
}
@ -176,22 +173,17 @@ public class LdapClient {
String[] userAttributesToReturn = {getUserFirstnameAttribute(), getUserLastnameAttribute(),
getUserIdAttribute()};
try {
final List<AccessIdResource> accessIds = ldapTemplate.search(getUserSearchBase(), andFilter.encode(),
SearchControls.SUBTREE_SCOPE, userAttributesToReturn, new UserContextMapper());
LOGGER.debug("exit from searchUsersByName. Retrieved the following users: {}.",
LoggerUtils.listToString(accessIds));
return accessIds;
} catch (Exception e) {
LOGGER.error("caught Exception {} ", e.getMessage());
throw e;
}
final List<AccessIdResource> accessIds = ldapTemplate.search(getUserSearchBase(), andFilter.encode(),
SearchControls.SUBTREE_SCOPE, userAttributesToReturn, new UserContextMapper());
LOGGER.debug("exit from searchUsersByName. Retrieved the following users: {}.",
LoggerUtils.listToString(accessIds));
return accessIds;
}
public List<AccessIdResource> searchGroupsByName(final String name) throws InvalidArgumentException {
LOGGER.debug("entry to searchGroupsByName(name = {}).", name);
if (!active) {
LOGGER.error("LdapClient was called but is not active due to missing configuration: " + message);
throw new SystemException(
"LdapClient was called but is not active due to missing configuration: " + message);
}
@ -216,16 +208,11 @@ public class LdapClient {
groupAttributesToReturn = new String[] {getGroupNameAttribute(), CN};
}
try {
final List<AccessIdResource> accessIds = ldapTemplate.search(getGroupSearchBase(), andFilter.encode(),
SearchControls.SUBTREE_SCOPE, groupAttributesToReturn, new GroupContextMapper());
LOGGER.debug("Exit from searchGroupsByName. Retrieved the following groups: {}",
LoggerUtils.listToString(accessIds));
return accessIds;
} catch (Exception e) {
LOGGER.error("caught Exception {} ", e.getMessage());
throw e;
}
final List<AccessIdResource> accessIds = ldapTemplate.search(getGroupSearchBase(), andFilter.encode(),
SearchControls.SUBTREE_SCOPE, groupAttributesToReturn, new GroupContextMapper());
LOGGER.debug("Exit from searchGroupsByName. Retrieved the following groups: {}",
LoggerUtils.listToString(accessIds));
return accessIds;
}

View File

@ -22,7 +22,7 @@ public abstract class AbstractPagingController {
pagesize = Long.valueOf(pagesizeParam);
page = Long.valueOf(pageParam);
} catch (NumberFormatException e) {
throw new InvalidArgumentException("page and pagesize must be a integer value.");
throw new InvalidArgumentException("page and pagesize must be a integer value.", e.getCause());
}
PageMetadata pageMetadata = new PageMetadata(pagesize, page, totalElements);
if (pageMetadata.getNumber() > pageMetadata.getTotalPages()) {

View File

@ -194,7 +194,7 @@ public class ClassificationController extends AbstractPagingController {
}
private ClassificationQuery applyFilterParams(ClassificationQuery query,
MultiValueMap<String, String> params) throws InvalidArgumentException {
MultiValueMap<String, String> params) {
if (params.containsKey(NAME)) {
String[] names = extractCommaSeparatedFields(params.get(NAME));
query.nameIn(names);

View File

@ -91,7 +91,7 @@ public class TaskController extends AbstractPagingController {
@GetMapping
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<PagedResources<TaskSummaryResource>> getTasks(
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException, NotAuthorizedException {
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
TaskQuery query = taskService.createTaskQuery();
query = applyFilterParams(query, params);
@ -171,7 +171,7 @@ public class TaskController extends AbstractPagingController {
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<TaskResource> createTask(@RequestBody TaskResource taskResource)
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException {
TaskAlreadyExistException, InvalidArgumentException {
Task createdTask = taskService.createTask(taskResourceAssembler.toModel(taskResource));
ResponseEntity<TaskResource> result = new ResponseEntity<>(taskResourceAssembler.toResource(createdTask),
HttpStatus.CREATED);
@ -212,7 +212,7 @@ public class TaskController extends AbstractPagingController {
}
private TaskQuery applyFilterParams(TaskQuery taskQuery, MultiValueMap<String, String> params)
throws NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
// apply filters
if (params.containsKey(NAME)) {
@ -292,7 +292,7 @@ public class TaskController extends AbstractPagingController {
}
private TaskQuery applySortingParams(TaskQuery taskQuery, MultiValueMap<String, String> params)
throws NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
// sorting
String sortBy = params.getFirst(SORT_BY);

View File

@ -13,7 +13,6 @@ import pro.taskana.TaskService;
import pro.taskana.TaskState;
import pro.taskana.TaskSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
/**
* TODO.
@ -51,12 +50,12 @@ public class TaskFilter {
@Autowired
private TaskService taskService;
public List<TaskSummary> getAll() throws NotAuthorizedException {
public List<TaskSummary> getAll() {
return taskService.createTaskQuery().list();
}
public List<TaskSummary> inspectParams(MultiValueMap<String, String> params)
throws NotAuthorizedException, InvalidArgumentException {
throws InvalidArgumentException {
TaskQuery taskQuery = taskService.createTaskQuery();
// apply filters

View File

@ -42,7 +42,7 @@ public class ClassificationResourceAssembler {
return addLinks(resource, classification);
}
public Classification toModel(ClassificationResource classificationResource) throws NotAuthorizedException {
public Classification toModel(ClassificationResource classificationResource) {
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification(
classificationResource.domain, classificationResource.key, classificationResource.type);
BeanUtils.copyProperties(classificationResource, classification);

View File

@ -108,7 +108,7 @@ public class TaskResourceAssembler
resource.setCustom16(task.getCustomAttribute("16"));
}
} catch (InvalidArgumentException e) {
throw new SystemException("caught unexpected Exception " + e);
throw new SystemException("caught unexpected Exception.", e.getCause());
}
return resource;

View File

@ -94,7 +94,7 @@ public class TaskSummaryResourceAssembler
resource.setCustom16(taskSummary.getCustomAttribute("16"));
}
} catch (InvalidArgumentException e) {
throw new SystemException("caught unexpected Exception " + e);
throw new SystemException("caught unexpected Exception.", e.getCause());
}
return resource;

View File

@ -37,7 +37,7 @@ public class WorkbasketAssembler {
return addLinks(resource, wb);
}
public Workbasket toModel(WorkbasketResource wbResource) throws NotAuthorizedException {
public Workbasket toModel(WorkbasketResource wbResource) {
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket(wbResource.key, wbResource.domain);
BeanUtils.copyProperties(wbResource, workbasket);
@ -55,7 +55,8 @@ public class WorkbasketAssembler {
resource.add(linkTo(methodOn(WorkbasketController.class).getWorkbasketAccessItems(wb.getId()))
.withRel("accessItems"));
resource.add(linkTo(WorkbasketController.class).withRel("allWorkbaskets"));
resource.add(linkTo(methodOn(WorkbasketController.class).removeDistributionTargetForWorkbasketId(wb.getId())).withRel("removeDistributionTargets"));
resource.add(linkTo(methodOn(WorkbasketController.class).removeDistributionTargetForWorkbasketId(wb.getId()))
.withRel("removeDistributionTargets"));
return resource;
}
}

View File

@ -68,7 +68,7 @@ public class ClassificationAssemblerTest {
}
@Test
public void resourceToClassification() throws NotAuthorizedException {
public void resourceToClassification() {
// given
ClassificationResource classificationResource = new ClassificationResource();
classificationResource.setClassificationId("1");
@ -95,7 +95,8 @@ public class ClassificationAssemblerTest {
classificationResource.setServiceLevel("P1D");
classificationResource.setDescription("Test");
// when
ClassificationImpl classification = (ClassificationImpl) classificationResourceAssembler.toModel(classificationResource);
ClassificationImpl classification = (ClassificationImpl) classificationResourceAssembler
.toModel(classificationResource);
// then
testEquality(classification, classificationResource);
}

View File

@ -58,7 +58,7 @@ public class WorkbasketAssemblerTest {
}
@Test
public void resourceToWorkbasket() throws NotAuthorizedException {
public void resourceToWorkbasket() {
// given
WorkbasketResource workbasketResource = new WorkbasketResource();
workbasketResource.setWorkbasketId("1");