-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TSK-1824: Refactor createTask tests that involve Attachments; Throw exception in REST if taskId of an Attachment is incorrect #1876
Conversation
e926b52
to
c0128e0
Compare
1398726
to
fcd311f
Compare
d7af34b
to
cdf4ed4
Compare
rest/taskana-rest-spring/src/test/java/pro/taskana/task/rest/TaskControllerIntTest.java
Outdated
Show resolved
Hide resolved
rest/taskana-rest-spring/src/main/java/pro/taskana/task/rest/TaskController.java
Show resolved
Hide resolved
lib/taskana-core-test/src/test/java/acceptance/task/create/CreateTaskWithAttachmentAccTest.java
Outdated
Show resolved
Hide resolved
lib/taskana-core-test/src/test/java/acceptance/task/create/CreateTaskWithAttachmentAccTest.java
Outdated
Show resolved
Hide resolved
assertThatThrownBy(() -> taskService.createTask(task)) | ||
.isInstanceOf(InvalidArgumentException.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that the original tests did not verify the message of the IllegalArgumentException, but I am undecided whether we should verify the message of those Exceptions. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will verify the message
lib/taskana-core-test/src/test/java/acceptance/task/create/CreateTaskWithAttachmentAccTest.java
Outdated
Show resolved
Hide resolved
lib/taskana-core-test/src/test/java/acceptance/task/create/CreateTaskWithAttachmentAccTest.java
Show resolved
Hide resolved
@WithAccessId(user = "user-1-1") | ||
@Test | ||
void should_SetTaskIdOfAttachmentCorrectly_WhenCopyingAttachment() throws Exception { | ||
Attachment copiedAttachment = | ||
taskService.getTask(defaultTaskWithAttachment.getId()).getAttachments().get(0).copy(); | ||
Task taskToCreate = taskService.newTask(defaultWorkbasketSummary.getId()); | ||
taskToCreate.setClassificationKey(defaultClassificationSummary.getKey()); | ||
taskToCreate.setPrimaryObjRef(defaultObjectReference); | ||
taskToCreate.addAttachment(copiedAttachment); | ||
Task result = taskService.createTask(taskToCreate); | ||
|
||
assertThat(result.getAttachments().get(0).getTaskId()).isEqualTo(result.getId()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not test TSK-1824 since the copiedAttachment
does not contain a different taskId.
Please don't copy the Attachment. Just reuse the Attachment from the defaultTaskWithAttachment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok :)
@Test | ||
void should_SetTaskIdOfAttachmentCorrectly_WhenCopyingAttachment() throws Exception { | ||
Attachment copiedAttachment = | ||
taskService.getTask(defaultTaskWithAttachment.getId()).getAttachments().get(0).copy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taskService.getTask(defaultTaskWithAttachment.getId()).getAttachments().get(0).copy(); | |
defaultTaskWithAttachment.getAttachments().get(0).copy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok :)
defaultClassificationSummary = | ||
defaultTestClassification() | ||
.serviceLevel("P2D") | ||
.buildAndStoreAsSummary(classificationService); | ||
defaultWorkbasketSummary = defaultTestWorkbasket().buildAndStoreAsSummary(workbasketService); | ||
|
||
WorkbasketAccessItemBuilder.newWorkbasketAccessItem() | ||
.workbasketId(defaultWorkbasketSummary.getId()) | ||
.accessId("user-1-1") | ||
.permission(WorkbasketPermission.OPEN) | ||
.permission(WorkbasketPermission.READ) | ||
.permission(WorkbasketPermission.APPEND) | ||
.buildAndStore(workbasketService); | ||
defaultObjectReference = defaultTestObjectReference().build(); | ||
defaultAttachment = | ||
TaskAttachmentBuilder.newAttachment() | ||
.classificationSummary(defaultClassificationSummary) | ||
.objectReference(defaultObjectReference) | ||
.build(); | ||
defaultTaskWithAttachment = | ||
TaskBuilder.newTask() | ||
.primaryObjRef(defaultObjectReference) | ||
.workbasketSummary(defaultWorkbasketSummary) | ||
.classificationSummary(defaultClassificationSummary) | ||
.attachments(defaultAttachment) | ||
.buildAndStore(taskService, "user-1-1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please be consistent and static import all test-api classes :)
btw: should we make that a guideline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will include this in the guidelines :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about static imports of DefaultTestEntities instead of all test-api classes?
93faaef
to
f7cd50f
Compare
1684202
to
f6a5562
Compare
Closed by #2355 |
https://sonarcloud.io/summary/new_code?id=ryzheboka_taskana&branch=TSK-1824
For the submitter:
Verified by the reviewer: