Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anotheroneofthese committed Oct 10, 2024
1 parent 5778768 commit d7c5cd8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/test/kotlin/no/nb/mlt/wls/domain/WLSServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import no.nb.mlt.wls.domain.model.Packaging
import no.nb.mlt.wls.domain.ports.inbound.CreateOrderDTO
import no.nb.mlt.wls.domain.ports.inbound.ItemMetadata
import no.nb.mlt.wls.domain.ports.inbound.ItemNotFoundException
import no.nb.mlt.wls.domain.ports.inbound.MoveItemPayload
import no.nb.mlt.wls.domain.ports.inbound.OrderNotFoundException
import no.nb.mlt.wls.domain.ports.inbound.ValidationException
import no.nb.mlt.wls.domain.ports.outbound.InventoryNotifier
Expand Down Expand Up @@ -138,7 +139,7 @@ class WLSServiceTest {

val cut = WLSService(itemRepoMock, orderRepoMock, storageSystemRepoMock, inventoryNotifierMock)
runTest {
val movedItem = cut.moveItem(testItem.hostId, testItem.hostName, 1.0, "Somewhere nice")
val movedItem = cut.moveItem(testMoveItemPayload)
assertThat(movedItem).isEqualTo(expectedItem)

coVerify(exactly = 1) { itemRepoMock.getItem(any(), any()) }
Expand All @@ -154,7 +155,7 @@ class WLSServiceTest {
val cut = WLSService(itemRepoMock, orderRepoMock, storageSystemRepoMock, inventoryNotifierMock)
runTest {
assertThrows<RuntimeException> {
cut.moveItem(testItem.hostId, testItem.hostName, 1.0, "Somewhere nice")
cut.moveItem(testMoveItemPayload)
}

coVerify(exactly = 1) { itemRepoMock.getItem(any(), any()) }
Expand All @@ -170,7 +171,7 @@ class WLSServiceTest {
val cut = WLSService(itemRepoMock, orderRepoMock, storageSystemRepoMock, inventoryNotifierMock)
runTest {
assertThrows<RuntimeException> {
cut.moveItem(testItem.hostId, testItem.hostName, -1.0, "Somewhere nice")
cut.moveItem(testMoveItemPayload.copy(quantity = -1.0))
}

coVerify(exactly = 0) { itemRepoMock.getItem(any(), any()) }
Expand All @@ -186,7 +187,7 @@ class WLSServiceTest {
val cut = WLSService(itemRepoMock, orderRepoMock, storageSystemRepoMock, inventoryNotifierMock)
runTest {
assertThrows<RuntimeException> {
cut.moveItem(testItem.hostId, testItem.hostName, 1.0, " ")
cut.moveItem(testMoveItemPayload.copy(location = " "))
}

coVerify(exactly = 0) { itemRepoMock.getItem(any(), any()) }
Expand Down Expand Up @@ -435,6 +436,14 @@ class WLSServiceTest {
)
)

private val testMoveItemPayload =
MoveItemPayload(
"12345",
HostName.AXIELL,
1.0,
"Somewhere nice"
)

private fun Order.toCreateOrderDTO() =
CreateOrderDTO(
hostName = testOrder.hostName,
Expand Down

0 comments on commit d7c5cd8

Please sign in to comment.