TSK-398: domain is checked for existance during workbasket creation.
This commit is contained in:
parent
b0156d9af2
commit
9803de0502
|
@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidOwnerException;
|
||||
import pro.taskana.exceptions.InvalidStateException;
|
||||
|
@ -39,7 +40,7 @@ public class TaskanaRestTest {
|
|||
@GET
|
||||
public Response startTask() throws NotAuthorizedException, WorkbasketNotFoundException,
|
||||
ClassificationNotFoundException, ClassificationAlreadyExistException, InvalidWorkbasketException,
|
||||
TaskAlreadyExistException, InvalidArgumentException, WorkbasketAlreadyExistException {
|
||||
TaskAlreadyExistException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Workbasket workbasket = taskanaEjb.getWorkbasketService().newWorkbasket("key", "cdiDomain");
|
||||
workbasket.setName("wb");
|
||||
workbasket.setType(WorkbasketType.PERSONAL);
|
||||
|
|
|
@ -2,6 +2,7 @@ package pro.taskana;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import pro.taskana.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
|
@ -56,9 +57,12 @@ public interface WorkbasketService {
|
|||
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
|
||||
* @throws WorkbasketAlreadyExistException
|
||||
* if the workbasket exists already
|
||||
* @throws DomainNotFoundException
|
||||
* if the domain does not exist in the configuration.
|
||||
*/
|
||||
Workbasket createWorkbasket(Workbasket workbasket)
|
||||
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException;
|
||||
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,
|
||||
DomainNotFoundException;
|
||||
|
||||
/**
|
||||
* Update a Workbasket.
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -42,6 +43,7 @@ public class TaskanaEngineConfiguration {
|
|||
private static final String H2_DRIVER = "org.h2.Driver";
|
||||
private static final String TASKANA_PROPERTIES = "/taskana.properties";
|
||||
private static final String TASKANA_ROLES_SEPARATOR = "|";
|
||||
private static final String TASKANA_DOMAINS_PROPERTY = "taskana.domains";
|
||||
|
||||
// Taskana properties file
|
||||
protected String propertiesFileName = TASKANA_PROPERTIES;
|
||||
|
@ -64,7 +66,7 @@ public class TaskanaEngineConfiguration {
|
|||
private List<LocalDate> customHolidays;
|
||||
|
||||
// List of configured domain names
|
||||
protected List<String> domains = null;
|
||||
protected List<String> domains = new ArrayList<String>();
|
||||
|
||||
public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions)
|
||||
throws SQLException {
|
||||
|
@ -103,8 +105,21 @@ public class TaskanaEngineConfiguration {
|
|||
}
|
||||
|
||||
public void initTaskanaProperties(String propertiesFile, String rolesSeparator) {
|
||||
LOGGER.debug("Reading taskana configuration from {} with role separator {}", propertiesFile, rolesSeparator);
|
||||
Properties props = readPropertiesFromFile(propertiesFile);
|
||||
initTaskanaRoles(props, rolesSeparator);
|
||||
initDomains(props);
|
||||
}
|
||||
|
||||
private void initDomains(Properties props) {
|
||||
String domainNames = props.getProperty(TASKANA_DOMAINS_PROPERTY);
|
||||
if (domainNames != null && !domainNames.isEmpty()) {
|
||||
StringTokenizer st = new StringTokenizer(domainNames, ",");
|
||||
while (st.hasMoreTokens()) {
|
||||
domains.add(st.nextToken().trim().toUpperCase());
|
||||
}
|
||||
}
|
||||
LOGGER.debug("Configured domains: {}", domains);
|
||||
}
|
||||
|
||||
private void initTaskanaRoles(Properties props, String rolesSeparator) {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package pro.taskana.exceptions;
|
||||
|
||||
/**
|
||||
* This exception is thrown if a domain name is specified which is not found in the configuration.
|
||||
*/
|
||||
public class DomainNotFoundException extends NotFoundException {
|
||||
|
||||
public DomainNotFoundException(String domain, String msg) {
|
||||
super(domain, msg);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
|
@ -372,4 +372,14 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given domain does exist in the configuration.
|
||||
*
|
||||
* @param domain
|
||||
* @return <code>true</code> if the domain exists
|
||||
*/
|
||||
public boolean domainExists(String domain) {
|
||||
return getConfiguration().getDomains().contains(domain);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import pro.taskana.WorkbasketPermission;
|
|||
import pro.taskana.WorkbasketQuery;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.WorkbasketSummary;
|
||||
import pro.taskana.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
|
@ -135,9 +136,11 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
|
||||
@Override
|
||||
public Workbasket createWorkbasket(Workbasket newWorkbasket)
|
||||
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException {
|
||||
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,
|
||||
DomainNotFoundException {
|
||||
LOGGER.debug("entry to createtWorkbasket(workbasket)", newWorkbasket);
|
||||
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
|
||||
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) newWorkbasket;
|
||||
try {
|
||||
taskanaEngine.openConnection();
|
||||
|
@ -383,7 +386,7 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
return new WorkbasketQueryImpl(taskanaEngine);
|
||||
}
|
||||
|
||||
private void validateWorkbasket(Workbasket workbasket) throws InvalidWorkbasketException {
|
||||
private void validateWorkbasket(Workbasket workbasket) throws InvalidWorkbasketException, DomainNotFoundException {
|
||||
// check that required properties (database not null) are set
|
||||
if (workbasket.getId() == null || workbasket.getId().length() == 0) {
|
||||
throw new InvalidWorkbasketException("Id must not be null for " + workbasket);
|
||||
|
@ -399,6 +402,10 @@ public class WorkbasketServiceImpl implements WorkbasketService {
|
|||
if (workbasket.getType() == null) {
|
||||
throw new InvalidWorkbasketException("Type must not be null for " + workbasket);
|
||||
}
|
||||
if (!taskanaEngine.domainExists(workbasket.getDomain())) {
|
||||
throw new DomainNotFoundException(workbasket.getDomain(),
|
||||
"Domain " + workbasket.getDomain() + " does not exist in the configuration.");
|
||||
}
|
||||
}
|
||||
|
||||
private void addWorkbasketAccessItemValuesToPermissionSet(WorkbasketAccessItem workbasketAccessItem,
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package acceptance.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
|
||||
/**
|
||||
* Test taskana configuration without roles.
|
||||
*
|
||||
* @author bbr
|
||||
*/
|
||||
public class TaskanaConfigAccTest extends TaskanaEngineImpl {
|
||||
|
||||
public TaskanaConfigAccTest() throws SQLException {
|
||||
super(new TaskanaEngineConfiguration(TaskanaEngineConfigurationTest.getDataSource(), true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDomains() {
|
||||
assertEquals(2, getConfiguration().getDomains().size());
|
||||
assertTrue(getConfiguration().getDomains().contains("DOMAIN_A"));
|
||||
assertTrue(getConfiguration().getDomains().contains("DOMAIN_B"));
|
||||
assertFalse(getConfiguration().getDomains().contains("Domain_A"));
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -14,6 +14,7 @@ import pro.taskana.Workbasket;
|
|||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.WorkbasketType;
|
||||
import pro.taskana.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
|
@ -38,7 +39,7 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
|
|||
@Test
|
||||
public void testCreateWorkbasket()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
InvalidWorkbasketException, WorkbasketAlreadyExistException {
|
||||
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
int before = workbasketService.createWorkbasketQuery().domainIn("DOMAIN_A").list().size();
|
||||
|
||||
|
@ -66,10 +67,10 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
|
|||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testCreateWorkbasketNotAuthorized()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
InvalidWorkbasketException, WorkbasketAlreadyExistException {
|
||||
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
|
||||
Workbasket workbasket = workbasketService.newWorkbasket("key3", "novatec");
|
||||
Workbasket workbasket = workbasketService.newWorkbasket("key3", "DOMAIN_A");
|
||||
workbasket.setName("Megabasket");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setOrgLevel1("company");
|
||||
|
@ -78,12 +79,31 @@ public class CreateWorkbasketAccTest extends AbstractAccTest {
|
|||
fail("NotAuthorizedException should have been thrown");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "user_1_2",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test(expected = DomainNotFoundException.class)
|
||||
public void testCreateWorkbasketWithInvalidDomain()
|
||||
throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException,
|
||||
InvalidWorkbasketException, WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
|
||||
Workbasket workbasket = workbasketService.newWorkbasket("key3", "UNKNOWN_DOMAIN");
|
||||
workbasket.setName("Megabasket");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket.setOrgLevel1("company");
|
||||
workbasketService.createWorkbasket(workbasket);
|
||||
|
||||
fail("DomainNotFoundException should have been thrown");
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
userName = "dummy",
|
||||
groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testCreateWorkbasketWithMissingRequiredField()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketAlreadyExistException {
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketAlreadyExistException,
|
||||
DomainNotFoundException {
|
||||
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
|
||||
|
||||
Workbasket workbasket = workbasketService.newWorkbasket(null, "novatec");
|
||||
|
|
|
@ -35,6 +35,7 @@ import pro.taskana.Workbasket;
|
|||
import pro.taskana.WorkbasketPermission;
|
||||
import pro.taskana.WorkbasketType;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
|
@ -221,7 +222,8 @@ public class WorkbasketServiceImplTest {
|
|||
|
||||
@Test
|
||||
public void testCreateWorkbasket_InvalidWorkbasketCases()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketAlreadyExistException {
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, WorkbasketAlreadyExistException,
|
||||
DomainNotFoundException {
|
||||
WorkbasketImpl wb = new WorkbasketImpl();
|
||||
int serviceCalls = 1;
|
||||
|
||||
|
@ -342,12 +344,13 @@ public class WorkbasketServiceImplTest {
|
|||
@Test
|
||||
public void testCreateWorkbasket_WithoutDistibutionTargets()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
WorkbasketImpl expectedWb = createTestWorkbasket(null, "Key-1");
|
||||
doNothing().when(workbasketMapperMock).insert(expectedWb);
|
||||
doReturn(expectedWb).when(workbasketMapperMock).findById(any());
|
||||
doReturn(taskanaEngineConfigurationMock).when(taskanaEngineImplMock).getConfiguration();
|
||||
doReturn(false).when(taskanaEngineConfigurationMock).isSecurityEnabled();
|
||||
doReturn(true).when(taskanaEngineImplMock).domainExists(any());
|
||||
|
||||
Workbasket actualWb = cutSpy.createWorkbasket(expectedWb);
|
||||
cutSpy.setDistributionTargets(expectedWb.getId(), null);
|
||||
|
@ -362,6 +365,7 @@ public class WorkbasketServiceImplTest {
|
|||
verify(taskanaEngineImplMock, times(3)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(2)).checkRoleMembership(any());
|
||||
verify(taskanaEngineImplMock, times(1)).isUserInRole(any());
|
||||
verify(taskanaEngineImplMock, times(1)).domainExists(any());
|
||||
verify(distributionTargetMapperMock, times(1)).deleteAllDistributionTargetsBySourceId(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
|
@ -375,11 +379,12 @@ public class WorkbasketServiceImplTest {
|
|||
@Test
|
||||
public void testCreateWorkbasket_WithDistibutionTargets()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
final int distTargetAmount = 2;
|
||||
WorkbasketImpl expectedWb = createTestWorkbasket(null, "Key-1");
|
||||
doNothing().when(workbasketMapperMock).insert(expectedWb);
|
||||
doReturn(expectedWb).when(cutSpy).getWorkbasket(any());
|
||||
doReturn(true).when(taskanaEngineImplMock).domainExists(any());
|
||||
|
||||
Workbasket actualWb = cutSpy.createWorkbasket(expectedWb);
|
||||
cutSpy.setDistributionTargets(expectedWb.getId(), createTestDistributionTargets(distTargetAmount));
|
||||
|
@ -393,6 +398,7 @@ public class WorkbasketServiceImplTest {
|
|||
verify(workbasketMapperMock, times(1)).update(any());
|
||||
verify(taskanaEngineImplMock, times(4)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(4)).checkRoleMembership(any());
|
||||
verify(taskanaEngineImplMock, times(3)).domainExists(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -405,9 +411,10 @@ public class WorkbasketServiceImplTest {
|
|||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void testCreateWorkbasket_DistibutionTargetNotExisting()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
WorkbasketImpl expectedWb = createTestWorkbasket("ID-1", "Key-1");
|
||||
doNothing().when(workbasketMapperMock).insert(expectedWb);
|
||||
doReturn(true).when(taskanaEngineImplMock).domainExists(any());
|
||||
|
||||
try {
|
||||
cutSpy.createWorkbasket(expectedWb);
|
||||
|
@ -424,6 +431,7 @@ public class WorkbasketServiceImplTest {
|
|||
verify(cutSpy, times(1)).getWorkbasket(any());
|
||||
verify(taskanaEngineImplMock, times(3)).returnConnection();
|
||||
verify(taskanaEngineImplMock, times(2)).checkRoleMembership(any());
|
||||
verify(taskanaEngineImplMock, times(1)).domainExists(any());
|
||||
verifyNoMoreInteractions(taskQueryMock, taskServiceMock, workbasketMapperMock, workbasketAccessMapperMock,
|
||||
distributionTargetMapperMock,
|
||||
taskanaEngineImplMock, taskanaEngineConfigurationMock);
|
||||
|
@ -566,13 +574,13 @@ public class WorkbasketServiceImplTest {
|
|||
workbasket.setName("Workbasket " + id);
|
||||
workbasket.setDescription("Description WB with Key " + key);
|
||||
workbasket.setType(WorkbasketType.PERSONAL);
|
||||
workbasket.setDomain("");
|
||||
workbasket.setDomain("DOMAIN_A");
|
||||
return workbasket;
|
||||
}
|
||||
|
||||
private List<String> createTestDistributionTargets(int amount)
|
||||
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
List<String> distributionsTargets = new ArrayList<>();
|
||||
amount = (amount < 0) ? 0 : amount;
|
||||
for (int i = 0; i < amount; i++) {
|
||||
|
|
|
@ -34,6 +34,7 @@ import pro.taskana.WorkbasketType;
|
|||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
|
@ -97,12 +98,12 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
public void testStart() throws FileNotFoundException, SQLException, TaskNotFoundException,
|
||||
WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException,
|
||||
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException {
|
||||
Workbasket wb = workbasketService.newWorkbasket("workbasket", "novatec");
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Workbasket wb = workbasketService.newWorkbasket("workbasket", "DOMAIN_A");
|
||||
wb.setName("workbasket");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
Classification classification = classificationService.newClassification("TEST", "novatec", "t1");
|
||||
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "t1");
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = taskServiceImpl.newTask(wb.getId());
|
||||
|
@ -124,20 +125,20 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
|
||||
WorkbasketAlreadyExistException {
|
||||
Workbasket wb = workbasketService.newWorkbasket("wb1k1", "novatec");
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Workbasket wb = workbasketService.newWorkbasket("wb1k1", "DOMAIN_A");
|
||||
wb.setName("sdf");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
|
||||
Classification classification = classificationService.newClassification("TEST", "novatec", "t1");
|
||||
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "t1");
|
||||
classification = taskanaEngine.getClassificationService()
|
||||
.createClassification(classification);
|
||||
classification = taskanaEngine.getClassificationService().getClassification(
|
||||
classification.getKey(),
|
||||
classification.getDomain());
|
||||
|
||||
TaskImpl task = (TaskImpl) taskServiceImpl.newTask(wb.getKey(), "novatec");
|
||||
TaskImpl task = (TaskImpl) taskServiceImpl.newTask(wb.getKey(), "DOMAIN_A");
|
||||
task.setName("Unit Test Task");
|
||||
task.setClassificationKey(classification.getKey());
|
||||
task.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
|
||||
|
@ -154,7 +155,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
DBCleaner cleaner = new DBCleaner();
|
||||
cleaner.clearDb(TaskanaEngineConfiguration.createDefaultDataSource(), false);
|
||||
TaskanaEngineConfiguration taskanaEngineConfiguration = new TaskanaEngineConfiguration(null, false, false);
|
||||
|
@ -162,11 +163,11 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
((TaskanaEngineImpl) te).setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
|
||||
TaskServiceImpl taskServiceImpl = (TaskServiceImpl) te.getTaskService();
|
||||
|
||||
Workbasket wb = workbasketService.newWorkbasket("workbasket", "novatec");
|
||||
Workbasket wb = workbasketService.newWorkbasket("workbasket", "DOMAIN_A");
|
||||
wb.setName("workbasket");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
te.getWorkbasketService().createWorkbasket(wb);
|
||||
Classification classification = te.getClassificationService().newClassification("TEST", "novatec", "t1");
|
||||
Classification classification = te.getClassificationService().newClassification("TEST", "DOMAIN_A", "t1");
|
||||
te.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = taskServiceImpl.newTask(wb.getId());
|
||||
|
@ -183,12 +184,12 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, SystemException,
|
||||
WorkbasketAlreadyExistException {
|
||||
Workbasket wb = workbasketService.newWorkbasket("key", "novatec");
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Workbasket wb = workbasketService.newWorkbasket("key", "DOMAIN_A");
|
||||
wb.setName("workbasket");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
Classification classification = classificationService.newClassification("TEST", "novatec", "t1");
|
||||
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "t1");
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = taskServiceImpl.newTask(wb.getKey(), wb.getDomain());
|
||||
|
@ -202,7 +203,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
.descriptionLike("test")
|
||||
.priorityIn(1, 2, 2)
|
||||
.stateIn(TaskState.CLAIMED)
|
||||
.workbasketKeyDomainIn(new KeyDomain("asd", "novatec"), new KeyDomain("asdasdasd", "novatec"))
|
||||
.workbasketKeyDomainIn(new KeyDomain("asd", "novatec"), new KeyDomain("asdasdasd", "DOMAIN_A"))
|
||||
.ownerIn("test", "test2", "bla")
|
||||
.customAttributeIn("16", "test")
|
||||
.classificationKeyIn("pId1", "pId2")
|
||||
|
@ -220,7 +221,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
public void shouldTransferTaskToOtherWorkbasket()
|
||||
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
ClassificationAlreadyExistException, TaskNotFoundException, InterruptedException, TaskAlreadyExistException,
|
||||
InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException {
|
||||
InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Workbasket sourceWB;
|
||||
Workbasket destinationWB;
|
||||
WorkbasketImpl wb;
|
||||
|
@ -230,7 +231,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
final int sleepTime = 100;
|
||||
|
||||
// Source Workbasket
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket("key1", "domain");
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket("key1", "DOMAIN_A");
|
||||
wb.setName("Basic-Workbasket");
|
||||
wb.setDescription("Just used as base WB for Task here");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
|
@ -238,7 +239,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
sourceWB = workbasketService.createWorkbasket(wb);
|
||||
|
||||
// Destination Workbasket
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "domain");
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
|
||||
wb.setName("Desination-WorkBasket");
|
||||
|
||||
wb.setType(WorkbasketType.CLEARANCE);
|
||||
|
@ -247,7 +248,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
destinationWB = workbasketService.createWorkbasket(wb);
|
||||
|
||||
// Classification required for Task
|
||||
classification = (ClassificationImpl) classificationService.newClassification("KEY", "domain", "t1");
|
||||
classification = (ClassificationImpl) classificationService.newClassification("KEY", "DOMAIN_A", "t1");
|
||||
classification.setCategory("Test Classification");
|
||||
classification.setName("Transfert-Task Classification");
|
||||
classificationService.createClassification(classification);
|
||||
|
@ -286,7 +287,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException,
|
||||
ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException,
|
||||
TaskNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
final String user = CurrentUserContext.getUserid();
|
||||
|
||||
// Set up Security for this Test
|
||||
|
@ -305,7 +306,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
classification.setName("Transfert-Task Classification");
|
||||
classificationService.createClassification(classification);
|
||||
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("k5", "test-domain");
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("k5", "DOMAIN_A");
|
||||
wb.setName("BASE WB");
|
||||
wb.setDescription("Normal base WB");
|
||||
wb.setOwner(user);
|
||||
|
@ -313,7 +314,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
wb = (WorkbasketImpl) workbasketService.createWorkbasket(wb);
|
||||
createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true);
|
||||
|
||||
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket("key77", "d2");
|
||||
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket("key77", "DOMAIN_A");
|
||||
wbNoAppend.setName("Test-Security-WorkBasket-APPEND");
|
||||
wbNoAppend.setDescription("Workbasket without permission APPEND on Task");
|
||||
wbNoAppend.setOwner(user);
|
||||
|
@ -322,7 +323,7 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
wbNoAppend = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoAppend);
|
||||
createWorkbasketWithSecurity(wbNoAppend, wbNoAppend.getOwner(), true, true, false, true);
|
||||
|
||||
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket("k99", "test-domain");
|
||||
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket("k99", "DOMAIN_B");
|
||||
wbNoTransfer.setName("Test-Security-WorkBasket-TRANSFER");
|
||||
wbNoTransfer.setDescription("Workbasket without permission TRANSFER on Task");
|
||||
wbNoTransfer.setOwner(user);
|
||||
|
@ -373,12 +374,12 @@ public class TaskServiceImplIntAutocommitTest {
|
|||
public void testWithPrimaryObjectRef() throws FileNotFoundException, SQLException, TaskNotFoundException,
|
||||
WorkbasketNotFoundException, NotAuthorizedException, ClassificationNotFoundException,
|
||||
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException {
|
||||
Workbasket wb = workbasketService.newWorkbasket("workbasket", "novatec");
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Workbasket wb = workbasketService.newWorkbasket("workbasket", "DOMAIN_A");
|
||||
wb.setName("workbasket");
|
||||
wb.setType(WorkbasketType.GROUP);
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(wb);
|
||||
Classification classification = classificationService.newClassification("TEST", "novatec", "t1");
|
||||
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "t1");
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = taskServiceImpl.newTask(wb.getId());
|
||||
|
|
|
@ -8,8 +8,6 @@ import static org.junit.Assert.fail;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -38,6 +36,7 @@ import pro.taskana.WorkbasketType;
|
|||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
|
@ -49,7 +48,6 @@ import pro.taskana.exceptions.WorkbasketNotFoundException;
|
|||
import pro.taskana.impl.ClassificationImpl;
|
||||
import pro.taskana.impl.ClassificationServiceImpl;
|
||||
import pro.taskana.impl.JunitHelper;
|
||||
import pro.taskana.impl.ObjectReference;
|
||||
import pro.taskana.impl.TaskImpl;
|
||||
import pro.taskana.impl.TaskServiceImpl;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
|
@ -105,19 +103,19 @@ public class TaskServiceImplIntExplicitTest {
|
|||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
generateSampleAccessItems();
|
||||
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "novatec");
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
|
||||
workbasket.setName("workbasket");
|
||||
// workbasket.setId("1 "); // set id manually for authorization tests
|
||||
workbasket.setId("1"); // set id manually for authorization tests
|
||||
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
Classification classification = classificationService.newClassification("TEST", "novatec", "type1");
|
||||
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "type1");
|
||||
taskanaEngineImpl.getWorkbasketService().createWorkbasket(workbasket);
|
||||
taskanaEngineImpl.getClassificationService().createClassification(classification);
|
||||
connection.commit();
|
||||
|
@ -141,7 +139,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
|
@ -173,7 +171,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
throws FileNotFoundException, SQLException, TaskNotFoundException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
DataSource ds = TaskanaEngineConfiguration.createDefaultDataSource();
|
||||
DBCleaner cleaner = new DBCleaner();
|
||||
cleaner.clearDb(ds, false);
|
||||
|
@ -185,13 +183,13 @@ public class TaskServiceImplIntExplicitTest {
|
|||
WorkbasketServiceImpl workBasketServiceImpl = (WorkbasketServiceImpl) te.getWorkbasketService();
|
||||
ClassificationServiceImpl classificationServiceImpl = (ClassificationServiceImpl) te.getClassificationService();
|
||||
|
||||
Workbasket workbasket = workbasketService.newWorkbasket("K99", "novatec");
|
||||
Workbasket workbasket = workbasketService.newWorkbasket("K99", "DOMAIN_A");
|
||||
workbasket.setName("workbasket");
|
||||
|
||||
workbasket.setName("workbasket99");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket = workBasketServiceImpl.createWorkbasket(workbasket);
|
||||
Classification classification = classificationService.newClassification("TEST", "novatec", "t1");
|
||||
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "t1");
|
||||
classification = classificationServiceImpl.createClassification(classification);
|
||||
|
||||
Task task = taskServiceImpl.newTask(workbasket.getId());
|
||||
|
@ -207,80 +205,12 @@ public class TaskServiceImplIntExplicitTest {
|
|||
te.setConnection(null);
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testCreateTaskWithPlannedAndName() throws SQLException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
|
||||
WorkbasketAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
generateSampleAccessItems();
|
||||
|
||||
Classification classification = classificationService.newClassification("TEST1", "novatec", "t1");
|
||||
classification.setCategory("MANUAL");
|
||||
classification.setName("classification name");
|
||||
classification.setServiceLevel("P1D");
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
ObjectReference objectReference = new ObjectReference();
|
||||
objectReference.setCompany("Novatec");
|
||||
objectReference.setSystem("System");
|
||||
objectReference.setSystemInstance("2");
|
||||
objectReference.setValue("4444");
|
||||
objectReference.setType("type");
|
||||
|
||||
Instant tomorrow = Instant.now().plus(Duration.ofDays(1L));
|
||||
|
||||
Workbasket wb = workbasketService.newWorkbasket("k1", "novatec");
|
||||
wb.setType(WorkbasketType.PERSONAL);
|
||||
wb.setName("aName");
|
||||
|
||||
wb = workbasketService.createWorkbasket(wb);
|
||||
|
||||
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem(wb.getId(), "Elena");
|
||||
accessItem.setPermAppend(true);
|
||||
accessItem.setPermRead(true);
|
||||
accessItem.setPermOpen(true);
|
||||
workbasketService.createWorkbasketAccessItem(accessItem);
|
||||
|
||||
Task test = taskServiceImpl.newTask(wb.getId());
|
||||
test.setPrimaryObjRef(objectReference);
|
||||
test.setPlanned(tomorrow);
|
||||
test.setClassificationKey(classification.getKey());
|
||||
test = taskServiceImpl.createTask(test);
|
||||
|
||||
Task task = this.generateDummyTask();
|
||||
task.setClassificationKey(classification.getKey());
|
||||
task.setName("Name");
|
||||
task.setPrimaryObjRef(objectReference);
|
||||
task.setPlanned(tomorrow);
|
||||
Task resultTask = taskServiceImpl.createTask(task);
|
||||
Assert.assertNotEquals(resultTask.getPlanned(), resultTask.getCreated());
|
||||
Assert.assertNotNull(resultTask.getDue());
|
||||
|
||||
Task task2 = taskServiceImpl.newTask(task.getWorkbasketSummary().getId());
|
||||
task2.setClassificationKey(classification.getKey());
|
||||
task2.setPrimaryObjRef(objectReference);
|
||||
task2.setDescription("desc");
|
||||
Task resultTask2 = taskServiceImpl.createTask(task2);
|
||||
|
||||
Assert.assertEquals(resultTask2.getPlanned(), resultTask2.getCreated());
|
||||
Assert.assertTrue(resultTask2.getName().equals(classification.getName()));
|
||||
|
||||
Assert.assertEquals(resultTask.getClassificationSummary().getId(),
|
||||
resultTask2.getClassificationSummary().getId());
|
||||
Assert.assertTrue(resultTask.getDue().isAfter(resultTask2.getDue()));
|
||||
Assert.assertFalse(resultTask.getName().equals(resultTask2.getName()));
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void createTaskShouldThrowWorkbasketNotFoundException()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException,
|
||||
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException {
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
|
@ -296,13 +226,13 @@ public class TaskServiceImplIntExplicitTest {
|
|||
public void createManualTaskShouldThrowClassificationNotFoundException()
|
||||
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException, SQLException,
|
||||
ClassificationAlreadyExistException, TaskAlreadyExistException, InvalidWorkbasketException,
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException {
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
generateSampleAccessItems();
|
||||
|
||||
Workbasket wb = workbasketService.newWorkbasket("WB NR.1", "nova");
|
||||
Workbasket wb = workbasketService.newWorkbasket("WB NR.1", "DOMAIN_A");
|
||||
wb.setName("dummy-WB");
|
||||
wb.setType(WorkbasketType.PERSONAL);
|
||||
wb = workbasketService.createWorkbasket(wb);
|
||||
|
@ -324,15 +254,15 @@ public class TaskServiceImplIntExplicitTest {
|
|||
public void should_ReturnList_when_BuilderIsUsed() throws SQLException, NotAuthorizedException,
|
||||
WorkbasketNotFoundException, ClassificationNotFoundException, ClassificationAlreadyExistException,
|
||||
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, SystemException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
generateSampleAccessItems();
|
||||
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "novatec");
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("k1", "DOMAIN_A");
|
||||
workbasket.setName("workbasket");
|
||||
Classification classification = classificationService.newClassification("TEST", "novatec", "t1");
|
||||
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "t1");
|
||||
classificationService.createClassification(classification);
|
||||
workbasket.setId("1"); // set id manually for authorization tests
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
|
@ -349,7 +279,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
.descriptionLike("test")
|
||||
.priorityIn(1, 2, 2)
|
||||
.stateIn(TaskState.CLAIMED)
|
||||
.workbasketKeyDomainIn(new KeyDomain("k1", "novatec"))
|
||||
.workbasketKeyDomainIn(new KeyDomain("k1", "DOMAIN_A"))
|
||||
.ownerIn("test", "test2", "bla")
|
||||
.customAttributeLike("13", "test")
|
||||
.classificationKeyIn("pId1", "pId2")
|
||||
|
@ -369,7 +299,8 @@ public class TaskServiceImplIntExplicitTest {
|
|||
public void shouldTransferTaskToOtherWorkbasket()
|
||||
throws WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException,
|
||||
ClassificationAlreadyExistException, TaskNotFoundException, InterruptedException, TaskAlreadyExistException,
|
||||
SQLException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException {
|
||||
SQLException, InvalidWorkbasketException, InvalidArgumentException, WorkbasketAlreadyExistException,
|
||||
DomainNotFoundException {
|
||||
Workbasket sourceWB;
|
||||
Workbasket destinationWB;
|
||||
WorkbasketImpl wb;
|
||||
|
@ -382,7 +313,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
taskanaEngineImpl.setConnection(connection);
|
||||
|
||||
// Source Workbasket
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket("sourceWbKey", "domain");
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket("sourceWbKey", "DOMAIN_A");
|
||||
wb.setName("Basic-Workbasket");
|
||||
wb.setDescription("Just used as base WB for Task here");
|
||||
wb.setOwner(user);
|
||||
|
@ -393,7 +324,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
createWorkbasketWithSecurity(sourceWB, sourceWB.getOwner(), true, true, true, true);
|
||||
|
||||
// Destination Workbasket
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket("wb2Key", "domain");
|
||||
wb = (WorkbasketImpl) workbasketService.newWorkbasket("wb2Key", "DOMAIN_A");
|
||||
wb.setName("Desination-WorkBasket");
|
||||
wb.setDescription("Destination WB where Task should be transfered to");
|
||||
wb.setOwner(user);
|
||||
|
@ -403,7 +334,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
createWorkbasketWithSecurity(destinationWB, destinationWB.getOwner(), false, true, true, true);
|
||||
|
||||
// Classification required for Task
|
||||
classification = (ClassificationImpl) classificationService.newClassification("KEY", "domain", "t1");
|
||||
classification = (ClassificationImpl) classificationService.newClassification("KEY", "DOMAIN_A", "t1");
|
||||
classification.setCategory("Test Classification");
|
||||
classification.setName("Transfert-Task Classification");
|
||||
classificationService.createClassification(classification);
|
||||
|
@ -447,7 +378,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
public void shouldNotTransferByFailingSecurity() throws WorkbasketNotFoundException,
|
||||
ClassificationNotFoundException, NotAuthorizedException, ClassificationAlreadyExistException, SQLException,
|
||||
TaskNotFoundException, TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
final String user = "User";
|
||||
|
||||
// Set up Security for this Test
|
||||
|
@ -461,12 +392,12 @@ public class TaskServiceImplIntExplicitTest {
|
|||
workbasketService = taskanaEngine.getWorkbasketService();
|
||||
|
||||
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification(
|
||||
"KEY", "test-domain", "t1");
|
||||
"KEY", "DOMAIN_A", "t1");
|
||||
classification.setCategory("Test Classification");
|
||||
classification.setName("Transfert-Task Classification");
|
||||
classificationService.createClassification(classification);
|
||||
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("wbKey1", "test-domain");
|
||||
WorkbasketImpl wb = (WorkbasketImpl) workbasketService.newWorkbasket("wbKey1", "DOMAIN_A");
|
||||
wb.setName("BASE WB");
|
||||
wb.setDescription("Normal base WB");
|
||||
wb.setOwner(user);
|
||||
|
@ -474,7 +405,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
wb = (WorkbasketImpl) workbasketService.createWorkbasket(wb);
|
||||
createWorkbasketWithSecurity(wb, wb.getOwner(), true, true, true, true);
|
||||
|
||||
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoAppend", "anotherDomain");
|
||||
WorkbasketImpl wbNoAppend = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoAppend", "DOMAIN_B");
|
||||
wbNoAppend.setName("Test-Security-WorkBasket-APPEND");
|
||||
wbNoAppend.setDescription("Workbasket without permission APPEND on Task");
|
||||
wbNoAppend.setOwner(user);
|
||||
|
@ -483,7 +414,7 @@ public class TaskServiceImplIntExplicitTest {
|
|||
wbNoAppend = (WorkbasketImpl) workbasketService.createWorkbasket(wbNoAppend);
|
||||
createWorkbasketWithSecurity(wbNoAppend, wbNoAppend.getOwner(), true, true, false, true);
|
||||
|
||||
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoTransfer", "test-domain");
|
||||
WorkbasketImpl wbNoTransfer = (WorkbasketImpl) workbasketService.newWorkbasket("keyNoTransfer", "DOMAIN_A");
|
||||
wbNoTransfer.setName("Test-Security-WorkBasket-TRANSFER");
|
||||
wbNoTransfer.setDescription("Workbasket without permission TRANSFER on Task");
|
||||
wbNoTransfer.setOwner(user);
|
||||
|
@ -531,14 +462,14 @@ public class TaskServiceImplIntExplicitTest {
|
|||
|
||||
private Task generateDummyTask() throws ClassificationAlreadyExistException, ClassificationNotFoundException,
|
||||
WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("wb", "novatec");
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket("wb", "DOMAIN_A");
|
||||
workbasket.setName("wb");
|
||||
workbasket.setId("1"); // set id manually for authorization tests
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(workbasket);
|
||||
|
||||
Classification classification = classificationService.newClassification("TEST", "novatec", "t1");
|
||||
Classification classification = classificationService.newClassification("TEST", "DOMAIN_A", "t1");
|
||||
taskanaEngine.getClassificationService().createClassification(classification);
|
||||
|
||||
Task task = taskServiceImpl.newTask(workbasket.getId());
|
||||
|
|
|
@ -34,7 +34,6 @@ import pro.taskana.configuration.TaskanaEngineConfiguration;
|
|||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
import pro.taskana.impl.TaskanaEngineProxyForTest;
|
||||
|
@ -43,7 +42,6 @@ import pro.taskana.impl.configuration.DBCleaner;
|
|||
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
|
||||
import pro.taskana.impl.util.IdGenerator;
|
||||
import pro.taskana.mappings.WorkbasketMapper;
|
||||
import pro.taskana.security.CurrentUserContext;
|
||||
import pro.taskana.security.JAASRunner;
|
||||
import pro.taskana.security.WithAccessId;
|
||||
|
||||
|
@ -85,67 +83,27 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
now = Instant.now();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testSelectWorkbasket()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException {
|
||||
String id = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket = createTestWorkbasket(id, "key0", "novatec", "Superbasket", WorkbasketType.GROUP);
|
||||
workbasket = workBasketService.createWorkbasket(workbasket);
|
||||
createWorkbasketWithSecurity(workbasket, CurrentUserContext.getUserid(), true, true, false, false);
|
||||
Workbasket foundWorkbasket = workBasketService.getWorkbasket(id);
|
||||
Assert.assertEquals(id, foundWorkbasket.getId());
|
||||
}
|
||||
|
||||
@Test(expected = WorkbasketNotFoundException.class)
|
||||
public void testGetWorkbasketFail()
|
||||
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException {
|
||||
workBasketService.getWorkbasket("fail");
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testSelectWorkbasketWithDistribution()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, InvalidWorkbasketException,
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException {
|
||||
String id = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket wbDist1 = createTestWorkbasket(id, "key0", "novatec", "Superbasket", WorkbasketType.GROUP);
|
||||
wbDist1 = workBasketService.createWorkbasket(wbDist1);
|
||||
createWorkbasketWithSecurity(wbDist1, CurrentUserContext.getUserid(), true, true, false, false);
|
||||
|
||||
id = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket wbDist2 = createTestWorkbasket(id, "key1", "novatec", "Megabasket", WorkbasketType.GROUP);
|
||||
wbDist2 = workBasketService.createWorkbasket(wbDist2);
|
||||
createWorkbasketWithSecurity(wbDist2, "Elena", true, true, false, false);
|
||||
id = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket = createTestWorkbasket(id, "key2", "novatec", "Hyperbasket", WorkbasketType.GROUP);
|
||||
workbasket = workBasketService.createWorkbasket(workbasket);
|
||||
List<String> distributionTargets = new ArrayList<>(Arrays.asList(wbDist1.getId(), wbDist2.getId()));
|
||||
createWorkbasketWithSecurity(workbasket, "Elena", true, true, false, false);
|
||||
workBasketService.setDistributionTargets(workbasket.getId(), distributionTargets);
|
||||
|
||||
Workbasket foundWorkbasket = workBasketService.getWorkbasket(workbasket.getId());
|
||||
Assert.assertEquals(id, foundWorkbasket.getId());
|
||||
Assert.assertEquals(2, workBasketService.getDistributionTargets(foundWorkbasket.getId()).size());
|
||||
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testUpdateWorkbasket() throws Exception {
|
||||
String id0 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket0 = createTestWorkbasket(id0, "key0", "novatec", "Superbasket", WorkbasketType.GROUP);
|
||||
Workbasket workbasket0 = createTestWorkbasket(id0, "key0", "DOMAIN_A", "Superbasket", WorkbasketType.GROUP);
|
||||
workbasket0 = workBasketService.createWorkbasket(workbasket0);
|
||||
createWorkbasketWithSecurity(workbasket0, "Elena", true, true, false, false);
|
||||
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket1 = createTestWorkbasket(id1, "key1", "novatec", "Megabasket", WorkbasketType.GROUP);
|
||||
Workbasket workbasket1 = createTestWorkbasket(id1, "key1", "DOMAIN_A", "Megabasket", WorkbasketType.GROUP);
|
||||
workbasket1 = workBasketService.createWorkbasket(workbasket1);
|
||||
createWorkbasketWithSecurity(workbasket1, "Elena", true, true, false, false);
|
||||
|
||||
String id2 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket2 = createTestWorkbasket(id2, "key2", "novatec", "Hyperbasket", WorkbasketType.GROUP);
|
||||
Workbasket workbasket2 = createTestWorkbasket(id2, "key2", "DOMAIN_A", "Hyperbasket", WorkbasketType.GROUP);
|
||||
workbasket2 = workBasketService.createWorkbasket(workbasket2);
|
||||
createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false);
|
||||
List<String> distTargets = new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId()));
|
||||
|
@ -153,7 +111,7 @@ public class WorkbasketServiceImplIntAutocommitTest {
|
|||
workBasketService.setDistributionTargets(workbasket2.getId(), distTargets);
|
||||
|
||||
String id3 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket3 = createTestWorkbasket(id3, "key3", "novatec", "hm ... irgend ein basket",
|
||||
Workbasket workbasket3 = createTestWorkbasket(id3, "key3", "DOMAIN_A", "hm ... irgend ein basket",
|
||||
WorkbasketType.GROUP);
|
||||
workbasket3 = workBasketService.createWorkbasket(workbasket3);
|
||||
createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false);
|
||||
|
|
|
@ -26,10 +26,7 @@ import pro.taskana.WorkbasketSummary;
|
|||
import pro.taskana.WorkbasketType;
|
||||
import pro.taskana.configuration.TaskanaEngineConfiguration;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
|
||||
import pro.taskana.exceptions.WorkbasketNotFoundException;
|
||||
import pro.taskana.impl.TaskanaEngineImpl;
|
||||
import pro.taskana.impl.WorkbasketImpl;
|
||||
import pro.taskana.impl.configuration.DBCleaner;
|
||||
|
@ -72,77 +69,6 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
cleaner.clearDb(dataSource, false);
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testSelectWorkbasket()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, InvalidWorkbasketException,
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
workBasketService = taskanaEngine.getWorkbasketService();
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workBasketService.newWorkbasket("key0", "novatec");
|
||||
String id0 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket.setId(id0);
|
||||
workbasket.setName("Superbasket");
|
||||
workbasket.setType(WorkbasketType.GROUP);
|
||||
workbasket = (WorkbasketImpl) workBasketService.createWorkbasket(workbasket);
|
||||
|
||||
createWorkbasketWithSecurity(workbasket, "Elena", true, true, true, true);
|
||||
connection.commit();
|
||||
workbasket = (WorkbasketImpl) workBasketService.getWorkbasket(workbasket.getId());
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena")
|
||||
@Test(expected = NotAuthorizedException.class)
|
||||
public void testGetWorkbasketFail()
|
||||
throws WorkbasketNotFoundException, SQLException, InvalidWorkbasketException, NotAuthorizedException,
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
workBasketService = taskanaEngine.getWorkbasketService();
|
||||
|
||||
Workbasket wb = createTestWorkbasket("ID-1", "KEY-1", "DOMAIN", "Name-1", WorkbasketType.PERSONAL);
|
||||
wb = workBasketService.createWorkbasket(wb);
|
||||
createWorkbasketWithSecurity(wb, "Elena", false, false, false, false);
|
||||
|
||||
workBasketService.getWorkbasket(wb.getId());
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testSelectWorkbasketWithDistribution()
|
||||
throws WorkbasketNotFoundException, NotAuthorizedException, SQLException, InvalidWorkbasketException,
|
||||
InvalidArgumentException, WorkbasketAlreadyExistException {
|
||||
Connection connection = dataSource.getConnection();
|
||||
taskanaEngineImpl.setConnection(connection);
|
||||
workBasketService = taskanaEngine.getWorkbasketService();
|
||||
|
||||
String id0 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket0 = createTestWorkbasket(id0, "key0", "novatec", "Superbasket", WorkbasketType.GROUP);
|
||||
workbasket0 = workBasketService.createWorkbasket(workbasket0);
|
||||
createWorkbasketWithSecurity(workbasket0, "Elena", true, true, false, false);
|
||||
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket1 = createTestWorkbasket(id1, "key1", "novatec", "Megabasket", WorkbasketType.GROUP);
|
||||
workbasket1 = workBasketService.createWorkbasket(workbasket1);
|
||||
createWorkbasketWithSecurity(workbasket1, "Elena", true, true, false, false);
|
||||
|
||||
String id2 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket2 = createTestWorkbasket(id2, "key2", "novatec", "Hyperbasket", WorkbasketType.GROUP);
|
||||
workbasket2 = workBasketService.createWorkbasket(workbasket2);
|
||||
createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false);
|
||||
|
||||
List<String> distributionTargets = new ArrayList<>(Arrays.asList(workbasket0.getId(), workbasket1.getId()));
|
||||
workBasketService.setDistributionTargets(workbasket2.getId(), distributionTargets);
|
||||
|
||||
Workbasket foundWorkbasket = workBasketService.getWorkbasket(id2);
|
||||
Assert.assertEquals(id2, foundWorkbasket.getId());
|
||||
Assert.assertEquals(2, workBasketService.getDistributionTargets(foundWorkbasket.getId()).size());
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
@WithAccessId(userName = "Elena", groupNames = {"businessadmin"})
|
||||
@Test
|
||||
public void testUpdateWorkbasket() throws Exception {
|
||||
|
@ -150,17 +76,17 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
taskanaEngineImpl.setConnection(connection);
|
||||
workBasketService = taskanaEngine.getWorkbasketService();
|
||||
String id0 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket0 = createTestWorkbasket(id0, "key0", "novatec", "Superbasket", WorkbasketType.GROUP);
|
||||
Workbasket workbasket0 = createTestWorkbasket(id0, "key0", "DOMAIN_A", "Superbasket", WorkbasketType.GROUP);
|
||||
workbasket0 = workBasketService.createWorkbasket(workbasket0);
|
||||
createWorkbasketWithSecurity(workbasket0, "Elena", true, true, false, false);
|
||||
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket1 = createTestWorkbasket(id1, "key1", "novatec", "Megabasket", WorkbasketType.GROUP);
|
||||
Workbasket workbasket1 = createTestWorkbasket(id1, "key1", "DOMAIN_A", "Megabasket", WorkbasketType.GROUP);
|
||||
workbasket1 = workBasketService.createWorkbasket(workbasket1);
|
||||
createWorkbasketWithSecurity(workbasket1, "Elena", true, true, false, false);
|
||||
|
||||
String id2 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket2 = createTestWorkbasket(id2, "key2", "novatec", "Hyperbasket", WorkbasketType.GROUP);
|
||||
Workbasket workbasket2 = createTestWorkbasket(id2, "key2", "DOMAIN_A", "Hyperbasket", WorkbasketType.GROUP);
|
||||
workbasket2 = workBasketService.createWorkbasket(workbasket2);
|
||||
createWorkbasketWithSecurity(workbasket2, "Elena", true, true, false, false);
|
||||
|
||||
|
@ -169,7 +95,7 @@ public class WorkbasketServiceImplIntExplicitTest {
|
|||
workBasketService.setDistributionTargets(workbasket2.getId(), distTargets);
|
||||
|
||||
String id3 = IdGenerator.generateWithPrefix("TWB");
|
||||
Workbasket workbasket3 = createTestWorkbasket(id3, "key3", "novatec", "hm ... irgend ein basket",
|
||||
Workbasket workbasket3 = createTestWorkbasket(id3, "key3", "DOMAIN_A", "hm ... irgend ein basket",
|
||||
WorkbasketType.GROUP);
|
||||
workbasket3 = workBasketService.createWorkbasket(workbasket3);
|
||||
createWorkbasketWithSecurity(workbasket3, "Elena", true, true, false, false);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
taskana.roles.user = group1 | group2|teamlead_1 | teamlead_2 |user_1_1| user_1_1| user_1_2| user_2_1| user_2_2| max|elena|simone
|
||||
taskana.roles.Admin=name=konrad,Organisation=novatec|admin
|
||||
taskana.roles.businessadmin=max|Moritz|businessadmin
|
||||
|
||||
taskana.domains= Domain_A , DOMAIN_B
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import pro.taskana.TaskanaEngine;
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketType;
|
||||
import pro.taskana.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
|
||||
|
@ -54,7 +55,7 @@ public class TaskanaTestController {
|
|||
@RequestMapping("/transaction")
|
||||
public @ResponseBody String transaction(@RequestParam(value = "rollback", defaultValue = "false") String rollback)
|
||||
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key", "workbasket"));
|
||||
|
||||
int workbaskets = getWorkbaskets();
|
||||
|
@ -70,7 +71,7 @@ public class TaskanaTestController {
|
|||
public @ResponseBody String transactionMany(
|
||||
@RequestParam(value = "rollback", defaultValue = "false") String rollback)
|
||||
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key1", "workbasket1"));
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key2", "workbasket2"));
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key3", "workbasket3"));
|
||||
|
@ -87,7 +88,7 @@ public class TaskanaTestController {
|
|||
public @ResponseBody String transactionGeschbuch(
|
||||
@RequestParam(value = "rollback", defaultValue = "false") String rollback)
|
||||
throws WorkbasketNotFoundException, InvalidWorkbasketException, NotAuthorizedException,
|
||||
WorkbasketAlreadyExistException {
|
||||
WorkbasketAlreadyExistException, DomainNotFoundException {
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key1", "workbasket1"));
|
||||
taskanaEngine.getWorkbasketService().createWorkbasket(createWorkBasket("key2", "workbasket2"));
|
||||
|
||||
|
@ -121,7 +122,7 @@ public class TaskanaTestController {
|
|||
|
||||
private Workbasket createWorkBasket(String key, String name) throws NotAuthorizedException {
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) taskanaEngine.getWorkbasketService().newWorkbasket(key,
|
||||
"generali");
|
||||
"DOMAIN_A");
|
||||
String id1 = IdGenerator.generateWithPrefix("TWB");
|
||||
workbasket.setId(id1);
|
||||
workbasket.setName(name);
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
taskana.roles.user = group1 | group2|teamlead_1 | teamlead_2 |user_1_1| user_1_1| user_1_2| user_2_1| user_2_2| max|elena|simone
|
||||
taskana.roles.Admin=name=konrad,Organisation=novatec|admin
|
||||
taskana.roles.businessadmin=max|Moritz|businessadmin
|
||||
|
||||
taskana.domains= Domain_A , DOMAIN_B
|
|
@ -12,6 +12,7 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExcep
|
|||
import pro.taskana.exceptions.ClassificationAlreadyExistException;
|
||||
import pro.taskana.exceptions.ClassificationNotFoundException;
|
||||
import pro.taskana.exceptions.ConcurrencyException;
|
||||
import pro.taskana.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidOwnerException;
|
||||
import pro.taskana.exceptions.InvalidStateException;
|
||||
|
@ -106,6 +107,11 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
|
|||
return buildResponse(ex, req, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(DomainNotFoundException.class)
|
||||
protected ResponseEntity<Object> handleDomainNotFound(DomainNotFoundException ex, WebRequest req) {
|
||||
return buildResponse(ex, req, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
private ResponseEntity<Object> buildResponse(Exception ex, WebRequest req, HttpStatus status) {
|
||||
TaskanaErrorData errorData = new TaskanaErrorData(status, ex, req);
|
||||
return new ResponseEntity<>(errorData, status);
|
||||
|
|
|
@ -31,6 +31,7 @@ import pro.taskana.WorkbasketQuery;
|
|||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.WorkbasketSummary;
|
||||
import pro.taskana.WorkbasketType;
|
||||
import pro.taskana.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
|
@ -145,7 +146,7 @@ public class WorkbasketController {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseEntity<WorkbasketResource> createWorkbasket(@RequestBody WorkbasketResource workbasketResource)
|
||||
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,
|
||||
WorkbasketNotFoundException {
|
||||
WorkbasketNotFoundException, DomainNotFoundException {
|
||||
Workbasket workbasket = workbasketMapper.toModel(workbasketResource);
|
||||
workbasket = workbasketService.createWorkbasket(workbasket);
|
||||
return new ResponseEntity<>(workbasketMapper.toResource(workbasket), HttpStatus.CREATED);
|
||||
|
|
|
@ -23,6 +23,7 @@ import pro.taskana.Workbasket;
|
|||
import pro.taskana.WorkbasketQuery;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.WorkbasketSummary;
|
||||
import pro.taskana.exceptions.DomainNotFoundException;
|
||||
import pro.taskana.exceptions.InvalidArgumentException;
|
||||
import pro.taskana.exceptions.InvalidWorkbasketException;
|
||||
import pro.taskana.exceptions.NotAuthorizedException;
|
||||
|
@ -159,6 +160,9 @@ public class WorkbasketDefinitionController {
|
|||
} catch (WorkbasketAlreadyExistException e) {
|
||||
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
|
||||
return new ResponseEntity<>(HttpStatus.CONFLICT);
|
||||
} catch (DomainNotFoundException e) {
|
||||
TransactionInterceptor.currentTransactionStatus().setRollbackOnly();
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue