-
Notifications
You must be signed in to change notification settings - Fork 14
Correcting Logic for archive/unarchive collection process #339
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
Correcting Logic for archive/unarchive collection process #339
Conversation
|
I'd like to see some kind of addition to an existing test that covers this case |
Per our meeting time, I'd like to see a unit test that flexes the execution paths in this case statement. It's OK to adjust the scope. Protected would be OK if your test has the right scope. |
| PublishStatus.Workspace -> { | ||
| dao.status = PublishStatus.Workspace | ||
| } | ||
| else -> {} |
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.
Can this case ever happen? CollectionDao.status is not nullable, and the dao argument is also not nullable.
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.
yeah I just supposed that this was like a default in java case statement, I have heard that it is a good practice to leave not skip the default even if nothing needs to happen there.
| @Autowired | ||
| lateinit var collectionController: CollectionController | ||
|
|
||
| var authentication: Authentication = Mockito.mock(Authentication::class.java) |
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.
In Kotlin, we often use mockk. I can't give you a deep reason why, but there are times/places where Mockito is problematic. I'm not asking for a change here, just please be aware.
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.
Yeah I know, I just replicated a code that I already had before knowing about mockk, and since Mockito was working for the needed here I just used it here.
| author = "newAuthor") | ||
| val collection = collectionRepository.create(name = "name", user = "user", email = "j.chavez@wgu.edu", description = "description") | ||
| collection!!.status = PublishStatus.Archived | ||
| collection!!.archiveDate = LocalDateTime.now() |
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.
IDEA reports that collection!! isn't needed on line 106
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.
Yeah, the assertion is already in line 105, let me remove it.
| description = "newDescription", | ||
| publishStatus = PublishStatus.Unarchived, | ||
| author = "newAuthor") | ||
| val collection = collectionRepository.create(name = "name", user = "user", email = "j.chavez@wgu.edu", description = "description") |
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.
Can we please not use real identities in source code?
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.
Correcting this..
| } | ||
|
|
||
| @Test | ||
| fun `applyStatusChange() should apply Published status`() { |
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 test name does not seem to align with the assertion? Let's straighten this out please?
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.
Correcting
Uh oh!
There was an error while loading. Please reload this page.