use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class QueryTasksAccTest method testQueryForCustom2.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1" })
@Test
public void testQueryForCustom2() throws SQLException, NotAuthorizedException, InvalidArgumentException {
TaskService taskService = taskanaEngine.getTaskService();
List<TaskSummary> results = taskService.createTaskQuery().customAttributeLike("2", "%a%", "%b%", "%c%", "%d%", "%e%", "%f%", "%g%", "%h%", "%i%", "%j%", "%k%", "%l%", "%m%", "%n%", "%o%", "%p%", "%q%", "%r%", "%s%", "%w%").list();
assertThat(results.size(), equalTo(1));
String[] ids = results.stream().map(t -> {
try {
return t.getCustomAttribute("2");
} catch (InvalidArgumentException e) {
e.printStackTrace();
return "";
}
}).collect(Collectors.toList()).toArray(new String[0]);
List<TaskSummary> result2 = taskService.createTaskQuery().customAttributeIn("2", ids).list();
assertThat(result2.size(), equalTo(1));
}
use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class QueryClassificationAccTest method testGetClassificationsForKeyAndCategories.
@Test
public void testGetClassificationsForKeyAndCategories() throws SQLException, ClassificationNotFoundException, NotAuthorizedException, InvalidArgumentException {
ClassificationService classificationService = taskanaEngine.getClassificationService();
List<ClassificationSummary> classifications = classificationService.createClassificationQuery().keyIn("T2100", "L10000").categoryIn("EXTERNAL", "MANUAL").list();
assertNotNull(classifications);
assertEquals(5, classifications.size());
List<ClassificationSummary> externCategory = classifications.stream().filter(c -> c.getCategory().equals("EXTERNAL")).collect(Collectors.toList());
assertEquals(2, externCategory.size());
List<ClassificationSummary> manualCategory = classifications.stream().filter(c -> c.getCategory().equals("MANUAL")).collect(Collectors.toList());
assertEquals(3, manualCategory.size());
}
use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class CreateClassificationAccTest method testCreateClassificationWithInvalidValues.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testCreateClassificationWithInvalidValues() throws ClassificationAlreadyExistException, NotAuthorizedException, ClassificationNotFoundException, DomainNotFoundException, InvalidArgumentException {
long amountOfClassificationsBefore = classificationService.createClassificationQuery().count();
// Check key NULL
try {
Classification classification = classificationService.newClassification(null, "DOMAIN_A", "TASK");
classification = classificationService.createClassification(classification);
} catch (InvalidArgumentException e) {
// nothing to do
}
// Check invalid ServiceLevel
try {
Classification classification = classificationService.newClassification("Key2", "DOMAIN_B", "TASK");
classification.setServiceLevel("abc");
classification = classificationService.createClassification(classification);
} catch (InvalidArgumentException e) {
// nothing to do
}
}
use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class WorkbasketServiceImpl method updateWorkbasketAccessItem.
@Override
public WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem) throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug("entry to updateWorkbasketAccessItem(workbasketAccessItem = {}", workbasketAccessItem);
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
WorkbasketAccessItemImpl accessItem = (WorkbasketAccessItemImpl) workbasketAccessItem;
try {
taskanaEngine.openConnection();
WorkbasketAccessItem originalItem = workbasketAccessMapper.findById(accessItem.getId());
if ((originalItem.getAccessId() != null && !originalItem.getAccessId().equals(accessItem.getAccessId())) || (originalItem.getWorkbasketId() != null && !originalItem.getWorkbasketId().equals(accessItem.getWorkbasketId()))) {
throw new InvalidArgumentException("AccessId and WorkbasketId must not be changed in updateWorkbasketAccessItem calls");
}
workbasketAccessMapper.update(accessItem);
LOGGER.debug("Method updateWorkbasketAccessItem() updated workbasketAccessItem {}", accessItem);
return accessItem;
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from updateWorkbasketAccessItem(workbasketAccessItem). Returning {}", accessItem);
}
}
use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class WorkbasketServiceImpl method setWorkbasketAccessItems.
@Override
public void setWorkbasketAccessItems(String workbasketId, List<WorkbasketAccessItem> wbAccessItems) throws InvalidArgumentException, NotAuthorizedException {
LOGGER.debug("entry to setWorkbasketAccessItems(workbasketAccessItems = {})", wbAccessItems.toString());
taskanaEngine.checkRoleMembership(TaskanaRole.BUSINESS_ADMIN, TaskanaRole.ADMIN);
List<WorkbasketAccessItemImpl> newItems = new ArrayList<>();
try {
taskanaEngine.openConnection();
// Check pre-conditions and set ID
if (!wbAccessItems.isEmpty()) {
for (WorkbasketAccessItem workbasketAccessItem : wbAccessItems) {
WorkbasketAccessItemImpl wbAccessItemImpl = (WorkbasketAccessItemImpl) workbasketAccessItem;
if (wbAccessItemImpl.getWorkbasketId() == null) {
LOGGER.error("setWorkbasketAccessItem failed because WorkbasketAccessItem {} has a null workbasketId. Throwing InvalidArgumentException.", workbasketAccessItem);
throw new InvalidArgumentException("Checking the preconditions of the current WorkbasketAccessItem failed - WBID is NULL. WorkbasketAccessItem=" + workbasketAccessItem.toString());
} else if (!wbAccessItemImpl.getWorkbasketId().equals(workbasketId)) {
LOGGER.error("setWorkbasketAccessItem failed because WorkbasketAccessItem {} does not refer to workbasket {}. Throwing InvalidArgumentException.", workbasketAccessItem, workbasketId);
throw new InvalidArgumentException("Checking the preconditions of the current WorkbasketAccessItem failed - the WBID does not match. Target-WBID='" + workbasketId + "' WorkbasketAccessItem=" + workbasketAccessItem.toString());
}
if (wbAccessItemImpl.getId() == null || wbAccessItemImpl.getId().isEmpty()) {
wbAccessItemImpl.setId(IdGenerator.generateWithPrefix(ID_PREFIX_WORKBASKET_AUTHORIZATION));
}
newItems.add(wbAccessItemImpl);
}
// delete all current ones
workbasketAccessMapper.deleteAllAccessItemsForWorkbasketId(workbasketId);
// add all
newItems.stream().forEach(item -> workbasketAccessMapper.insert(item));
}
} finally {
taskanaEngine.returnConnection();
LOGGER.debug("exit from setWorkbasketAccessItems(workbasketAccessItems = {})", wbAccessItems.toString());
}
}
Aggregations