forked from Taskana/taskana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
671 additions
and
216 deletions.
There are no files selected for viewing
194 changes: 97 additions & 97 deletions
194
common/taskana-common-data/src/main/resources/sql/sample-data/task.sql
Large diffs are not rendered by default.
Oops, something went wrong.
214 changes: 107 additions & 107 deletions
214
common/taskana-common-data/src/main/resources/sql/test-data/task.sql
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...on/taskana-common/src/main/resources/sql/db2/taskana_schema_update_7.0.0_to_7.2.0_db2.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- this script updates the TASKANA database schema from version 7.0.0 to version 7.2.0. | ||
SET SCHEMA %schemaName%; | ||
|
||
INSERT INTO TASKANA_SCHEMA_VERSION (ID, VERSION, CREATED) | ||
VALUES (TASKANA_SCHEMA_VERSION_ID_SEQ.NEXTVAL, '7.2.0', CURRENT_TIMESTAMP); | ||
|
||
ALTER TABLE TASK | ||
ADD COLUMN LOCK_EXPIRE TIMESTAMP NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
common/taskana-common/src/main/resources/sql/h2/taskana_schema_update_7.0.0_to_7.2.0_h2.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- this script updates the TASKANA database schema from version 7.0.0 to version 7.2.0. | ||
SET SCHEMA %schemaName%; | ||
|
||
INSERT INTO TASKANA_SCHEMA_VERSION (ID, VERSION, CREATED) | ||
VALUES (nextval('TASKANA_SCHEMA_VERSION_ID_SEQ'), '7.2.0', CURRENT_TIMESTAMP); | ||
|
||
ALTER TABLE TASK | ||
ADD ( | ||
`LOCK_EXPIRE` TIMESTAMP NULL | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...kana-common/src/main/resources/sql/oracle/taskana_schema_update_7.0.0_to_7.2.0_oracle.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- this script updates the TASKANA database schema from version 7.0.0 to version 7.2.0. | ||
ALTER | ||
SESSION SET CURRENT_SCHEMA = %schemaName%; | ||
|
||
INSERT INTO TASKANA_SCHEMA_VERSION (ID, VERSION, CREATED) | ||
VALUES (TASKANA_SCHEMA_VERSION_ID_SEQ.NEXTVAL, '7.2.0', CURRENT_TIMESTAMP); | ||
|
||
ALTER TABLE TASK | ||
ADD LOCK_EXPIRE TIMESTAMP NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...-common/src/main/resources/sql/postgres/taskana_schema_update_7.0.0_to_7.2.0_postgres.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- this script updates the TASKANA database schema from version 7.0.0 to version 7.2.0. | ||
|
||
SET search_path = %schemaName%; | ||
|
||
INSERT INTO TASKANA_SCHEMA_VERSION (ID, VERSION, CREATED) | ||
VALUES (nextval('TASKANA_SCHEMA_VERSION_ID_SEQ'), '7.2.0', CURRENT_TIMESTAMP); | ||
|
||
ALTER TABLE TASK | ||
ADD COLUMN LOCK_EXPIRE TIMESTAMP NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
163 changes: 163 additions & 0 deletions
163
lib/taskana-core-test/src/test/java/acceptance/task/lock/LockTaskAccTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
package acceptance.task.lock; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static pro.taskana.testapi.DefaultTestEntities.defaultTestClassification; | ||
import static pro.taskana.testapi.DefaultTestEntities.defaultTestObjectReference; | ||
import static pro.taskana.testapi.DefaultTestEntities.defaultTestWorkbasket; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import pro.taskana.classification.api.ClassificationService; | ||
import pro.taskana.classification.api.models.ClassificationSummary; | ||
import pro.taskana.task.api.TaskService; | ||
import pro.taskana.task.api.models.ObjectReference; | ||
import pro.taskana.task.api.models.Task; | ||
import pro.taskana.task.api.models.TaskSummary; | ||
import pro.taskana.testapi.TaskanaInject; | ||
import pro.taskana.testapi.TaskanaIntegrationTest; | ||
import pro.taskana.testapi.builder.TaskBuilder; | ||
import pro.taskana.testapi.builder.UserBuilder; | ||
import pro.taskana.testapi.builder.WorkbasketAccessItemBuilder; | ||
import pro.taskana.testapi.security.WithAccessId; | ||
import pro.taskana.user.api.UserService; | ||
import pro.taskana.workbasket.api.WorkbasketPermission; | ||
import pro.taskana.workbasket.api.WorkbasketService; | ||
import pro.taskana.workbasket.api.models.WorkbasketSummary; | ||
|
||
@TaskanaIntegrationTest | ||
class LockTaskAccTest { | ||
@TaskanaInject TaskService taskService; | ||
@TaskanaInject ClassificationService classificationService; | ||
@TaskanaInject WorkbasketService workbasketService; | ||
@TaskanaInject UserService userService; | ||
|
||
ClassificationSummary defaultClassificationSummary; | ||
WorkbasketSummary defaultWorkbasketSummary; | ||
ObjectReference defaultObjectReference; | ||
|
||
@WithAccessId(user = "admin") | ||
@BeforeAll | ||
void setup() throws Exception { | ||
defaultClassificationSummary = | ||
defaultTestClassification().buildAndStoreAsSummary(classificationService); | ||
defaultWorkbasketSummary = defaultTestWorkbasket().buildAndStoreAsSummary(workbasketService); | ||
|
||
WorkbasketAccessItemBuilder.newWorkbasketAccessItem() | ||
.workbasketId(defaultWorkbasketSummary.getId()) | ||
.accessId("user-1-2") | ||
.permission(WorkbasketPermission.OPEN) | ||
.permission(WorkbasketPermission.READ) | ||
.permission(WorkbasketPermission.READTASKS) | ||
.permission(WorkbasketPermission.EDITTASKS) | ||
.permission(WorkbasketPermission.APPEND) | ||
.buildAndStore(workbasketService); | ||
|
||
defaultObjectReference = defaultTestObjectReference().build(); | ||
|
||
UserBuilder.newUser() | ||
.id("user-1-2") | ||
.firstName("Max") | ||
.lastName("Mustermann") | ||
.longName("Long name of user-1-2") | ||
.buildAndStore(userService); | ||
} | ||
|
||
@WithAccessId(user = "admin") | ||
@Test | ||
void should_SelectAndLockTasks_When_TasksUnlocked() throws Exception { | ||
Task task1 = | ||
createDefaultTaskWithLock(false).buildAndStore(taskService); | ||
|
||
Task task2 = | ||
createDefaultTaskWithLock(false).buildAndStore(taskService); | ||
|
||
List<String> taskIdsToLock = List.of(task1.getId(), task2.getId()); | ||
|
||
List<String> lockedTaskIds = taskService.selectAndLock(taskIdsToLock); | ||
|
||
assertThat(lockedTaskIds).containsExactlyInAnyOrder(task1.getId(),task2.getId()); | ||
List<TaskSummary> lockedTasks = | ||
taskService | ||
.createTaskQuery() | ||
.idIn(taskIdsToLock.toArray(new String[0])) | ||
.list(); | ||
for (TaskSummary taskSummary : lockedTasks) { | ||
assertThat(taskSummary.isLocked()).isTrue(); | ||
} | ||
} | ||
|
||
@WithAccessId(user = "admin") | ||
@Test | ||
void should_OnlySelectAndLockUnlockedTasks_When_SomeTasksLocked() throws Exception { | ||
Task task1 = | ||
createDefaultTaskWithLock(false).buildAndStore(taskService); | ||
Task task2 = | ||
createDefaultTaskWithLock(true).buildAndStore(taskService); | ||
|
||
List<String> taskIds = List.of(task1.getId(), task2.getId()); | ||
List<String> lockedTaskIds = taskService.selectAndLock(taskIds); | ||
|
||
assertThat(lockedTaskIds).containsExactlyInAnyOrder(task1.getId()); | ||
List<TaskSummary> lockedTasks = | ||
taskService | ||
.createTaskQuery() | ||
.idIn(lockedTaskIds.toArray(new String[0])) | ||
.list(); | ||
for (TaskSummary taskSummary : lockedTasks) { | ||
assertThat(taskSummary.isLocked()).isTrue(); | ||
} | ||
} | ||
|
||
@WithAccessId(user = "admin") | ||
@Test | ||
void should_SelectAndUnlockTasks_When_TasksLocked() throws Exception { | ||
Task task1 = | ||
createDefaultTaskWithLock(true).buildAndStore(taskService); | ||
Task task2 = | ||
createDefaultTaskWithLock(true).buildAndStore(taskService); | ||
|
||
List<String> taskIdsToUnlock = List.of(task1.getId(), task2.getId()); | ||
List<String> unlockedTaskIds = taskService.selectAndUnlock(taskIdsToUnlock); | ||
|
||
assertThat(unlockedTaskIds).containsExactlyInAnyOrder(task1.getId(), task2.getId()); | ||
List<TaskSummary> unlockedTasks = | ||
taskService | ||
.createTaskQuery() | ||
.idIn(taskIdsToUnlock.toArray(new String[0])) | ||
.list(); | ||
for (TaskSummary taskSummary : unlockedTasks) { | ||
assertThat(taskSummary.isLocked()).isFalse(); | ||
} | ||
} | ||
|
||
@WithAccessId(user = "admin") | ||
@Test | ||
void should_OnlySelectAndUnlockLockedTasks_When_SomeTasksUnlocked() throws Exception { | ||
Task task1 = | ||
createDefaultTaskWithLock(false).buildAndStore(taskService); | ||
Task task2 = | ||
createDefaultTaskWithLock(true).buildAndStore(taskService); | ||
|
||
List<String> taskIds = List.of(task1.getId(), task2.getId()); | ||
List<String> lockedTaskIds = taskService.selectAndLock(taskIds); | ||
|
||
assertThat(lockedTaskIds).containsExactlyInAnyOrder(task1.getId()); | ||
List<TaskSummary> lockedTasks = | ||
taskService | ||
.createTaskQuery() | ||
.idIn(lockedTaskIds.toArray(new String[0])) | ||
.list(); | ||
for (TaskSummary taskSummary : lockedTasks) { | ||
assertThat(taskSummary.isLocked()).isTrue(); | ||
} | ||
} | ||
|
||
private TaskBuilder createDefaultTaskWithLock(Boolean locked) { | ||
return TaskBuilder.newTask() | ||
.classificationSummary(defaultClassificationSummary) | ||
.workbasketSummary(defaultWorkbasketSummary) | ||
.primaryObjRef(defaultObjectReference) | ||
.locked(locked); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.