Skip to content

Commit

Permalink
Handle item notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
anotheroneofthese committed Oct 9, 2024
1 parent d862947 commit 82b2684
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class SynqController(
@RequestBody synqBatchItemUpdatePayload: SynqBatchItemUpdatePayload
): ResponseEntity<Void> {
for (payload in synqBatchItemUpdatePayload.mapToItemPayloads()) {
val item = moveItem.moveItem(payload)
println(item)
moveItem.moveItem(payload)
}
return ResponseEntity.ok().build()
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/no/nb/mlt/wls/domain/WLSService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class WLSService(
throw ValidationException("Location can not be blank")
}
val item = getItem(hostName, hostId) ?: throw ItemNotFoundException("Item with id '$hostId' does not exist for '$hostName'")
return itemRepository.moveItem(item.hostId, item.hostName, quantity, location)
itemRepository.moveItem(item.hostId, item.hostName, quantity, location)
inventoryNotifier.itemChanged(item)

Check failure on line 75 in src/main/kotlin/no/nb/mlt/wls/domain/WLSService.kt

View workflow job for this annotation

GitHub Actions / JUnit Tests

no.nb.mlt.wls.domain.WLSServiceTest ► moveItem should return when item successfully moves

Failed test found in: target/surefire-reports/TEST-no.nb.mlt.wls.domain.WLSServiceTest.xml Error: io.mockk.MockKException: no answer found for: InventoryNotifier(#54).itemChanged(Item(hostId=12345, hostName=AXIELL, description=Tyven, tyven skal du hete, itemCategory=BOOK, preferredEnvironment=NONE, packaging=NONE, owner=NB, callbackUrl=https://callback.com/item, location=null, quantity=null))
Raw output
io.mockk.MockKException: no answer found for: InventoryNotifier(#54).itemChanged(Item(hostId=12345, hostName=AXIELL, description=Tyven, tyven skal du hete, itemCategory=BOOK, preferredEnvironment=NONE, packaging=NONE, owner=NB, callbackUrl=https://callback.com/item, location=null, quantity=null))
	at io.mockk.impl.stub.MockKStub.defaultAnswer(MockKStub.kt:90)
	at io.mockk.impl.stub.MockKStub.answer(MockKStub.kt:42)
	at io.mockk.impl.recording.states.AnsweringState.call(AnsweringState.kt:16)
	at io.mockk.impl.recording.CommonCallRecorder.call(CommonCallRecorder.kt:53)
	at io.mockk.impl.stub.MockKStub.handleInvocation(MockKStub.kt:263)
	at io.mockk.impl.instantiation.JvmMockFactoryHelper$mockHandler$1.invocation(JvmMockFactoryHelper.kt:25)
	at io.mockk.proxy.jvm.advice.Interceptor.call(Interceptor.kt:20)
	at io.mockk.proxy.jvm.advice.BaseAdvice.handle(BaseAdvice.kt:42)
	at io.mockk.proxy.jvm.advice.jvm.JvmMockKProxyInterceptor.interceptNoSuper(JvmMockKProxyInterceptor.java:45)
	at no.nb.mlt.wls.domain.ports.outbound.InventoryNotifier$Subclass3.itemChanged(Unknown Source)
	at no.nb.mlt.wls.domain.WLSService.moveItem(WLSService.kt:75)
	at no.nb.mlt.wls.domain.WLSServiceTest$moveItem should return when item successfully moves$3.invokeSuspend(WLSServiceTest.kt:139)
	at no.nb.mlt.wls.domain.WLSServiceTest$moveItem should return when item successfully moves$3.invoke(WLSServiceTest.kt)
	at no.nb.mlt.wls.domain.WLSServiceTest$moveItem should return when item successfully moves$3.invoke(WLSServiceTest.kt)
	at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$1.invokeSuspend(TestBuilders.kt:314)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
	at kotlinx.coroutines.test.TestDispatcher.processEvent$kotlinx_coroutines_test(TestDispatcher.kt:28)
	at kotlinx.coroutines.test.TestCoroutineScheduler.tryRunNextTaskUnless$kotlinx_coroutines_test(TestCoroutineScheduler.kt:103)
	at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$workRunner$1.invokeSuspend(TestBuilders.kt:320)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at kotlinx.coroutines.test.TestBuildersJvmKt.createTestResult(TestBuildersJvm.kt:13)
	at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt.runTest-8Mi8wO0(TestBuilders.kt:308)
	at kotlinx.coroutines.test.TestBuildersKt.runTest-8Mi8wO0(Unknown Source)
	at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt.runTest-8Mi8wO0(TestBuilders.kt:166)
	at kotlinx.coroutines.test.TestBuildersKt.runTest-8Mi8wO0(Unknown Source)
	at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt.runTest-8Mi8wO0$default(TestBuilders.kt:158)
	at kotlinx.coroutines.test.TestBuildersKt.runTest-8Mi8wO0$default(Unknown Source)
	at no.nb.mlt.wls.domain.WLSServiceTest.moveItem should return when item successfully moves(WLSServiceTest.kt:138)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
return item
}

override suspend fun createOrder(orderDTO: CreateOrderDTO): Order {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ class InventoryNotifierAdapter(
private val webClient: WebClient
) : InventoryNotifier {
override fun itemChanged(item: Item) {
TODO("Future task")
if (item.callbackUrl != null) {
webClient
.post()
.uri(item.callbackUrl)
.bodyValue(item)
.retrieve()
.bodyToMono(Void::class.java)
.retry(5)
.subscribe()
}
}

override fun orderChanged(order: Order) {
Expand Down

0 comments on commit 82b2684

Please sign in to comment.