use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class DaysToWorkingDaysConverterTest method testConvertWorkingDaysToDaysForTasks.
@Test
public void testConvertWorkingDaysToDaysForTasks() {
List<TimeIntervalColumnHeader> reportItems = Collections.singletonList(new TimeIntervalColumnHeader(0));
try {
DaysToWorkingDaysConverter converter = DaysToWorkingDaysConverter.initialize(reportItems, Instant.now());
Instant thursday0201 = Instant.parse("2018-02-01T07:00:00.000Z");
// = thursday
long days = converter.convertWorkingDaysToDays(thursday0201, 0);
assertEquals(0, days);
// fri
days = converter.convertWorkingDaysToDays(thursday0201, 1);
assertEquals(1, days);
// mon
days = converter.convertWorkingDaysToDays(thursday0201, 2);
assertEquals(4, days);
// tues
days = converter.convertWorkingDaysToDays(thursday0201, 3);
assertEquals(5, days);
// we
days = converter.convertWorkingDaysToDays(thursday0201, 4);
assertEquals(6, days);
// thurs
days = converter.convertWorkingDaysToDays(thursday0201, 5);
assertEquals(7, days);
// fri
days = converter.convertWorkingDaysToDays(thursday0201, 6);
assertEquals(8, days);
// mon
days = converter.convertWorkingDaysToDays(thursday0201, 7);
assertEquals(11, days);
// tue
days = converter.convertWorkingDaysToDays(thursday0201, 8);
assertEquals(12, days);
// we
days = converter.convertWorkingDaysToDays(thursday0201, 9);
assertEquals(13, days);
// thu
days = converter.convertWorkingDaysToDays(thursday0201, 10);
assertEquals(14, days);
// fri
days = converter.convertWorkingDaysToDays(thursday0201, 11);
assertEquals(15, days);
Instant gruenDonnerstag2018 = Instant.parse("2018-03-29T01:00:00.000Z");
days = converter.convertWorkingDaysToDays(gruenDonnerstag2018, 0);
assertEquals(0, days);
// Karfreitag
days = converter.convertWorkingDaysToDays(gruenDonnerstag2018, 1);
// osterdienstag
assertEquals(5, days);
// Karfreitag
days = converter.convertWorkingDaysToDays(gruenDonnerstag2018, 2);
// ostermittwoch
assertEquals(6, days);
Instant freitag0427 = Instant.parse("2018-04-27T19:00:00.000Z");
days = converter.convertWorkingDaysToDays(freitag0427, 0);
assertEquals(0, days);
days = converter.convertWorkingDaysToDays(freitag0427, 1);
// 30.4.
assertEquals(3, days);
days = converter.convertWorkingDaysToDays(freitag0427, 2);
// 2.5.
assertEquals(5, days);
} catch (InvalidArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail("");
}
}
use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class UpdateWorkbasketAuthorizationsAccTest method testInsertAccessItemList.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testInsertAccessItemList() throws InvalidArgumentException, NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
final String wbId = "WBI:100000000000000000000000000000000004";
List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems(wbId);
int countBefore = accessItems.size();
// update some values
WorkbasketAccessItem item0 = accessItems.get(0);
item0.setPermAppend(false);
item0.setPermOpen(false);
item0.setPermTransfer(false);
final String updateId0 = item0.getId();
// insert new entry
WorkbasketAccessItem newItem = workbasketService.newWorkbasketAccessItem(wbId, CurrentUserContext.getUserid());
newItem.setPermRead(true);
newItem.setPermOpen(true);
newItem.setPermCustom12(true);
accessItems.add(newItem);
workbasketService.setWorkbasketAccessItems(wbId, accessItems);
List<WorkbasketAccessItem> updatedAccessItems = workbasketService.getWorkbasketAccessItems(wbId);
int countAfter = updatedAccessItems.size();
assertTrue((countBefore + 1) == countAfter);
item0 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId0)).findFirst().get();
assertFalse(item0.isPermAppend());
assertFalse(item0.isPermOpen());
assertFalse(item0.isPermTransfer());
assertFalse(item0.isPermAppend());
assertFalse(item0.isPermTransfer());
}
use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class UpdateWorkbasketAuthorizationsAccTest method testUpdateWorkbasketAccessItemRejected.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testUpdateWorkbasketAccessItemRejected() throws SQLException, NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException, InvalidWorkbasketException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1000000000000000000000000000000000000000", "user1");
accessItem.setPermAppend(true);
accessItem.setPermCustom11(true);
accessItem.setPermRead(true);
accessItem = workbasketService.createWorkbasketAccessItem(accessItem);
accessItem.setPermCustom1(true);
accessItem.setPermAppend(false);
((WorkbasketAccessItemImpl) accessItem).setAccessId("willi");
try {
workbasketService.updateWorkbasketAccessItem(accessItem);
fail("InvalidArgumentException was expected because access id was changed");
} catch (InvalidArgumentException ex) {
// nothing to do
}
((WorkbasketAccessItemImpl) accessItem).setAccessId("user1");
accessItem = workbasketService.updateWorkbasketAccessItem(accessItem);
Assert.assertEquals(false, accessItem.isPermAppend());
Assert.assertEquals(true, accessItem.isPermRead());
Assert.assertEquals(true, accessItem.isPermCustom11());
Assert.assertEquals(true, accessItem.isPermCustom1());
Assert.assertEquals(false, accessItem.isPermCustom2());
((WorkbasketAccessItemImpl) accessItem).setWorkbasketId("2");
try {
workbasketService.updateWorkbasketAccessItem(accessItem);
fail("InvalidArgumentException was expected because key was changed");
} catch (InvalidArgumentException ex) {
// nothing to do
}
}
use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class UpdateWorkbasketAuthorizationsAccTest method testUpdatedAccessItemList.
@WithAccessId(userName = "teamlead_1", groupNames = { "group_1", "businessadmin" })
@Test
public void testUpdatedAccessItemList() throws InvalidArgumentException, NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
final String wbId = "WBI:100000000000000000000000000000000004";
List<WorkbasketAccessItem> accessItems = workbasketService.getWorkbasketAccessItems(wbId);
int countBefore = accessItems.size();
// update some values
WorkbasketAccessItem item0 = accessItems.get(0);
item0.setPermAppend(false);
item0.setPermOpen(false);
item0.setPermTransfer(false);
final String updateId0 = item0.getId();
WorkbasketAccessItem item1 = accessItems.get(1);
item1.setPermAppend(false);
item1.setPermOpen(false);
item1.setPermTransfer(false);
final String updateId1 = item1.getId();
workbasketService.setWorkbasketAccessItems(wbId, accessItems);
List<WorkbasketAccessItem> updatedAccessItems = workbasketService.getWorkbasketAccessItems(wbId);
int countAfter = updatedAccessItems.size();
assertThat(countAfter, equalTo(countBefore));
item0 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId0)).findFirst().get();
assertFalse(item0.isPermAppend());
assertFalse(item0.isPermOpen());
assertFalse(item0.isPermTransfer());
item1 = updatedAccessItems.stream().filter(i -> i.getId().equals(updateId1)).findFirst().get();
assertFalse(item1.isPermAppend());
assertFalse(item1.isPermOpen());
assertFalse(item1.isPermTransfer());
}
use of pro.taskana.exceptions.InvalidArgumentException in project taskana by Taskana.
the class TaskFilter method inspectParams.
public List<TaskSummary> inspectParams(MultiValueMap<String, String> params) throws NotAuthorizedException, InvalidArgumentException {
TaskQuery taskQuery = taskService.createTaskQuery();
// apply filters
if (params.containsKey(NAME)) {
String[] names = extractCommaSeperatedFields(params.get(NAME));
taskQuery.nameIn(names);
}
if (params.containsKey(DESCRIPTION)) {
taskQuery.descriptionLike(params.get(DESCRIPTION).get(0));
}
if (params.containsKey(PRIORITY)) {
String[] prioritesInString = extractCommaSeperatedFields(params.get(PRIORITY));
int[] priorites = extractPriorities(prioritesInString);
taskQuery.priorityIn(priorites);
}
if (params.containsKey(STATE)) {
TaskState[] states = extractStates(params);
taskQuery.stateIn(states);
}
if (params.containsKey(CLASSIFICATION_KEY)) {
String[] classificationKeys = extractCommaSeperatedFields(params.get(CLASSIFICATION_KEY));
taskQuery.classificationKeyIn(classificationKeys);
}
if (params.containsKey(WORKBASKET_ID)) {
String[] workbaskets = extractCommaSeperatedFields(params.get(WORKBASKET_ID));
taskQuery.workbasketIdIn(workbaskets);
}
if (params.containsKey(OWNER)) {
String[] owners = extractCommaSeperatedFields(params.get(OWNER));
taskQuery.ownerIn(owners);
}
// objectReference
if (params.keySet().stream().filter(s -> s.startsWith(POR)).toArray().length > 0) {
if (params.containsKey(POR_COMPANY)) {
String[] companies = extractCommaSeperatedFields(params.get(POR_COMPANY));
taskQuery.primaryObjectReferenceCompanyIn(companies);
}
if (params.containsKey(POR_SYSTEM)) {
String[] systems = extractCommaSeperatedFields(params.get(POR_SYSTEM));
taskQuery.primaryObjectReferenceSystemIn(systems);
}
if (params.containsKey(POR_SYSTEM_INSTANCE)) {
String[] systemInstances = extractCommaSeperatedFields(params.get(POR_SYSTEM_INSTANCE));
taskQuery.primaryObjectReferenceSystemInstanceIn(systemInstances);
}
if (params.containsKey(POR_TYPE)) {
String[] types = extractCommaSeperatedFields(params.get(POR_TYPE));
taskQuery.primaryObjectReferenceTypeIn(types);
}
if (params.containsKey(POR_VALUE)) {
String[] values = extractCommaSeperatedFields(params.get(POR_VALUE));
taskQuery.primaryObjectReferenceValueIn(values);
}
}
if (params.containsKey(IS_READ)) {
taskQuery.readEquals(Boolean.getBoolean(params.get(IS_READ).get(0)));
}
if (params.containsKey(IS_TRANSFERRED)) {
taskQuery.transferredEquals(Boolean.getBoolean(params.get(IS_TRANSFERRED).get(0)));
}
return taskQuery.list();
}
Aggregations