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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -237,7 +237,8 @@ public class ClassificationServiceImpl implements ClassificationService {
try { try {
Duration.parse(classification.getServiceLevel()); Duration.parse(classification.getServiceLevel());
} catch (Exception e) { } 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(); taskanaEngine.openConnection();
result = classificationMapper.findById(id); result = classificationMapper.findById(id);
if (result == null) { 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"); throw new ClassificationNotFoundException(id, "Classification for id " + id + " was not found");
} }
return result; return result;
@ -303,9 +303,6 @@ public class ClassificationServiceImpl implements ClassificationService {
if (result == null) { if (result == null) {
result = classificationMapper.findByKeyAndDomain(key, ""); result = classificationMapper.findByKeyAndDomain(key, "");
if (result == null) { if (result == null) {
LOGGER.error(
"Classification for key {} and domain {} was not found. Throwing ClassificationNotFoundException",
key, domain);
throw new ClassificationNotFoundException(key, domain, throw new ClassificationNotFoundException(key, domain,
"Classification for key " + key + " was not found"); "Classification for key " + key + " was not found");
} }
@ -400,7 +397,8 @@ public class ClassificationServiceImpl implements ClassificationService {
} catch (PersistenceException e) { } catch (PersistenceException e) {
if (isReferentialIntegrityConstraintViolation(e)) { if (isReferentialIntegrityConstraintViolation(e)) {
throw new ClassificationInUseException("The classification " + classificationId 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 { } finally {

View File

@ -332,7 +332,8 @@ public class TaskImpl implements Task {
num = Integer.parseInt(number); num = Integer.parseInt(number);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new InvalidArgumentException( 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) { switch (num) {
@ -382,7 +383,8 @@ public class TaskImpl implements Task {
num = Integer.parseInt(number); num = Integer.parseInt(number);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new InvalidArgumentException( 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) { switch (num) {

View File

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

View File

@ -372,7 +372,8 @@ public class TaskSummaryImpl implements TaskSummary {
num = Integer.parseInt(number); num = Integer.parseInt(number);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new InvalidArgumentException( 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) { switch (num) {

View File

@ -1,400 +1,394 @@
package pro.taskana.impl; package pro.taskana.impl;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.Arrays; import java.util.Arrays;
import java.util.Deque; import java.util.Deque;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.ibatis.mapping.Environment; import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration; import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder; import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.ibatis.session.SqlSessionManager; import org.apache.ibatis.session.SqlSessionManager;
import org.apache.ibatis.transaction.TransactionFactory; import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory; import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.apache.ibatis.transaction.managed.ManagedTransactionFactory; import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import pro.taskana.ClassificationService; import pro.taskana.ClassificationService;
import pro.taskana.TaskMonitorService; import pro.taskana.TaskMonitorService;
import pro.taskana.TaskService; import pro.taskana.TaskService;
import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaRole; import pro.taskana.TaskanaRole;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.AutocommitFailedException; import pro.taskana.exceptions.AutocommitFailedException;
import pro.taskana.exceptions.ConnectionNotSetException; import pro.taskana.exceptions.ConnectionNotSetException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.SystemException; import pro.taskana.exceptions.SystemException;
import pro.taskana.exceptions.UnsupportedDatabaseException; import pro.taskana.exceptions.UnsupportedDatabaseException;
import pro.taskana.impl.persistence.MapTypeHandler; import pro.taskana.impl.persistence.MapTypeHandler;
import pro.taskana.impl.util.LoggerUtils; import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.mappings.AttachmentMapper; import pro.taskana.mappings.AttachmentMapper;
import pro.taskana.mappings.ClassificationMapper; import pro.taskana.mappings.ClassificationMapper;
import pro.taskana.mappings.DistributionTargetMapper; import pro.taskana.mappings.DistributionTargetMapper;
import pro.taskana.mappings.JobMapper; import pro.taskana.mappings.JobMapper;
import pro.taskana.mappings.ObjectReferenceMapper; import pro.taskana.mappings.ObjectReferenceMapper;
import pro.taskana.mappings.QueryMapper; import pro.taskana.mappings.QueryMapper;
import pro.taskana.mappings.TaskMapper; import pro.taskana.mappings.TaskMapper;
import pro.taskana.mappings.TaskMonitorMapper; import pro.taskana.mappings.TaskMonitorMapper;
import pro.taskana.mappings.WorkbasketAccessMapper; import pro.taskana.mappings.WorkbasketAccessMapper;
import pro.taskana.mappings.WorkbasketMapper; import pro.taskana.mappings.WorkbasketMapper;
import pro.taskana.security.CurrentUserContext; import pro.taskana.security.CurrentUserContext;
/** /**
* This is the implementation of TaskanaEngine. * This is the implementation of TaskanaEngine.
*/ */
public class TaskanaEngineImpl implements TaskanaEngine { public class TaskanaEngineImpl implements TaskanaEngine {
private static final String DEFAULT = "default"; private static final String DEFAULT = "default";
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineImpl.class);
protected static ThreadLocal<Deque<SqlSessionManager>> sessionStack = new ThreadLocal<>(); protected static ThreadLocal<Deque<SqlSessionManager>> sessionStack = new ThreadLocal<>();
protected TaskanaEngineConfiguration taskanaEngineConfiguration; protected TaskanaEngineConfiguration taskanaEngineConfiguration;
protected TransactionFactory transactionFactory; protected TransactionFactory transactionFactory;
protected SqlSessionManager sessionManager; protected SqlSessionManager sessionManager;
protected SqlSessionFactory sessionFactory; protected SqlSessionFactory sessionFactory;
protected ConnectionManagementMode mode = ConnectionManagementMode.PARTICIPATE; protected ConnectionManagementMode mode = ConnectionManagementMode.PARTICIPATE;
protected java.sql.Connection connection = null; protected java.sql.Connection connection = null;
protected TaskanaEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration) { protected TaskanaEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration) {
this.taskanaEngineConfiguration = taskanaEngineConfiguration; this.taskanaEngineConfiguration = taskanaEngineConfiguration;
createTransactionFactory(taskanaEngineConfiguration.getUseManagedTransactions()); createTransactionFactory(taskanaEngineConfiguration.getUseManagedTransactions());
this.sessionManager = createSqlSessionManager(); this.sessionManager = createSqlSessionManager();
} }
public static TaskanaEngine createTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration) { public static TaskanaEngine createTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration) {
return new TaskanaEngineImpl(taskanaEngineConfiguration); return new TaskanaEngineImpl(taskanaEngineConfiguration);
} }
/** /**
* With sessionStack, we maintain a Stack of SqlSessionManager objects on a per thread basis. SqlSessionManager is * 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. * 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(); ..... * Each external API call is wrapped into taskanaEngineImpl.openConnection(); .....
* taskanaEngineImpl.returnConnection(); calls. In order to avoid duplicate opening / closing of connections, we use * 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 * 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() * 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 * 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() * stack. When the stack becomes empty, we close the database connection by calling sessionManager.close()
* *
* @return Stack of SqlSessionManager * @return Stack of SqlSessionManager
*/ */
protected static Deque<SqlSessionManager> getSessionStack() { protected static Deque<SqlSessionManager> getSessionStack() {
Deque<SqlSessionManager> stack = sessionStack.get(); Deque<SqlSessionManager> stack = sessionStack.get();
if (stack == null) { if (stack == null) {
stack = new ArrayDeque<>(); stack = new ArrayDeque<>();
sessionStack.set(stack); sessionStack.set(stack);
} }
return stack; return stack;
} }
protected static SqlSessionManager getSessionFromStack() { protected static SqlSessionManager getSessionFromStack() {
Deque<SqlSessionManager> stack = getSessionStack(); Deque<SqlSessionManager> stack = getSessionStack();
if (stack.isEmpty()) { if (stack.isEmpty()) {
return null; return null;
} }
return stack.peek(); return stack.peek();
} }
protected static void pushSessionToStack(SqlSessionManager session) { protected static void pushSessionToStack(SqlSessionManager session) {
getSessionStack().push(session); getSessionStack().push(session);
} }
protected static void popSessionFromStack() { protected static void popSessionFromStack() {
Deque<SqlSessionManager> stack = getSessionStack(); Deque<SqlSessionManager> stack = getSessionStack();
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
stack.pop(); stack.pop();
} }
} }
public static boolean isDb2(String dbProductName) { public static boolean isDb2(String dbProductName) {
return dbProductName.contains("DB2"); return dbProductName.contains("DB2");
} }
public static boolean isH2(String databaseProductName) { public static boolean isH2(String databaseProductName) {
return databaseProductName.contains("H2"); return databaseProductName.contains("H2");
} }
public static boolean isPostgreSQL(String databaseProductName) { public static boolean isPostgreSQL(String databaseProductName) {
return databaseProductName.equals("PostgreSQL"); return databaseProductName.equals("PostgreSQL");
} }
@Override @Override
public TaskService getTaskService() { public TaskService getTaskService() {
SqlSession session = this.sessionManager; SqlSession session = this.sessionManager;
return new TaskServiceImpl(this, session.getMapper(TaskMapper.class), return new TaskServiceImpl(this, session.getMapper(TaskMapper.class),
session.getMapper(AttachmentMapper.class)); session.getMapper(AttachmentMapper.class));
} }
@Override @Override
public TaskMonitorService getTaskMonitorService() { public TaskMonitorService getTaskMonitorService() {
SqlSession session = this.sessionManager; SqlSession session = this.sessionManager;
return new TaskMonitorServiceImpl(this, return new TaskMonitorServiceImpl(this,
session.getMapper(TaskMonitorMapper.class)); session.getMapper(TaskMonitorMapper.class));
} }
@Override @Override
public WorkbasketService getWorkbasketService() { public WorkbasketService getWorkbasketService() {
SqlSession session = this.sessionManager; SqlSession session = this.sessionManager;
return new WorkbasketServiceImpl(this, return new WorkbasketServiceImpl(this,
session.getMapper(WorkbasketMapper.class), session.getMapper(WorkbasketMapper.class),
session.getMapper(DistributionTargetMapper.class), session.getMapper(DistributionTargetMapper.class),
session.getMapper(WorkbasketAccessMapper.class)); session.getMapper(WorkbasketAccessMapper.class));
} }
@Override @Override
public ClassificationService getClassificationService() { public ClassificationService getClassificationService() {
SqlSession session = this.sessionManager; SqlSession session = this.sessionManager;
return new ClassificationServiceImpl(this, session.getMapper(ClassificationMapper.class), return new ClassificationServiceImpl(this, session.getMapper(ClassificationMapper.class),
session.getMapper(TaskMapper.class)); session.getMapper(TaskMapper.class));
} }
@Override @Override
public TaskanaEngineConfiguration getConfiguration() { public TaskanaEngineConfiguration getConfiguration() {
return this.taskanaEngineConfiguration; return this.taskanaEngineConfiguration;
} }
/** /**
* sets the connection management mode. * sets the connection management mode.
* *
* @param mode * @param mode
* - the connection management mode Valid values are: * - the connection management mode Valid values are:
* <ul> * <ul>
* <li>PARTICIPATE - taskana participates in global transaction. This is the default mode.</li> * <li>PARTICIPATE - taskana participates in global transaction. This is the default mode.</li>
* <li>AUTOCOMMIT - taskana commits each API call separately</li> * <li>AUTOCOMMIT - taskana commits each API call separately</li>
* <li>EXPLICIT - commit processing is managed explicitly by the client</li> * <li>EXPLICIT - commit processing is managed explicitly by the client</li>
* </ul> * </ul>
*/ */
@Override @Override
public void setConnectionManagementMode(ConnectionManagementMode mode) { public void setConnectionManagementMode(ConnectionManagementMode mode) {
if (this.mode == ConnectionManagementMode.EXPLICIT && connection != null if (this.mode == ConnectionManagementMode.EXPLICIT && connection != null
&& mode != ConnectionManagementMode.EXPLICIT) { && mode != ConnectionManagementMode.EXPLICIT) {
if (sessionManager.isManagedSessionStarted()) { if (sessionManager.isManagedSessionStarted()) {
sessionManager.close(); sessionManager.close();
} }
connection = null; connection = null;
} }
this.mode = mode; this.mode = mode;
} }
/** /**
* Set the database connection to be used by taskana. If this Api is called, taskana uses the connection passed by * 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 * 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 * 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. * TaskanaEngine.closeConnection() or TaskanaEngine.setConnection(null). Both calls have the same effect.
* *
* @param connection * @param connection
* The connection that passed into TaskanaEngine * The connection that passed into TaskanaEngine
*/ */
@Override @Override
public void setConnection(java.sql.Connection connection) throws SQLException { public void setConnection(java.sql.Connection connection) throws SQLException {
if (connection != null) { if (connection != null) {
this.connection = connection; this.connection = connection;
// disabling auto commit for passed connection in order to gain full control over the connection management // disabling auto commit for passed connection in order to gain full control over the connection management
connection.setAutoCommit(false); connection.setAutoCommit(false);
mode = ConnectionManagementMode.EXPLICIT; mode = ConnectionManagementMode.EXPLICIT;
sessionManager.startManagedSession(connection); sessionManager.startManagedSession(connection);
} else if (this.connection != null) { } else if (this.connection != null) {
closeConnection(); closeConnection();
} }
} }
/** /**
* closes the connection to the database in mode EXPLICIT. In mode EXPLICIT, closes the client's connection, sets it * 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) * to null and switches to mode PARTICIPATE Has the same effect as setConnection(null)
*/ */
@Override @Override
public void closeConnection() { public void closeConnection() {
if (this.mode == ConnectionManagementMode.EXPLICIT) { if (this.mode == ConnectionManagementMode.EXPLICIT) {
this.connection = null; this.connection = null;
if (sessionManager.isManagedSessionStarted()) { if (sessionManager.isManagedSessionStarted()) {
sessionManager.close(); sessionManager.close();
} }
mode = ConnectionManagementMode.PARTICIPATE; mode = ConnectionManagementMode.PARTICIPATE;
} }
} }
/** /**
* Open the connection to the database. to be called at the begin of each Api call that accesses the database * Open the connection to the database. to be called at the begin of each Api call that accesses the database
*/ */
void openConnection() { void openConnection() {
initSqlSession(); initSqlSession();
if (mode != ConnectionManagementMode.EXPLICIT) { if (mode != ConnectionManagementMode.EXPLICIT) {
pushSessionToStack(this.sessionManager); pushSessionToStack(this.sessionManager);
} }
} }
/** /**
* Initializes the SqlSessionManager. * Initializes the SqlSessionManager.
*/ */
void initSqlSession() { void initSqlSession() {
if (mode == ConnectionManagementMode.EXPLICIT && this.connection == null) { if (mode == ConnectionManagementMode.EXPLICIT && this.connection == null) {
throw new ConnectionNotSetException(); throw new ConnectionNotSetException();
} else if (mode != ConnectionManagementMode.EXPLICIT && !this.sessionManager.isManagedSessionStarted()) { } else if (mode != ConnectionManagementMode.EXPLICIT && !this.sessionManager.isManagedSessionStarted()) {
this.sessionManager.startManagedSession(); this.sessionManager.startManagedSession();
} }
} }
/** /**
* Returns the database connection into the pool. In the case of nested calls, simply pops the latest session from * 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 * 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 * connection is closed. To be called at the end of each Api call that accesses the database
*/ */
void returnConnection() { void returnConnection() {
if (this.mode != ConnectionManagementMode.EXPLICIT) { if (this.mode != ConnectionManagementMode.EXPLICIT) {
popSessionFromStack(); popSessionFromStack();
if (getSessionStack().isEmpty() if (getSessionStack().isEmpty()
&& this.sessionManager != null && this.sessionManager.isManagedSessionStarted()) { && this.sessionManager != null && this.sessionManager.isManagedSessionStarted()) {
if (this.mode == ConnectionManagementMode.AUTOCOMMIT) { if (this.mode == ConnectionManagementMode.AUTOCOMMIT) {
try { try {
this.sessionManager.commit(); this.sessionManager.commit();
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("closeSession(): Tried to Autocommit and caught exception" + e); throw new AutocommitFailedException(e.getCause());
throw new AutocommitFailedException(e); }
} }
} this.sessionManager.close();
this.sessionManager.close(); }
} }
} }
}
/**
/** * retrieve the SqlSession used by taskana.
* retrieve the SqlSession used by taskana. *
* * @return the myBatis SqlSession object used by taskana
* @return the myBatis SqlSession object used by taskana */
*/ SqlSession getSqlSession() {
SqlSession getSqlSession() { return this.sessionManager;
return this.sessionManager; }
}
/**
/** * Checks whether current user is member of any of the specified roles.
* Checks whether current user is member of any of the specified roles. *
* * @param roles
* @param roles * The roles that are checked for membership of the current user
* The roles that are checked for membership of the current user * @throws NotAuthorizedException
* @throws NotAuthorizedException * If the current user is not member of any specified role
* If the current user is not member of any specified role */
*/ @Override
@Override public void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException {
public void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException { if (isUserInRole(roles)) {
if (isUserInRole(roles)) { return;
return; } else {
} else { if (LOGGER.isErrorEnabled()) {
if (LOGGER.isErrorEnabled()) { String accessIds = LoggerUtils.listToString(CurrentUserContext.getAccessIds());
String accessIds = LoggerUtils.listToString(CurrentUserContext.getAccessIds()); String rolesAsString = Arrays.toString(roles);
String rolesAsString = Arrays.toString(roles); LOGGER.error("Throwing NotAuthorizedException because accessIds {} are not member of roles {}",
LOGGER.error("Throwing NotAuthorizedException because accessIds {} are not member of roles {}", accessIds,
accessIds, rolesAsString);
rolesAsString); }
} throw new NotAuthorizedException("current user is not member of role(s) " + Arrays.toString(roles));
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.
* check whether the current user is member of one of the roles specified. *
* * @param roles
* @param roles * The roles that are checked for membership of the current user
* 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
* @return true if the current user is a member of at least one of the specified groups */
*/ @Override
@Override public boolean isUserInRole(TaskanaRole... roles) {
public boolean isUserInRole(TaskanaRole... roles) { if (!getConfiguration().isSecurityEnabled()) {
if (!getConfiguration().isSecurityEnabled()) { return true;
return true; } else {
} else { List<String> accessIds = CurrentUserContext.getAccessIds();
List<String> accessIds = CurrentUserContext.getAccessIds(); Set<String> rolesMembers = new HashSet<>();
Set<String> rolesMembers = new HashSet<>(); for (TaskanaRole role : roles) {
for (TaskanaRole role : roles) { rolesMembers.addAll(getConfiguration().getRoleMap().get(role));
rolesMembers.addAll(getConfiguration().getRoleMap().get(role)); }
} for (String accessId : accessIds) {
for (String accessId : accessIds) { if (rolesMembers.contains(accessId)) {
if (rolesMembers.contains(accessId)) { return true;
return true; }
} }
} return false;
return false; }
} }
}
/**
/** * This method creates the sqlSessionManager of myBatis. It integrates all the SQL mappers and sets the databaseId
* This method creates the sqlSessionManager of myBatis. It integrates all the SQL mappers and sets the databaseId * attribute.
* attribute. *
* * @return a {@link SqlSessionFactory}
* @return a {@link SqlSessionFactory} */
*/ protected SqlSessionManager createSqlSessionManager() {
protected SqlSessionManager createSqlSessionManager() { Environment environment = new Environment(DEFAULT, this.transactionFactory,
Environment environment = new Environment(DEFAULT, this.transactionFactory, taskanaEngineConfiguration.getDatasource());
taskanaEngineConfiguration.getDatasource()); Configuration configuration = new Configuration(environment);
Configuration configuration = new Configuration(environment);
// set databaseId
// set databaseId String databaseProductName;
String databaseProductName; try (Connection con = taskanaEngineConfiguration.getDatasource().getConnection()) {
try (Connection con = taskanaEngineConfiguration.getDatasource().getConnection()) { databaseProductName = con.getMetaData().getDatabaseProductName();
databaseProductName = con.getMetaData().getDatabaseProductName(); if (isDb2(databaseProductName)) {
if (isDb2(databaseProductName)) { configuration.setDatabaseId("db2");
configuration.setDatabaseId("db2"); } else if (isH2(databaseProductName)) {
} else if (isH2(databaseProductName)) { configuration.setDatabaseId("h2");
configuration.setDatabaseId("h2"); } else if (isPostgreSQL(databaseProductName)) {
} else if (isPostgreSQL(databaseProductName)) { configuration.setDatabaseId("postgres");
configuration.setDatabaseId("postgres"); } else {
} else { throw new UnsupportedDatabaseException(databaseProductName);
LOGGER.error( }
"Method createSqlSessionManager() didn't find database with name {}. Throwing UnsupportedDatabaseException",
databaseProductName); } catch (SQLException e) {
throw new UnsupportedDatabaseException(databaseProductName); throw new SystemException(
} "Method createSqlSessionManager() could not open a connection to the database. No databaseId has been set.",
e.getCause());
} catch (SQLException e) { }
LOGGER.error(
"Method createSqlSessionManager() could not open a connection to the database. No databaseId has been set.", // add mappers
e); configuration.addMapper(TaskMapper.class);
throw new SystemException( configuration.addMapper(TaskMonitorMapper.class);
"Method createSqlSessionManager() could not open a connection to the database. No databaseId has been set."); configuration.addMapper(WorkbasketMapper.class);
} configuration.addMapper(DistributionTargetMapper.class);
configuration.addMapper(ClassificationMapper.class);
// add mappers configuration.addMapper(WorkbasketAccessMapper.class);
configuration.addMapper(TaskMapper.class); configuration.addMapper(ObjectReferenceMapper.class);
configuration.addMapper(TaskMonitorMapper.class); configuration.addMapper(QueryMapper.class);
configuration.addMapper(WorkbasketMapper.class); configuration.addMapper(AttachmentMapper.class);
configuration.addMapper(DistributionTargetMapper.class); configuration.addMapper(JobMapper.class);
configuration.addMapper(ClassificationMapper.class); configuration.getTypeHandlerRegistry().register(MapTypeHandler.class);
configuration.addMapper(WorkbasketAccessMapper.class); SqlSessionFactory localSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
configuration.addMapper(ObjectReferenceMapper.class); return SqlSessionManager.newInstance(localSessionFactory);
configuration.addMapper(QueryMapper.class); }
configuration.addMapper(AttachmentMapper.class);
configuration.addMapper(JobMapper.class); /**
configuration.getTypeHandlerRegistry().register(MapTypeHandler.class); * creates the MyBatis transaction factory.
SqlSessionFactory localSessionFactory = new SqlSessionFactoryBuilder().build(configuration); *
return SqlSessionManager.newInstance(localSessionFactory); * @param useManagedTransactions
} */
private void createTransactionFactory(boolean useManagedTransactions) {
/** if (useManagedTransactions) {
* creates the MyBatis transaction factory. this.transactionFactory = new ManagedTransactionFactory();
* } else {
* @param useManagedTransactions this.transactionFactory = new JdbcTransactionFactory();
*/ }
private void createTransactionFactory(boolean useManagedTransactions) { }
if (useManagedTransactions) {
this.transactionFactory = new ManagedTransactionFactory(); /**
} else { * Returns true if the given domain does exist in the configuration.
this.transactionFactory = new JdbcTransactionFactory(); *
} * @param domain
} * the domain specified in the configuration
* @return <code>true</code> if the domain exists
/** */
* Returns true if the given domain does exist in the configuration. public boolean domainExists(String domain) {
* return getConfiguration().getDomains().contains(domain);
* @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(); taskanaEngine.openConnection();
result = workbasketMapper.findById(workbasketId); result = workbasketMapper.findById(workbasketId);
if (result == null) { if (result == null) {
LOGGER.error(
"Method getWorkbasket() didn't find workbasket with ID {}. Throwing WorkbasketNotFoundException",
workbasketId);
throw new WorkbasketNotFoundException(workbasketId, throw new WorkbasketNotFoundException(workbasketId,
"Workbasket with id " + workbasketId + " was not found."); "Workbasket with id " + workbasketId + " was not found.");
} }
@ -92,9 +89,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
result = workbasketMapper.findByKeyAndDomain(workbasketKey, domain); result = workbasketMapper.findByKeyAndDomain(workbasketKey, domain);
if (result == null) { if (result == null) {
LOGGER.error(
"Method getWorkbasketByKey() didn't find workbasket with key {}. Throwing WorkbasketNotFoundException",
workbasketKey);
throw new WorkbasketNotFoundException(workbasketKey, domain, throw new WorkbasketNotFoundException(workbasketKey, domain,
"Workbasket with key " + workbasketKey + " and domain " + domain + " was not found."); "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(), Workbasket existingWorkbasket = workbasketMapper.findByKeyAndDomain(newWorkbasket.getKey(),
newWorkbasket.getDomain()); newWorkbasket.getDomain());
if (existingWorkbasket != null) { 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); throw new WorkbasketAlreadyExistException(existingWorkbasket);
} }
@ -172,7 +163,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public Workbasket updateWorkbasket(Workbasket workbasketToUpdate) public Workbasket updateWorkbasket(Workbasket workbasketToUpdate)
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException { throws NotAuthorizedException {
LOGGER.debug("entry to updateWorkbasket(workbasket)", workbasketToUpdate); LOGGER.debug("entry to updateWorkbasket(workbasket)", workbasketToUpdate);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
@ -208,8 +199,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
accessItem.setId(IdGenerator.generateWithPrefix(ID_PREFIX_WORKBASKET_AUTHORIZATION)); accessItem.setId(IdGenerator.generateWithPrefix(ID_PREFIX_WORKBASKET_AUTHORIZATION));
if (workbasketAccessItem.getId() == null || workbasketAccessItem.getAccessId() == null if (workbasketAccessItem.getId() == null || workbasketAccessItem.getAccessId() == null
|| workbasketAccessItem.getWorkbasketId() == null) { || workbasketAccessItem.getWorkbasketId() == null) {
LOGGER.error(
"createWorkbasketAccessItem failed because id, accessId or workbasketId is null. Throwing InvalidArgumentException.");
throw new InvalidArgumentException( throw new InvalidArgumentException(
"Checking the preconditions of the current WorkbasketAccessItem failed. WorkbasketAccessItem=" "Checking the preconditions of the current WorkbasketAccessItem failed. WorkbasketAccessItem="
+ workbasketAccessItem.toString()); + workbasketAccessItem.toString());
@ -243,16 +232,10 @@ public class WorkbasketServiceImpl implements WorkbasketService {
for (WorkbasketAccessItem workbasketAccessItem : wbAccessItems) { for (WorkbasketAccessItem workbasketAccessItem : wbAccessItems) {
WorkbasketAccessItemImpl wbAccessItemImpl = (WorkbasketAccessItemImpl) workbasketAccessItem; WorkbasketAccessItemImpl wbAccessItemImpl = (WorkbasketAccessItemImpl) workbasketAccessItem;
if (wbAccessItemImpl.getWorkbasketId() == null) { if (wbAccessItemImpl.getWorkbasketId() == null) {
LOGGER.error(
"setWorkbasketAccessItem failed because WorkbasketAccessItem {} has a null workbasketId. Throwing InvalidArgumentException.",
workbasketAccessItem);
throw new InvalidArgumentException( throw new InvalidArgumentException(
"Checking the preconditions of the current WorkbasketAccessItem failed - WBID is NULL. WorkbasketAccessItem=" "Checking the preconditions of the current WorkbasketAccessItem failed - WBID is NULL. WorkbasketAccessItem="
+ workbasketAccessItem.toString()); + workbasketAccessItem.toString());
} else if (!wbAccessItemImpl.getWorkbasketId().equals(workbasketId)) { } else if (!wbAccessItemImpl.getWorkbasketId().equals(workbasketId)) {
LOGGER.error(
"setWorkbasketAccessItem failed because WorkbasketAccessItem {} does not refer to workbasket {}. Throwing InvalidArgumentException.",
workbasketAccessItem, workbasketId);
throw new InvalidArgumentException( throw new InvalidArgumentException(
"Checking the preconditions of the current WorkbasketAccessItem failed - the WBID does not match. Target-WBID='" "Checking the preconditions of the current WorkbasketAccessItem failed - the WBID does not match. Target-WBID='"
+ workbasketId + "' WorkbasketAccessItem=" + workbasketId + "' WorkbasketAccessItem="
@ -311,8 +294,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
if (workbasketMapper.findById(workbasketId) == null) { if (workbasketMapper.findById(workbasketId) == null) {
LOGGER.error("Throwing WorkbasketNotFoundException because workbasket with id {} does not exist",
workbasketId);
throw new WorkbasketNotFoundException(workbasketId, throw new WorkbasketNotFoundException(workbasketId,
"Workbasket with id " + workbasketId + " was not found."); "Workbasket with id " + workbasketId + " was not found.");
} }
@ -326,9 +307,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
WorkbasketAccessItem wbAcc = workbasketAccessMapper.findByWorkbasketAndAccessId(workbasketId, WorkbasketAccessItem wbAcc = workbasketAccessMapper.findByWorkbasketAndAccessId(workbasketId,
accessIds); accessIds);
if (wbAcc == null) { 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( throw new NotAuthorizedException(
"Not authorized. Permission '" + Arrays.toString(requestedPermissions) + "' on workbasket '" "Not authorized. Permission '" + Arrays.toString(requestedPermissions) + "' on workbasket '"
+ workbasketId + workbasketId
@ -340,9 +318,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
for (WorkbasketPermission perm : requestedPermissions) { for (WorkbasketPermission perm : requestedPermissions) {
if (!grantedPermissions.contains(perm)) { if (!grantedPermissions.contains(perm)) {
isAuthorized = false; isAuthorized = false;
LOGGER.error(
"AccessIds {} do not have permission {} on workbasket with id {}. Throwing NotAuthorizedException.",
LoggerUtils.listToString(accessIds), perm.name(), workbasketId);
throw new NotAuthorizedException( throw new NotAuthorizedException(
"Not authorized. Permission '" + perm.name() + "' on workbasket '" + workbasketId "Not authorized. Permission '" + perm.name() + "' on workbasket '" + workbasketId
+ "' is needed."); + "' is needed.");
@ -363,9 +338,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
taskanaEngine.openConnection(); taskanaEngine.openConnection();
if (workbasketMapper.findByKeyAndDomain(workbasketKey, domain) == null) { 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, throw new WorkbasketNotFoundException(workbasketKey, domain,
"Workbasket with key " + workbasketKey + " and domain " + domain + " was not found"); "Workbasket with key " + workbasketKey + " and domain " + domain + " was not found");
} }
@ -377,9 +349,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
WorkbasketAccessItem wbAcc = workbasketAccessMapper.findByWorkbasketKeyDomainAndAccessId( WorkbasketAccessItem wbAcc = workbasketAccessMapper.findByWorkbasketKeyDomainAndAccessId(
workbasketKey, domain, accessIds); workbasketKey, domain, accessIds);
if (wbAcc == null) { 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( throw new NotAuthorizedException(
"Not authorized. Permission '" + Arrays.toString(requestedPermissions) "Not authorized. Permission '" + Arrays.toString(requestedPermissions)
+ "' on workbasket with key '" + "' on workbasket with key '"
@ -391,9 +360,6 @@ public class WorkbasketServiceImpl implements WorkbasketService {
for (WorkbasketPermission perm : requestedPermissions) { for (WorkbasketPermission perm : requestedPermissions) {
if (!grantedPermissions.contains(perm)) { if (!grantedPermissions.contains(perm)) {
isAuthorized = false; 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( throw new NotAuthorizedException(
"Not authorized. Permission '" + perm.name() + "' on workbasket with key '" + workbasketKey "Not authorized. Permission '" + perm.name() + "' on workbasket with key '" + workbasketKey
+ "' and domain '" + domain + "' is needed."); + "' and domain '" + domain + "' is needed.");
@ -746,7 +712,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
@Override @Override
public void removeDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId) public void removeDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException { throws NotAuthorizedException {
LOGGER.debug("entry to removeDistributionTarget(sourceWorkbasketId = {}, targetWorkbasketId = {})", LOGGER.debug("entry to removeDistributionTarget(sourceWorkbasketId = {}, targetWorkbasketId = {})",
sourceWorkbasketId, targetWorkbasketId); sourceWorkbasketId, targetWorkbasketId);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN); taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);

View File

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

View File

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

View File

@ -102,7 +102,7 @@ public class CreateClassificationAccTest extends AbstractAccTest {
@Test @Test
public void testCreateClassificationWithInvalidValues() public void testCreateClassificationWithInvalidValues()
throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException, throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException,
DomainNotFoundException, InvalidArgumentException { DomainNotFoundException {
long amountOfClassificationsBefore = classificationService.createClassificationQuery().count(); long amountOfClassificationsBefore = classificationService.createClassificationQuery().count();
// Check key NULL // 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.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.sql.SQLException;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -38,7 +36,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"businessadmin"}) groupNames = {"businessadmin"})
@Test @Test
public void testDeleteClassificationInDomain() public void testDeleteClassificationInDomain()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException { throws ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L140101", "DOMAIN_A"); classificationService.deleteClassification("L140101", "DOMAIN_A");
Classification classification = classificationService.getClassification("L140101", "DOMAIN_A"); Classification classification = classificationService.getClassification("L140101", "DOMAIN_A");
@ -51,7 +49,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test(expected = NotAuthorizedException.class) @Test(expected = NotAuthorizedException.class)
public void testDeleteClassificationInDomainUserIsNotAuthorized() public void testDeleteClassificationInDomainUserIsNotAuthorized()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException { throws ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L140101", "DOMAIN_A"); classificationService.deleteClassification("L140101", "DOMAIN_A");
fail("NotAuthorizedException should have been thrown"); fail("NotAuthorizedException should have been thrown");
} }
@ -61,7 +59,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"group_1", "businessadmin"}) groupNames = {"group_1", "businessadmin"})
@Test(expected = ClassificationInUseException.class) @Test(expected = ClassificationInUseException.class)
public void testThrowExeptionIfDeleteClassificationWithExistingTasks() public void testThrowExeptionIfDeleteClassificationWithExistingTasks()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException { throws ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L1050", "DOMAIN_A"); classificationService.deleteClassification("L1050", "DOMAIN_A");
} }
@ -70,7 +68,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"group_1", "businessadmin"}) groupNames = {"group_1", "businessadmin"})
@Test(expected = ClassificationInUseException.class) @Test(expected = ClassificationInUseException.class)
public void testThrowExeptionIfDeleteMasterClassificationWithExistingTasks() public void testThrowExeptionIfDeleteMasterClassificationWithExistingTasks()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException { throws ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L1050", ""); classificationService.deleteClassification("L1050", "");
} }
@ -79,7 +77,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"businessadmin"}) groupNames = {"businessadmin"})
@Test @Test
public void testDeleteMasterClassification() public void testDeleteMasterClassification()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException { throws ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L3060", ""); classificationService.deleteClassification("L3060", "");
@ -97,7 +95,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"businessadmin"}) groupNames = {"businessadmin"})
@Test(expected = ClassificationInUseException.class) @Test(expected = ClassificationInUseException.class)
public void testDeleteMasterClassificationWithExistingAttachment() public void testDeleteMasterClassificationWithExistingAttachment()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException { throws ClassificationNotFoundException, NotAuthorizedException, ClassificationInUseException {
classificationService.deleteClassification("L12010", ""); classificationService.deleteClassification("L12010", "");
@ -115,7 +113,7 @@ public class DeleteClassificationAccTest extends AbstractAccTest {
groupNames = {"group_1", "businessadmin"}) groupNames = {"group_1", "businessadmin"})
@Test @Test
public void testThrowExceptionWhenChildClassificationIsInUseAndRollback() public void testThrowExceptionWhenChildClassificationIsInUseAndRollback()
throws ClassificationInUseException, NotAuthorizedException, ClassificationNotFoundException { throws NotAuthorizedException, ClassificationNotFoundException {
boolean classificationInUse = false; boolean classificationInUse = false;
try { try {
classificationService.deleteClassification("L11010", "DOMAIN_A"); 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.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import java.sql.SQLException;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -12,9 +11,6 @@ import org.junit.Test;
import acceptance.AbstractAccTest; import acceptance.AbstractAccTest;
import pro.taskana.ClassificationService; import pro.taskana.ClassificationService;
import pro.taskana.ClassificationSummary; 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. * Acceptance test for all "get classification" scenarios.
@ -26,8 +22,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testQueryClassificationValuesForColumnName() public void testQueryClassificationValuesForColumnName() {
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<String> columnValueList = classificationService.createClassificationQuery() List<String> columnValueList = classificationService.createClassificationQuery()
.listValues("NAME", null); .listValues("NAME", null);
@ -59,8 +54,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testFindClassificationsByCategoryAndDomain() public void testFindClassificationsByCategoryAndDomain() {
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery() List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery()
.categoryIn("MANUAL") .categoryIn("MANUAL")
@ -72,8 +66,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testGetOneClassificationForMultipleDomains() public void testGetOneClassificationForMultipleDomains() {
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery() List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.keyIn("L10000") .keyIn("L10000")
@ -85,8 +78,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testGetClassificationsForTypeAndParent() public void testGetClassificationsForTypeAndParent() {
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery() List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.typeIn("TASK", "DOCUMENT") .typeIn("TASK", "DOCUMENT")
@ -110,8 +102,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testGetClassificationsForKeyAndCategories() public void testGetClassificationsForKeyAndCategories() {
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery() List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.keyIn("T2100", "L10000") .keyIn("T2100", "L10000")
@ -135,8 +126,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testGetClassificationsWithParentKey() public void testGetClassificationsWithParentKey() {
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery() List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.keyIn("A12", "A13") .keyIn("A12", "A13")
@ -159,8 +149,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testGetClassificationsWithCustom1() public void testGetClassificationsWithCustom1() {
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery() List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.custom1Like("VNR,RVNR,KOLVNR", "VNR") .custom1Like("VNR,RVNR,KOLVNR", "VNR")
@ -171,8 +160,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testGetClassificationsWithCustom1Like() public void testGetClassificationsWithCustom1Like() {
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery() List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.custom1Like("%RVNR%") .custom1Like("%RVNR%")
@ -184,8 +172,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testGetClassificationsWithParentAndCustom2() public void testGetClassificationsWithParentAndCustom2() {
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery() List<ClassificationSummary> classifications = classificationService.createClassificationQuery()
.parentIdIn("CLI:100000000000000000000000000000000004") .parentIdIn("CLI:100000000000000000000000000000000004")
@ -197,8 +184,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testFindClassificationsByCreatedTimestamp() public void testFindClassificationsByCreatedTimestamp() {
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery() List<ClassificationSummary> classificationSummaryList = classificationService.createClassificationQuery()
.domainIn("DOMAIN_A") .domainIn("DOMAIN_A")
@ -210,8 +196,7 @@ public class QueryClassificationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testFindClassificationsByPriorityAndValidInDomain() public void testFindClassificationsByPriorityAndValidInDomain() {
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> list = classificationService.createClassificationQuery() List<ClassificationSummary> list = classificationService.createClassificationQuery()
.validInDomainEquals(Boolean.TRUE) .validInDomainEquals(Boolean.TRUE)

View File

@ -27,7 +27,7 @@ public class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testGetFirstPageOfClassificationQueryWithOffset() throws NotAuthorizedException { public void testGetFirstPageOfClassificationQueryWithOffset() {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> results = classificationService.createClassificationQuery() List<ClassificationSummary> results = classificationService.createClassificationQuery()
.domainIn("DOMAIN_A") .domainIn("DOMAIN_A")
@ -36,7 +36,7 @@ public class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testGetSecondPageOfClassificationQueryWithOffset() throws NotAuthorizedException { public void testGetSecondPageOfClassificationQueryWithOffset() {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> results = classificationService.createClassificationQuery() List<ClassificationSummary> results = classificationService.createClassificationQuery()
.domainIn("DOMAIN_A") .domainIn("DOMAIN_A")
@ -45,7 +45,7 @@ public class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testListOffsetAndLimitOutOfBounds() throws NotAuthorizedException { public void testListOffsetAndLimitOutOfBounds() {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
// both will be 0, working // both will be 0, working
@ -68,7 +68,7 @@ public class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testPaginationWithPages() throws NotAuthorizedException { public void testPaginationWithPages() {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
// Getting full page // Getting full page
@ -105,7 +105,7 @@ public class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testPaginationNullAndNegativeLimitsIgnoring() throws NotAuthorizedException { public void testPaginationNullAndNegativeLimitsIgnoring() {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
// 0 limit/size = 0 results // 0 limit/size = 0 results
@ -153,8 +153,7 @@ public class QueryClassificationWithPaginationAccTest extends AbstractAccTest {
} }
@Test @Test
public void testCountOfClassificationsQuery() public void testCountOfClassificationsQuery() {
throws NotAuthorizedException {
ClassificationService classificationService = taskanaEngine.getClassificationService(); ClassificationService classificationService = taskanaEngine.getClassificationService();
long count = classificationService.createClassificationQuery() long count = classificationService.createClassificationQuery()
.domainIn("DOMAIN_A") .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.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
@ -50,7 +49,7 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
groupNames = {"businessadmin"}) groupNames = {"businessadmin"})
@Test @Test
public void testUpdateClassification() public void testUpdateClassification()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
InvalidArgumentException { InvalidArgumentException {
String newName = "updated Name"; String newName = "updated Name";
String newEntryPoint = "updated EntryPoint"; String newEntryPoint = "updated EntryPoint";
@ -89,7 +88,7 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
@Test(expected = NotAuthorizedException.class) @Test(expected = NotAuthorizedException.class)
public void testUpdateClassificationFails() public void testUpdateClassificationFails()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
InvalidArgumentException { InvalidArgumentException {
String newName = "updated Name"; String newName = "updated Name";
String newEntryPoint = "updated EntryPoint"; String newEntryPoint = "updated EntryPoint";
@ -188,7 +187,7 @@ public class UpdateClassificationAccTest extends AbstractAccTest {
groupNames = {"admin"}) groupNames = {"admin"})
@Test @Test
public void testUpdateClassificationPrioServiceLevel() public void testUpdateClassificationPrioServiceLevel()
throws SQLException, ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
InterruptedException, TaskNotFoundException, InvalidArgumentException { InterruptedException, TaskNotFoundException, InvalidArgumentException {
String newEntryPoint = "updated EntryPoint"; String newEntryPoint = "updated EntryPoint";
Instant before = Instant.now(); Instant before = Instant.now();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,5 @@
package acceptance.task; package acceptance.task;
import java.sql.SQLException;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -9,8 +7,6 @@ import org.junit.runner.RunWith;
import acceptance.AbstractAccTest; import acceptance.AbstractAccTest;
import pro.taskana.KeyDomain; import pro.taskana.KeyDomain;
import pro.taskana.TaskService; import pro.taskana.TaskService;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException; import pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException;
import pro.taskana.security.JAASRunner; import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId; import pro.taskana.security.WithAccessId;
@ -30,8 +26,7 @@ public class QueryTasksByWorkbasketAccTest extends AbstractAccTest {
userName = "user_1_1", userName = "user_1_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test(expected = NotAuthorizedToQueryWorkbasketException.class) @Test(expected = NotAuthorizedToQueryWorkbasketException.class)
public void testThrowsExceptionIfNoOpenerPermissionOnQueriedWorkbasket() public void testThrowsExceptionIfNoOpenerPermissionOnQueriedWorkbasket() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
taskService.createTaskQuery() taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_2_1", "DOMAIN_A")) .workbasketKeyDomainIn(new KeyDomain("USER_2_1", "DOMAIN_A"))
@ -43,8 +38,7 @@ public class QueryTasksByWorkbasketAccTest extends AbstractAccTest {
userName = "user_1_1", userName = "user_1_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test(expected = NotAuthorizedToQueryWorkbasketException.class) @Test(expected = NotAuthorizedToQueryWorkbasketException.class)
public void testThrowsExceptionIfNoOpenerPermissionOnAtLeastOneQueriedWorkbasket() public void testThrowsExceptionIfNoOpenerPermissionOnAtLeastOneQueriedWorkbasket() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
taskService.createTaskQuery() taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_1_1", "DOMAIN_A"), new KeyDomain("USER_2_1", "DOMAIN_A")) .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", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testGetFirstPageOfTaskQueryWithOffset() public void testGetFirstPageOfTaskQueryWithOffset() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery() List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")) .workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A"))
@ -47,8 +46,7 @@ public class QueryTasksWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testSecondPageOfTaskQueryWithOffset() public void testSecondPageOfTaskQueryWithOffset() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery() List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")) .workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A"))
@ -60,8 +58,7 @@ public class QueryTasksWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testListOffsetAndLimitOutOfBounds() public void testListOffsetAndLimitOutOfBounds() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
// both will be 0, working // both will be 0, working
@ -87,8 +84,7 @@ public class QueryTasksWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testPaginationWithPages() public void testPaginationWithPages() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
// Getting full page // Getting full page
@ -128,8 +124,7 @@ public class QueryTasksWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testPaginationNullAndNegativeLimitsIgnoring() public void testPaginationNullAndNegativeLimitsIgnoring() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
// 0 limit/size = 0 results // 0 limit/size = 0 results
@ -186,8 +181,7 @@ public class QueryTasksWithPaginationAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testCountOfTaskQuery() public void testCountOfTaskQuery() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
long count = taskService.createTaskQuery() long count = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("GPK_KSC", "DOMAIN_A")) .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.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import java.sql.SQLException;
import java.util.List; import java.util.List;
import org.junit.Assert; import org.junit.Assert;
@ -16,8 +15,6 @@ import pro.taskana.KeyDomain;
import pro.taskana.TaskService; import pro.taskana.TaskService;
import pro.taskana.TaskState; import pro.taskana.TaskState;
import pro.taskana.TaskSummary; import pro.taskana.TaskSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.security.JAASRunner; import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId; import pro.taskana.security.WithAccessId;
@ -38,8 +35,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test @Test
public void testSortByModifiedAndDomain() public void testSortByModifiedAndDomain() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery() List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B")) .workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B"))
@ -61,8 +57,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test @Test
public void testSortByDomainNameAndCreated() public void testSortByDomainNameAndCreated() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery() List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B")) .workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B"))
@ -93,8 +88,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test @Test
public void testSortByPorSystemNoteDueAndOwner() public void testSortByPorSystemNoteDueAndOwner() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery() List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B")) .workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B"))
@ -119,8 +113,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test @Test
public void testSortByPorSystemInstanceParentProcPlannedAndState() public void testSortByPorSystemInstanceParentProcPlannedAndState() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery() List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B")) .workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B"))
@ -145,8 +138,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test @Test
public void testSortByPorCompanyAndClaimed() public void testSortByPorCompanyAndClaimed() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery() List<TaskSummary> results = taskService.createTaskQuery()
.workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B")) .workbasketKeyDomainIn(new KeyDomain("USER_3_2", "DOMAIN_B"))
@ -171,8 +163,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test @Test
public void testSortByWbKeyPrioPorValueAndCompleted() public void testSortByWbKeyPrioPorValueAndCompleted() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery() List<TaskSummary> results = taskService.createTaskQuery()
.stateIn(TaskState.READY) .stateIn(TaskState.READY)
@ -198,8 +189,7 @@ public class QueryTasksWithSortingAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test @Test
public void testSortBpIdClassificationIdDescriptionAndPorType() public void testSortBpIdClassificationIdDescriptionAndPorType() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery() List<TaskSummary> results = taskService.createTaskQuery()
.stateIn(TaskState.READY) .stateIn(TaskState.READY)

View File

@ -241,7 +241,7 @@ public class TransferTaskAccTest extends AbstractAccTest {
@WithAccessId(userName = "teamlead_1") @WithAccessId(userName = "teamlead_1")
@Test(expected = NotAuthorizedException.class) @Test(expected = NotAuthorizedException.class)
public void testBulkTransferTaskWithoutAppendPermissionOnTarget() public void testBulkTransferTaskWithoutAppendPermissionOnTarget()
throws InvalidArgumentException, WorkbasketNotFoundException, TaskNotFoundException, NotAuthorizedException { throws InvalidArgumentException, WorkbasketNotFoundException, NotAuthorizedException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
ArrayList<String> taskIdList = new ArrayList<>(); ArrayList<String> taskIdList = new ArrayList<>();
taskIdList.add("TKI:000000000000000000000000000000000006"); // working 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.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.time.Instant; import java.time.Instant;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -54,8 +53,8 @@ public class UpdateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testUpdatePrimaryObjectReferenceOfTask() public void testUpdatePrimaryObjectReferenceOfTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, WorkbasketNotFoundException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException { ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
@ -84,8 +83,8 @@ public class UpdateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete() public void testThrowsExceptionIfMandatoryPrimaryObjectReferenceIsNotSetOrIncomplete()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, WorkbasketNotFoundException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException { ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
@ -141,8 +140,8 @@ public class UpdateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testThrowsExceptionIfTaskHasAlreadyBeenUpdated() public void testThrowsExceptionIfTaskHasAlreadyBeenUpdated()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, WorkbasketNotFoundException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException { ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
@ -193,9 +192,7 @@ public class UpdateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testUpdateReadFlagOfTask() public void testUpdateReadFlagOfTask()
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, throws TaskNotFoundException, NotAuthorizedException {
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
@ -235,8 +232,8 @@ public class UpdateTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test(expected = InvalidArgumentException.class) @Test(expected = InvalidArgumentException.class)
public void testUpdateOfWorkbasketKeyWhatIsNotAllowed() public void testUpdateOfWorkbasketKeyWhatIsNotAllowed()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, WorkbasketNotFoundException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException { ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService(); 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.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; 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 // since only @Test and not @Before methods are run by JAASRunner, we call this method explicitely at
// the begin of each testcase.... // the begin of each testcase....
private void setUpMethod() private void setUpMethod()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException, SQLException, throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException { AttachmentPersistenceException {
taskService = taskanaEngine.getTaskService(); taskService = taskanaEngine.getTaskService();
@ -81,7 +80,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testAddNewAttachment() public void testAddNewAttachment()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException, throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException { AttachmentPersistenceException {
setUpMethod(); setUpMethod();
int attachmentCount = task.getAttachments().size(); int attachmentCount = task.getAttachments().size();
assertTrue(task.getPriority() == 1); assertTrue(task.getPriority() == 1);
@ -104,7 +103,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testAddNewAttachmentTwiceWithoutTaskanaMethodWillThrowAttachmentPersistenceException() public void testAddNewAttachmentTwiceWithoutTaskanaMethodWillThrowAttachmentPersistenceException()
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException, SQLException { AttachmentPersistenceException {
setUpMethod(); setUpMethod();
int attachmentCount = 0; int attachmentCount = 0;
task.getAttachments().clear(); task.getAttachments().clear();
@ -127,7 +126,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testAddExistingAttachmentAgainWillUpdateWhenNotEqual() public void testAddExistingAttachmentAgainWillUpdateWhenNotEqual()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException, throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException { AttachmentPersistenceException {
setUpMethod(); setUpMethod();
// Add attachment before // Add attachment before
task = taskService.getTask(task.getId()); task = taskService.getTask(task.getId());
@ -162,7 +161,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testAddExistingAttachmentAgainWillDoNothingWhenEqual() public void testAddExistingAttachmentAgainWillDoNothingWhenEqual()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException, throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException { AttachmentPersistenceException {
setUpMethod(); setUpMethod();
// Add Attachment before // Add Attachment before
int attachmentCount = task.getAttachments().size(); int attachmentCount = task.getAttachments().size();
@ -189,7 +188,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testAddAttachmentAsNullValueWillBeIgnored() public void testAddAttachmentAsNullValueWillBeIgnored()
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException, SQLException { AttachmentPersistenceException {
setUpMethod(); setUpMethod();
// Try to add a single NULL-Element // Try to add a single NULL-Element
int attachmentCount = task.getAttachments().size(); int attachmentCount = task.getAttachments().size();
@ -226,7 +225,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testRemoveAttachment() public void testRemoveAttachment()
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException, SQLException { AttachmentPersistenceException {
setUpMethod(); setUpMethod();
task.addAttachment(attachment); task.addAttachment(attachment);
task = taskService.updateTask(task); task = taskService.updateTask(task);
@ -250,7 +249,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testRemoveAttachmentWithNullAndNotAddedId() public void testRemoveAttachmentWithNullAndNotAddedId()
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException, SQLException { AttachmentPersistenceException {
setUpMethod(); setUpMethod();
task.addAttachment(attachment); task.addAttachment(attachment);
task = taskService.updateTask(task); task = taskService.updateTask(task);
@ -276,7 +275,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testUpdateAttachment() public void testUpdateAttachment()
throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException, throws TaskNotFoundException, WorkbasketNotFoundException, ClassificationNotFoundException,
InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, NotAuthorizedException,
AttachmentPersistenceException, SQLException { AttachmentPersistenceException {
setUpMethod(); setUpMethod();
((TaskImpl) task).setAttachments(new ArrayList<>()); ((TaskImpl) task).setAttachments(new ArrayList<>());
task = taskService.updateTask(task); task = taskService.updateTask(task);
@ -312,7 +311,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void modifyExistingAttachment() public void modifyExistingAttachment()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException, throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException { AttachmentPersistenceException {
setUpMethod(); setUpMethod();
// setup test // setup test
assertThat(task.getAttachments().size(), equalTo(0)); assertThat(task.getAttachments().size(), equalTo(0));
@ -396,7 +395,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void replaceExistingAttachments() public void replaceExistingAttachments()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException, throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException { AttachmentPersistenceException {
setUpMethod(); setUpMethod();
// setup test // setup test
assertThat(task.getAttachments().size(), equalTo(0)); assertThat(task.getAttachments().size(), equalTo(0));
@ -441,7 +440,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testPrioDurationOfTaskFromAttachmentsAtUpdate() public void testPrioDurationOfTaskFromAttachmentsAtUpdate()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException, WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException { ConcurrencyException, AttachmentPersistenceException {
@ -491,7 +490,7 @@ public class UpdateTaskAttachmentsAccTest extends AbstractAccTest {
public void testAddCustomAttributeToAttachment() public void testAddCustomAttributeToAttachment()
throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException, throws TaskNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException, WorkbasketNotFoundException, InvalidArgumentException, ConcurrencyException, InvalidWorkbasketException,
AttachmentPersistenceException, SQLException { AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
task = taskService.getTask("TKI:000000000000000000000000000000000000"); // class T2000, prio 1, SL P1D 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.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.sql.SQLException;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
@ -23,18 +22,12 @@ import pro.taskana.BulkOperationResults;
import pro.taskana.Task; import pro.taskana.Task;
import pro.taskana.TaskService; import pro.taskana.TaskService;
import pro.taskana.TaskState; 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.InvalidArgumentException;
import pro.taskana.exceptions.InvalidOwnerException; import pro.taskana.exceptions.InvalidOwnerException;
import pro.taskana.exceptions.InvalidStateException; import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.TaskNotFoundException; import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.TaskanaException; import pro.taskana.exceptions.TaskanaException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.security.JAASRunner; import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId; import pro.taskana.security.WithAccessId;
@ -53,8 +46,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testClaimTask() public void testClaimTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, TaskNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException { InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000025"); Task task = taskService.getTask("TKI:000000000000000000000000000000000025");
@ -76,8 +68,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test(expected = InvalidOwnerException.class) @Test(expected = InvalidOwnerException.class)
public void testThrowsExceptionIfTaskIsAlreadyClaimed() public void testThrowsExceptionIfTaskIsAlreadyClaimed()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, TaskNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException { InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000026"); Task task = taskService.getTask("TKI:000000000000000000000000000000000026");
@ -90,8 +81,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testClaimAlreadyClaimedByCallerTask() public void testClaimAlreadyClaimedByCallerTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, TaskNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException { InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000027"); Task task = taskService.getTask("TKI:000000000000000000000000000000000027");
@ -104,8 +94,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test(expected = InvalidOwnerException.class) @Test(expected = InvalidOwnerException.class)
public void testForceClaimTaskWhichIsAlreadyClaimedByAnotherUser() public void testForceClaimTaskWhichIsAlreadyClaimedByAnotherUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, TaskNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException { InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task task = taskService.getTask("TKI:000000000000000000000000000000000028"); Task task = taskService.getTask("TKI:000000000000000000000000000000000028");
@ -118,8 +107,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testCancelClaimTask() public void testCancelClaimTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, TaskNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException { InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000029"); Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000029");
@ -139,8 +127,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test(expected = InvalidOwnerException.class) @Test(expected = InvalidOwnerException.class)
public void testThrowsExceptionIfCancelClaimOfTaskFromAnotherUser() public void testThrowsExceptionIfCancelClaimOfTaskFromAnotherUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, TaskNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException { InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000030"); Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000030");
@ -153,8 +140,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testForceCancelClaimOfTaskFromAnotherUser() public void testForceCancelClaimOfTaskFromAnotherUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, TaskNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException { InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000031"); Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000031");
@ -174,8 +160,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testCompleteTask() public void testCompleteTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, TaskNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException { InvalidStateException, InvalidOwnerException {
Instant before = Instant.now().minus(Duration.ofSeconds(3L)); Instant before = Instant.now().minus(Duration.ofSeconds(3L));
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
@ -199,8 +184,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testForceCompleteUnclaimedTask() public void testForceCompleteUnclaimedTask()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, TaskNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException { InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000033"); Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000033");
@ -221,8 +205,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test(expected = InvalidOwnerException.class) @Test(expected = InvalidOwnerException.class)
public void testThrowsExceptionIfCompletingClaimedTaskOfAnotherUser() public void testThrowsExceptionIfCompletingClaimedTaskOfAnotherUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, TaskNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException { InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000034"); Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000034");
@ -235,8 +218,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testForceCompleteClaimedTaskOfAnotherUser() public void testForceCompleteClaimedTaskOfAnotherUser()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, TaskNotFoundException,
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
InvalidStateException, InvalidOwnerException { InvalidStateException, InvalidOwnerException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000035"); Task claimedTask = taskService.getTask("TKI:000000000000000000000000000000000035");
@ -257,9 +239,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testBulkCompleteTasks() public void testBulkCompleteTasks()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws NotAuthorizedException, InvalidArgumentException, TaskNotFoundException {
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
List<String> taskIdList = new ArrayList<>(); List<String> taskIdList = new ArrayList<>();
@ -282,9 +262,7 @@ public class WorkOnTaskAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testBulkDeleteTasksWithException() public void testBulkDeleteTasksWithException()
throws SQLException, NotAuthorizedException, InvalidArgumentException, ClassificationNotFoundException, throws InvalidArgumentException {
WorkbasketNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, TaskNotFoundException,
ConcurrencyException, AttachmentPersistenceException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
List<String> taskIdList = new ArrayList<>(); 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.assertNotNull;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
@ -39,7 +38,7 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
groupNames = {"businessadmin"}) groupNames = {"businessadmin"})
@Test @Test
public void testCreateWorkbasket() public void testCreateWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException { InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size(); int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
@ -67,8 +66,8 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
userName = "dummy") userName = "dummy")
@Test(expected = NotAuthorizedException.class) @Test(expected = NotAuthorizedException.class)
public void testCreateWorkbasketNotAuthorized() public void testCreateWorkbasketNotAuthorized()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, InvalidWorkbasketException, WorkbasketAlreadyExistException,
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException { DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.newWorkbasket("key3", "DOMAIN_A"); Workbasket workbasket = workbasketService.newWorkbasket("key3", "DOMAIN_A");
@ -85,8 +84,8 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
groupNames = {"businessadmin"}) groupNames = {"businessadmin"})
@Test(expected = DomainNotFoundException.class) @Test(expected = DomainNotFoundException.class)
public void testCreateWorkbasketWithInvalidDomain() public void testCreateWorkbasketWithInvalidDomain()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, InvalidWorkbasketException, WorkbasketAlreadyExistException,
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException { DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.newWorkbasket("key3", "UNKNOWN_DOMAIN"); Workbasket workbasket = workbasketService.newWorkbasket("key3", "UNKNOWN_DOMAIN");
@ -103,7 +102,7 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
groupNames = {"businessadmin"}) groupNames = {"businessadmin"})
@Test @Test
public void testCreateWorkbasketWithMissingRequiredField() public void testCreateWorkbasketWithMissingRequiredField()
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketAlreadyExistException, throws NotAuthorizedException, WorkbasketAlreadyExistException,
DomainNotFoundException { DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
@ -151,7 +150,7 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
groupNames = {"businessadmin"}) groupNames = {"businessadmin"})
@Test @Test
public void testWorkbasketAccessItemSetName() public void testWorkbasketAccessItemSetName()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException { InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size(); 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.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.util.List; import java.util.List;
import org.junit.Before; import org.junit.Before;
@ -140,8 +139,8 @@ public class DeleteWorkbasketAccTest extends AbstractAccTest {
groupNames = {"businessadmin"}) groupNames = {"businessadmin"})
@Test @Test
public void testCreateAndDeleteWorkbasket() public void testCreateAndDeleteWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, InvalidWorkbasketException, WorkbasketAlreadyExistException,
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException { DomainNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size(); 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.Workbasket;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketSummary; import pro.taskana.WorkbasketSummary;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.security.JAASRunner; import pro.taskana.security.JAASRunner;
@ -127,7 +126,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
userName = "user_3_1", groupNames = {"group_1"}) userName = "user_3_1", groupNames = {"group_1"})
@Test @Test
public void testDistributionTargetCallsFailWithNotAuthorizedException() public void testDistributionTargetCallsFailWithNotAuthorizedException()
throws NotAuthorizedException, WorkbasketNotFoundException { throws WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
String existingWb = "WBI:100000000000000000000000000000000001"; String existingWb = "WBI:100000000000000000000000000000000001";
@ -170,7 +169,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2", "businessadmin"}) groupNames = {"group_1", "group_2", "businessadmin"})
@Test @Test
public void testAddAndRemoveDistributionTargets() public void testAddAndRemoveDistributionTargets()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException { throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A"); Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
@ -201,7 +200,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"businessadmin"}) groupNames = {"businessadmin"})
@Test @Test
public void testAddAndRemoveDistributionTargetsOnWorkbasketWithoutReadPermission() public void testAddAndRemoveDistributionTargetsOnWorkbasketWithoutReadPermission()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException { throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("GPK_B_KSC_2", "DOMAIN_B"); Workbasket workbasket = workbasketService.getWorkbasket("GPK_B_KSC_2", "DOMAIN_B");
@ -227,7 +226,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test(expected = NotAuthorizedException.class) @Test(expected = NotAuthorizedException.class)
public void testAddDistributionTargetsFailsNotAuthorized() public void testAddDistributionTargetsFailsNotAuthorized()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException { throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A"); Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC_1", "DOMAIN_A");
@ -277,7 +276,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test @Test
public void testGetDistributionSourcesById() public void testGetDistributionSourcesById()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException { throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> distributionSources = workbasketService List<WorkbasketSummary> distributionSources = workbasketService
@ -298,7 +297,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test @Test
public void testGetDistributionSourcesByKeyDomain() public void testGetDistributionSourcesByKeyDomain()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException { throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> distributionSources = workbasketService List<WorkbasketSummary> distributionSources = workbasketService
@ -318,7 +317,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"undefinedgroup"}) groupNames = {"undefinedgroup"})
@Test(expected = NotAuthorizedException.class) @Test(expected = NotAuthorizedException.class)
public void testQueryDistributionSourcesThrowsNotAuthorized() public void testQueryDistributionSourcesThrowsNotAuthorized()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException { throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> distributionSources = workbasketService List<WorkbasketSummary> distributionSources = workbasketService
@ -332,7 +331,7 @@ public class DistributionTargetsAccTest extends AbstractAccTest {
groupNames = {"group_1", "group_2"}) groupNames = {"group_1", "group_2"})
@Test(expected = WorkbasketNotFoundException.class) @Test(expected = WorkbasketNotFoundException.class)
public void testQueryDistributionSourcesThrowsWorkbasketNotFound() public void testQueryDistributionSourcesThrowsWorkbasketNotFound()
throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException, SQLException { throws NotAuthorizedException, WorkbasketNotFoundException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> distributionSources = workbasketService List<WorkbasketSummary> distributionSources = workbasketService

View File

@ -1,6 +1,5 @@
package acceptance.workbasket; package acceptance.workbasket;
import java.sql.SQLException;
import java.util.List; import java.util.List;
import org.junit.Assert; import org.junit.Assert;
@ -12,8 +11,6 @@ import pro.taskana.Workbasket;
import pro.taskana.WorkbasketPermission; import pro.taskana.WorkbasketPermission;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketType; import pro.taskana.WorkbasketType;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.security.JAASRunner; import pro.taskana.security.JAASRunner;
@ -34,8 +31,7 @@ public class GetWorkbasketAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testGetWorkbasket() public void testGetWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, WorkbasketNotFoundException {
InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("WBI:100000000000000000000000000000000007"); Workbasket workbasket = workbasketService.getWorkbasket("WBI:100000000000000000000000000000000007");
@ -67,16 +63,14 @@ public class GetWorkbasketAccTest extends AbstractAccTest {
@Test(expected = WorkbasketNotFoundException.class) @Test(expected = WorkbasketNotFoundException.class)
public void testThrowsExceptionIfIdIsInvalid() public void testThrowsExceptionIfIdIsInvalid()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, WorkbasketNotFoundException {
InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
workbasketService.getWorkbasket("INVALID_ID"); workbasketService.getWorkbasket("INVALID_ID");
} }
@Test(expected = NotAuthorizedException.class) @Test(expected = NotAuthorizedException.class)
public void testThrowsExceptionIfNotAuthorized() public void testThrowsExceptionIfNotAuthorized()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, WorkbasketNotFoundException {
InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
workbasketService.getWorkbasket("WBI:100000000000000000000000000000000001"); 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.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.sql.SQLException;
import java.util.List; import java.util.List;
import org.junit.Assert; import org.junit.Assert;
@ -91,7 +90,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketValuesForColumnName() throws NotAuthorizedException { public void testQueryWorkbasketValuesForColumnName() {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<String> columnValueList = workbasketService.createWorkbasketQuery() List<String> columnValueList = workbasketService.createWorkbasketQuery()
.listValues("NAME", null); .listValues("NAME", null);
@ -110,8 +109,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByDomain() public void testQueryWorkbasketByDomain() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.domainIn("DOMAIN_B") .domainIn("DOMAIN_B")
@ -123,8 +121,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByDomainAndType() public void testQueryWorkbasketByDomainAndType() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.domainIn("DOMAIN_A") .domainIn("DOMAIN_A")
@ -137,8 +134,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByName() public void testQueryWorkbasketByName() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameIn("Gruppenpostkorb KSC") .nameIn("Gruppenpostkorb KSC")
@ -151,8 +147,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByNameStartsWith() public void testQueryWorkbasketByNameStartsWith() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%Gruppenpostkorb KSC%") .nameLike("%Gruppenpostkorb KSC%")
@ -164,8 +159,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByNameContains() public void testQueryWorkbasketByNameContains() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%Teamlead%", "%Gruppenpostkorb KSC%") .nameLike("%Teamlead%", "%Gruppenpostkorb KSC%")
@ -177,8 +171,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByNameContainsCaseInsensitive() public void testQueryWorkbasketByNameContainsCaseInsensitive() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%TEAMLEAD%") .nameLike("%TEAMLEAD%")
@ -190,8 +183,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByDescription() public void testQueryWorkbasketByDescription() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.descriptionLike("%ppk%", "%gruppen%") .descriptionLike("%ppk%", "%gruppen%")
@ -205,8 +197,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByOwnerLike() public void testQueryWorkbasketByOwnerLike() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.ownerLike("%an%", "%te%") .ownerLike("%an%", "%te%")
@ -219,8 +210,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByKey() public void testQueryWorkbasketByKey() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.keyIn("GPK_KSC") .keyIn("GPK_KSC")
@ -232,8 +222,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByMultipleKeys() public void testQueryWorkbasketByMultipleKeys() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.keyIn("GPK_KSC_1", "GPK_KSC") .keyIn("GPK_KSC_1", "GPK_KSC")
@ -245,8 +234,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByMultipleKeysWithUnknownKey() public void testQueryWorkbasketByMultipleKeysWithUnknownKey() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.keyIn("GPK_KSC_1", "GPK_Ksc", "GPK_KSC_3") .keyIn("GPK_KSC_1", "GPK_Ksc", "GPK_KSC_3")
@ -258,8 +246,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByKeyContains() public void testQueryWorkbasketByKeyContains() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.keyLike("%KSC%") .keyLike("%KSC%")
@ -271,8 +258,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByKeyContainsIgnoreCase() public void testQueryWorkbasketByKeyContainsIgnoreCase() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.keyLike("%kSc%") .keyLike("%kSc%")
@ -284,8 +270,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByKeyOrNameContainsIgnoreCase() public void testQueryWorkbasketByKeyOrNameContainsIgnoreCase() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.keyOrNameLike("%kSc%") .keyOrNameLike("%kSc%")
@ -297,8 +282,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByNameStartsWithSortedByNameAscending() public void testQueryWorkbasketByNameStartsWithSortedByNameAscending() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%Gruppenpostkorb KSC%") .nameLike("%Gruppenpostkorb KSC%")
@ -322,8 +306,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "max") userName = "max")
@Test @Test
public void testQueryWorkbasketByNameStartsWithSortedByNameDescending() public void testQueryWorkbasketByNameStartsWithSortedByNameDescending() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("basxet%") .nameLike("basxet%")
@ -344,8 +327,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "max") userName = "max")
@Test @Test
public void testQueryWorkbasketByNameStartsWithSortedByKeyAscending() public void testQueryWorkbasketByNameStartsWithSortedByKeyAscending() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("basxet%") .nameLike("basxet%")
@ -366,8 +348,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
@WithAccessId( @WithAccessId(
userName = "max") userName = "max")
@Test @Test
public void testQueryWorkbasketByNameStartsWithSortedByKeyDescending() public void testQueryWorkbasketByNameStartsWithSortedByKeyDescending() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("basxet%") .nameLike("basxet%")
@ -389,8 +370,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByCreated() public void testQueryWorkbasketByCreated() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.createdWithin(todaysInterval()) .createdWithin(todaysInterval())
@ -402,8 +382,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
userName = "teamlead_1", userName = "teamlead_1",
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test @Test
public void testQueryWorkbasketByModified() public void testQueryWorkbasketByModified() {
throws SQLException, NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.modifiedWithin(todaysInterval()) .modifiedWithin(todaysInterval())
@ -416,7 +395,7 @@ public class QueryWorkbasketAccTest extends AbstractAccTest {
groupNames = "admin") groupNames = "admin")
@Test @Test
public void testQueryWorkbasketByAdmin() public void testQueryWorkbasketByAdmin()
throws SQLException, NotAuthorizedException, InvalidArgumentException { throws NotAuthorizedException, InvalidArgumentException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery() List<WorkbasketSummary> results = workbasketService.createWorkbasketQuery()
.nameLike("%") .nameLike("%")

View File

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

View File

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

View File

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

View File

@ -1,6 +1,5 @@
package acceptance.workbasket; package acceptance.workbasket;
import java.sql.SQLException;
import java.time.Instant; import java.time.Instant;
import org.junit.Assert; import org.junit.Assert;
@ -11,7 +10,6 @@ import acceptance.AbstractAccTest;
import pro.taskana.Workbasket; import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.WorkbasketType; import pro.taskana.WorkbasketType;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException; import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.exceptions.WorkbasketNotFoundException;
@ -33,8 +31,7 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
groupNames = {"group_1", "businessadmin"}) groupNames = {"group_1", "businessadmin"})
@Test @Test
public void testUpdateWorkbasket() public void testUpdateWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A"); Workbasket workbasket = workbasketService.getWorkbasket("GPK_KSC", "DOMAIN_A");
Instant modified = workbasket.getModified(); Instant modified = workbasket.getModified();
@ -66,8 +63,7 @@ public class UpdateWorkbasketAccTest extends AbstractAccTest {
groupNames = {"group_1"}) groupNames = {"group_1"})
@Test(expected = NotAuthorizedException.class) @Test(expected = NotAuthorizedException.class)
public void testCheckAuthorizationToUpdateWorkbasket() public void testCheckAuthorizationToUpdateWorkbasket()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, WorkbasketNotFoundException, InvalidWorkbasketException {
InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
Workbasket workbasket = workbasketService.getWorkbasket("USER_1_1", "DOMAIN_A"); 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.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.sql.SQLException;
import java.util.List; import java.util.List;
import org.junit.Assert; import org.junit.Assert;
@ -23,7 +22,6 @@ import pro.taskana.WorkbasketAccessItem;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.exceptions.ClassificationNotFoundException; import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException; import pro.taskana.exceptions.NotAuthorizedToQueryWorkbasketException;
import pro.taskana.exceptions.TaskAlreadyExistException; import pro.taskana.exceptions.TaskAlreadyExistException;
@ -83,8 +81,7 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
groupNames = {"group_1", "businessadmin"}) groupNames = {"group_1", "businessadmin"})
@Test @Test
public void testUpdateWorkbasketAccessItemRejected() public void testUpdateWorkbasketAccessItemRejected()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException {
InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketAccessItem accessItem = workbasketService WorkbasketAccessItem accessItem = workbasketService
.newWorkbasketAccessItem("WBI:100000000000000000000000000000000001", "user1"); .newWorkbasketAccessItem("WBI:100000000000000000000000000000000001", "user1");
@ -125,8 +122,8 @@ public class UpdateWorkbasketAuthorizationsAccTest extends AbstractAccTest {
groupNames = {"group_2", "businessadmin"}) groupNames = {"group_2", "businessadmin"})
@Test @Test
public void testUpdatedAccessItemLeadsToNotAuthorizedException() public void testUpdatedAccessItemLeadsToNotAuthorizedException()
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
ClassificationNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException { ClassificationNotFoundException, TaskAlreadyExistException {
TaskService taskService = taskanaEngine.getTaskService(); TaskService taskService = taskanaEngine.getTaskService();
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService(); WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();

View File

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

View File

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

View File

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

View File

@ -15,9 +15,6 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
import pro.taskana.ObjectReference; import pro.taskana.ObjectReference;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
/** /**
* Test for ObjectReferenceQueryImpl. * Test for ObjectReferenceQueryImpl.
* *
@ -40,7 +37,7 @@ public class ObjectReferenceQueryImplTest {
} }
@Test @Test
public void should_ReturnList_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException { public void should_ReturnList_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession); when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectList(any(), any())).thenReturn(new ArrayList<>()); when(sqlSession.selectList(any(), any())).thenReturn(new ArrayList<>());
@ -53,8 +50,7 @@ public class ObjectReferenceQueryImplTest {
} }
@Test @Test
public void should_ReturnListWithOffset_when_BuilderIsUsed() public void should_ReturnListWithOffset_when_BuilderIsUsed() {
throws NotAuthorizedException, InvalidArgumentException {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession); when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectList(any(), any(), any())).thenReturn(new ArrayList<>()); when(sqlSession.selectList(any(), any(), any())).thenReturn(new ArrayList<>());
@ -67,7 +63,7 @@ public class ObjectReferenceQueryImplTest {
} }
@Test @Test
public void should_ReturnOneItem_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException { public void should_ReturnOneItem_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession); when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectOne(any(), any())).thenReturn(new ObjectReference()); 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.TaskState;
import pro.taskana.TaskSummary; import pro.taskana.TaskSummary;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
/** /**
* Test for TaskQueryImpl. * Test for TaskQueryImpl.
@ -51,7 +49,7 @@ public class TaskQueryImplTest {
} }
@Test @Test
public void should_ReturnList_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException { public void should_ReturnList_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession); when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectList(any(), any())).thenReturn(new ArrayList<>()); when(sqlSession.selectList(any(), any())).thenReturn(new ArrayList<>());
List<TaskSummary> intermediate = new ArrayList<>(); List<TaskSummary> intermediate = new ArrayList<>();
@ -66,8 +64,7 @@ public class TaskQueryImplTest {
} }
@Test @Test
public void should_ReturnListWithOffset_when_BuilderIsUsed() public void should_ReturnListWithOffset_when_BuilderIsUsed() {
throws NotAuthorizedException, InvalidArgumentException {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession); when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectList(any(), any(), any())).thenReturn(new ArrayList<>()); when(sqlSession.selectList(any(), any(), any())).thenReturn(new ArrayList<>());
List<TaskSummary> intermediate = new ArrayList<>(); List<TaskSummary> intermediate = new ArrayList<>();
@ -82,7 +79,7 @@ public class TaskQueryImplTest {
} }
@Test @Test
public void should_ReturnOneItem_when_BuilderIsUsed() throws NotAuthorizedException, InvalidArgumentException { public void should_ReturnOneItem_when_BuilderIsUsed() {
when(taskanaEngine.getSqlSession()).thenReturn(sqlSession); when(taskanaEngine.getSqlSession()).thenReturn(sqlSession);
when(sqlSession.selectOne(any(), any())).thenReturn(new TaskSummaryImpl()); when(sqlSession.selectOne(any(), any())).thenReturn(new TaskSummaryImpl());
List<TaskSummary> intermediate = new ArrayList<>(); List<TaskSummary> intermediate = new ArrayList<>();

View File

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

View File

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

View File

@ -8,7 +8,6 @@ import java.io.InputStream;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
import javax.security.auth.login.LoginException;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.apache.ibatis.datasource.pooled.PooledDataSource; import org.apache.ibatis.datasource.pooled.PooledDataSource;
@ -32,7 +31,7 @@ public class TaskanaEngineConfigurationTest {
private static final int POOL_TIME_TO_WAIT = 50; private static final int POOL_TIME_TO_WAIT = 50;
@Test @Test
public void testCreateTaskanaEngine() throws FileNotFoundException, SQLException, LoginException { public void testCreateTaskanaEngine() throws SQLException {
DataSource ds = getDataSource(); DataSource ds = getDataSource();
TaskanaEngineConfiguration taskEngineConfiguration = new TaskanaEngineConfiguration(ds, false); 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 * 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 * 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: * 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
* jdbcDriver=com.ibm.db2.jcc.DB2Driver * dbPassword=db2password If any of these properties is missing, or the file doesn't exist, the default Datasource
* 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. * for h2 in-memory db is created.
* *
* @return dataSource for unit test * @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.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.io.FileNotFoundException;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
@ -15,7 +14,6 @@ import java.time.LocalTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.List; import java.util.List;
import javax.security.auth.login.LoginException;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.junit.Assert; import org.junit.Assert;
@ -64,7 +62,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
} }
@Before @Before
public void setup() throws FileNotFoundException, SQLException, LoginException { public void setup() throws SQLException {
dataSource = TaskanaEngineConfigurationTest.getDataSource(); dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, false); taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine(); taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
@ -401,8 +399,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
return new TimeInterval(begin, end); return new TimeInterval(begin, end);
} }
private Classification createDummyClassificationWithUniqueKey(String domain, String type) private Classification createDummyClassificationWithUniqueKey(String domain, String type) {
throws NotAuthorizedException {
Classification classification = classificationService.newClassification("TEST" + counter, domain, type); Classification classification = classificationService.newClassification("TEST" + counter, domain, type);
counter++; counter++;
return classification; return classification;

View File

@ -440,8 +440,7 @@ public class ClassificationServiceImplIntExplicitTest {
taskanaEngineImpl.setConnection(null); taskanaEngineImpl.setConnection(null);
} }
private Classification createNewClassificationWithUniqueKey(String domain, String type) private Classification createNewClassificationWithUniqueKey(String domain, String type) {
throws NotAuthorizedException {
Classification classification = classificationService.newClassification("TEST" + counter, domain, type); Classification classification = classificationService.newClassification("TEST" + counter, domain, type);
counter++; counter++;
return classification; 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.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import java.io.FileNotFoundException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import javax.security.auth.login.LoginException;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.junit.Assert; import org.junit.Assert;
@ -81,7 +79,7 @@ public class TaskServiceImplIntAutocommitTest {
} }
@Before @Before
public void setup() throws FileNotFoundException, SQLException, LoginException { public void setup() throws SQLException {
dataSource = TaskanaEngineConfigurationTest.getDataSource(); dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, false); taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, false);
@ -96,7 +94,7 @@ public class TaskServiceImplIntAutocommitTest {
} }
@Test @Test
public void testStart() throws FileNotFoundException, SQLException, TaskNotFoundException, public void testStart() throws TaskNotFoundException,
WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException,
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException { InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
@ -123,7 +121,7 @@ public class TaskServiceImplIntAutocommitTest {
@Test(expected = TaskNotFoundException.class) @Test(expected = TaskNotFoundException.class)
public void testStartTransactionFail() public void testStartTransactionFail()
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, throws TaskNotFoundException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException { WorkbasketAlreadyExistException, DomainNotFoundException {
@ -153,7 +151,7 @@ public class TaskServiceImplIntAutocommitTest {
@Test @Test
public void testCreateTaskInTaskanaWithDefaultDb() public void testCreateTaskInTaskanaWithDefaultDb()
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException, throws SQLException, NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
WorkbasketAlreadyExistException, DomainNotFoundException { WorkbasketAlreadyExistException, DomainNotFoundException {
@ -182,7 +180,7 @@ public class TaskServiceImplIntAutocommitTest {
} }
@Test @Test
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException, public void should_ReturnList_when_BuilderIsUsed() throws NotAuthorizedException,
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException, WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, SystemException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, SystemException,
WorkbasketAlreadyExistException, DomainNotFoundException { WorkbasketAlreadyExistException, DomainNotFoundException {
@ -279,8 +277,7 @@ public class TaskServiceImplIntAutocommitTest {
@Test(expected = TaskNotFoundException.class) @Test(expected = TaskNotFoundException.class)
public void shouldNotTransferAnyTask() public void shouldNotTransferAnyTask()
throws WorkbasketNotFoundException, NotAuthorizedException, TaskNotFoundException, InvalidWorkbasketException, throws WorkbasketNotFoundException, NotAuthorizedException, TaskNotFoundException, InvalidStateException {
ClassificationNotFoundException, InvalidStateException {
taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1"); taskServiceImpl.transfer(UUID.randomUUID() + "_X", "1");
} }
@ -373,7 +370,7 @@ public class TaskServiceImplIntAutocommitTest {
} }
@Test @Test
public void testWithPrimaryObjectRef() throws FileNotFoundException, SQLException, TaskNotFoundException, public void testWithPrimaryObjectRef() throws TaskNotFoundException,
WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException,
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException, ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException { InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,26 +1,24 @@
package pro.taskana; package pro.taskana;
import java.sql.SQLException; import javax.annotation.PostConstruct;
import javax.annotation.PostConstruct; import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
import org.mybatis.spring.transaction.SpringManagedTransactionFactory; import pro.taskana.configuration.SpringTaskanaEngineConfiguration;
import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.configuration.SpringTaskanaEngineConfiguration;
import pro.taskana.impl.TaskanaEngineImpl; /**
* This class configures the TaskanaEngine for spring
/** */
* This class configures the TaskanaEngine for spring public class SpringTaskanaEngineImpl extends TaskanaEngineImpl {
*/
public class SpringTaskanaEngineImpl extends TaskanaEngineImpl { public SpringTaskanaEngineImpl(SpringTaskanaEngineConfiguration taskanaEngineConfiguration) {
super(taskanaEngineConfiguration);
public SpringTaskanaEngineImpl(SpringTaskanaEngineConfiguration taskanaEngineConfiguration) { }
super(taskanaEngineConfiguration);
} @PostConstruct
public void init() {
@PostConstruct this.transactionFactory = new SpringManagedTransactionFactory();
public void init() throws SQLException { this.sessionManager = createSqlSessionManager();
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.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskAlreadyExistException; import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.WorkbasketNotFoundException; import pro.taskana.exceptions.WorkbasketNotFoundException;
@ -23,8 +22,7 @@ public class TaskanaComponent {
} }
public void triggerRollback() throws NotAuthorizedException, WorkbasketNotFoundException, public void triggerRollback() throws NotAuthorizedException, WorkbasketNotFoundException,
ClassificationNotFoundException, InvalidWorkbasketException, TaskAlreadyExistException, ClassificationNotFoundException, TaskAlreadyExistException, InvalidArgumentException {
InvalidArgumentException {
Task task = taskService.newTask("1"); Task task = taskService.newTask("1");
task.setName("Unit Test Task"); task.setName("Unit Test Task");
ObjectReference objRef = new ObjectReference(); ObjectReference objRef = new ObjectReference();

View File

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

View File

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

View File

@ -22,7 +22,7 @@ public abstract class AbstractPagingController {
pagesize = Long.valueOf(pagesizeParam); pagesize = Long.valueOf(pagesizeParam);
page = Long.valueOf(pageParam); page = Long.valueOf(pageParam);
} catch (NumberFormatException e) { } 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); PageMetadata pageMetadata = new PageMetadata(pagesize, page, totalElements);
if (pageMetadata.getNumber() > pageMetadata.getTotalPages()) { if (pageMetadata.getNumber() > pageMetadata.getTotalPages()) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -37,7 +37,7 @@ public class WorkbasketAssembler {
return addLinks(resource, wb); 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); WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket(wbResource.key, wbResource.domain);
BeanUtils.copyProperties(wbResource, workbasket); BeanUtils.copyProperties(wbResource, workbasket);
@ -55,7 +55,8 @@ public class WorkbasketAssembler {
resource.add(linkTo(methodOn(WorkbasketController.class).getWorkbasketAccessItems(wb.getId())) resource.add(linkTo(methodOn(WorkbasketController.class).getWorkbasketAccessItems(wb.getId()))
.withRel("accessItems")); .withRel("accessItems"));
resource.add(linkTo(WorkbasketController.class).withRel("allWorkbaskets")); 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; return resource;
} }
} }

View File

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

View File

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