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.
Closes Taskana#2463: Refactor WorkbasketCleanupJobAccTest to use Test…
…-API
- Loading branch information
Showing
3 changed files
with
130 additions
and
157 deletions.
There are no files selected for viewing
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
79 changes: 79 additions & 0 deletions
79
lib/taskana-core-test/src/test/java/acceptance/jobs/WorkbasketCleanupJobAccTest.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,79 @@ | ||
package acceptance.jobs; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
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.common.api.TaskanaEngine; | ||
import pro.taskana.task.api.TaskService; | ||
import pro.taskana.task.api.TaskState; | ||
import pro.taskana.task.api.models.ObjectReference; | ||
import pro.taskana.testapi.DefaultTestEntities; | ||
import pro.taskana.testapi.TaskanaInject; | ||
import pro.taskana.testapi.TaskanaIntegrationTest; | ||
import pro.taskana.testapi.builder.TaskBuilder; | ||
import pro.taskana.testapi.security.WithAccessId; | ||
import pro.taskana.workbasket.api.WorkbasketService; | ||
import pro.taskana.workbasket.api.models.Workbasket; | ||
import pro.taskana.workbasket.api.models.WorkbasketSummary; | ||
import pro.taskana.workbasket.internal.jobs.WorkbasketCleanupJob; | ||
|
||
// All tests are executed as admin, because the jobrunner needs admin rights. | ||
@TaskanaIntegrationTest | ||
class WorkbasketCleanupJobAccTest { | ||
@TaskanaInject TaskService taskService; | ||
@TaskanaInject WorkbasketService workbasketService; | ||
@TaskanaInject ClassificationService classificationService; | ||
@TaskanaInject TaskanaEngine taskanaEngine; | ||
|
||
ClassificationSummary classification; | ||
ObjectReference primaryObjRef; | ||
|
||
@WithAccessId(user = "businessadmin") | ||
@BeforeAll | ||
void setup() throws Exception { | ||
classification = | ||
DefaultTestEntities.defaultTestClassification() | ||
.buildAndStoreAsSummary(classificationService); | ||
primaryObjRef = DefaultTestEntities.defaultTestObjectReference().build(); | ||
} | ||
|
||
@WithAccessId(user = "admin") | ||
@Test | ||
void should_CleanWorkbasketMarkedForDeletion_When_WorkbasketHasNoTasks() throws Exception { | ||
DefaultTestEntities.defaultTestWorkbasket() | ||
.markedForDeletion(true) | ||
.buildAndStore(workbasketService); | ||
List<WorkbasketSummary> wbSummariesOld = workbasketService.createWorkbasketQuery().list(); | ||
assertThat(wbSummariesOld).hasSize(1); | ||
|
||
WorkbasketCleanupJob job = new WorkbasketCleanupJob(taskanaEngine, null, null); | ||
job.run(); | ||
|
||
List<WorkbasketSummary> wbSummaries = workbasketService.createWorkbasketQuery().list(); | ||
assertThat(wbSummaries).isEmpty(); | ||
} | ||
|
||
@WithAccessId(user = "admin") | ||
@Test | ||
void should_NotCleanWorkbasketMarkedForDeletion_When_WorkbasketHasTasks() throws Exception { | ||
Workbasket wb = DefaultTestEntities.defaultTestWorkbasket().buildAndStore(workbasketService); | ||
TaskBuilder.newTask() | ||
.workbasketSummary(wb.asSummary()) | ||
.classificationSummary(classification) | ||
.primaryObjRef(primaryObjRef) | ||
.state(TaskState.COMPLETED) | ||
.buildAndStore(taskService); | ||
|
||
// Workbasket with completed task will be marked for deletion. | ||
workbasketService.deleteWorkbasket(wb.getId()); | ||
WorkbasketCleanupJob job = new WorkbasketCleanupJob(taskanaEngine, null, null); | ||
job.run(); | ||
|
||
List<WorkbasketSummary> wbSummaries = workbasketService.createWorkbasketQuery().list(); | ||
assertThat(wbSummaries).hasSize(1); | ||
} | ||
} |
137 changes: 0 additions & 137 deletions
137
lib/taskana-core/src/test/java/acceptance/jobs/WorkbasketCleanupJobAccTest.java
This file was deleted.
Oops, something went wrong.