Skip to content

Conversation

@jchavez137
Copy link
Contributor

@jchavez137 jchavez137 commented Mar 22, 2023

  • Moved logic for Changing status of a collection
  • Correcting logic for Archiving/Unarchiving collection to return to its previous status
  • Adding logic to properly update dates when changing status of a collection
  • Adding Unit test in CollectionController for status change

@JohnKallies
Copy link
Contributor

I'd like to see some kind of addition to an existing test that covers this case

@JohnKallies
Copy link
Contributor

JohnKallies commented Mar 22, 2023

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.

@JohnKallies JohnKallies added the bug Something isn't working label Mar 22, 2023
PublishStatus.Workspace -> {
dao.status = PublishStatus.Workspace
}
else -> {}
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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()
Copy link
Contributor

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

Copy link
Contributor Author

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")
Copy link
Contributor

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?

Copy link
Contributor Author

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`() {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correcting

@Corpratespaz Corpratespaz merged commit 45c3049 into hotfix/patch-for-workspaces Mar 24, 2023
@Corpratespaz Corpratespaz deleted the hotfix/patch-for-workspaces-osmt-241-archiving branch March 24, 2023 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Development

Successfully merging this pull request may close these issues.

5 participants