From 31328bf18ac2093d43b72fc76f83093e129c6310 Mon Sep 17 00:00:00 2001 From: Noah Bjerkli Aanonli Date: Tue, 20 Aug 2024 13:50:59 +0200 Subject: [PATCH] MLT-0032 Tests for OrderService (#28) Added tests relating to the Orders --- .../wls/order/repository/OrderRepository.kt | 2 +- .../nb/mlt/wls/order/service/OrderService.kt | 39 +++- .../order/controller/OrderControllerTest.kt | 181 ++++++++++++++++++ .../order/model/OrderModelConversionTest.kt | 108 +++++++++++ .../mlt/wls/order/service/OrderServiceTest.kt | 150 +++++++++++++++ .../ProductModelConversionTest.kt} | 27 +-- 6 files changed, 479 insertions(+), 28 deletions(-) create mode 100644 src/test/kotlin/no/nb/mlt/wls/order/controller/OrderControllerTest.kt create mode 100644 src/test/kotlin/no/nb/mlt/wls/order/model/OrderModelConversionTest.kt create mode 100644 src/test/kotlin/no/nb/mlt/wls/order/service/OrderServiceTest.kt rename src/test/kotlin/no/nb/mlt/wls/product/{ProductConvertiontests.kt => model/ProductModelConversionTest.kt} (80%) diff --git a/src/main/kotlin/no/nb/mlt/wls/order/repository/OrderRepository.kt b/src/main/kotlin/no/nb/mlt/wls/order/repository/OrderRepository.kt index 58e1d244..e5eeb906 100644 --- a/src/main/kotlin/no/nb/mlt/wls/order/repository/OrderRepository.kt +++ b/src/main/kotlin/no/nb/mlt/wls/order/repository/OrderRepository.kt @@ -8,7 +8,7 @@ import reactor.core.publisher.Mono @Repository interface OrderRepository : ReactiveMongoRepository { - fun getByHostNameAndHostOrderId( + fun findByHostNameAndHostOrderId( hostName: HostName, hostOrderId: String ): Mono diff --git a/src/main/kotlin/no/nb/mlt/wls/order/service/OrderService.kt b/src/main/kotlin/no/nb/mlt/wls/order/service/OrderService.kt index e729340a..cc86cee5 100644 --- a/src/main/kotlin/no/nb/mlt/wls/order/service/OrderService.kt +++ b/src/main/kotlin/no/nb/mlt/wls/order/service/OrderService.kt @@ -12,6 +12,7 @@ import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.stereotype.Service import org.springframework.web.server.ServerErrorException +import org.springframework.web.server.ServerWebInputException import java.time.Duration import java.util.concurrent.TimeoutException @@ -20,14 +21,20 @@ private val logger = KotlinLogging.logger {} @Service class OrderService(val db: OrderRepository, val synqService: SynqOrderService) { suspend fun createOrder(payload: ApiOrderPayload): ResponseEntity { + throwIfInvalidPayload(payload) + val existingOrder = - db.getByHostNameAndHostOrderId(payload.hostName, payload.orderId) + db.findByHostNameAndHostOrderId(payload.hostName, payload.orderId) .timeout(Duration.ofSeconds(8)) - .onErrorMap(TimeoutException::class.java) { - logger.error(it) { - "Timed out while fetching from WLS database. Relevant payload: $payload" + .onErrorMap { + if (it is TimeoutException) { + logger.error(it) { + "Timed out while fetching from WLS database. Relevant payload: $payload" + } + } else { + logger.error(it) { "Unexpected error for $payload" } } - ServerErrorException("Failed to create the order in storage system", it) + ServerErrorException("Failed while checking if order already exists in the database", it) } .awaitSingleOrNull() @@ -35,17 +42,35 @@ class OrderService(val db: OrderRepository, val synqService: SynqOrderService) { return ResponseEntity.badRequest().build() } - synqService.createOrder(payload.toOrder().toSynqPayload()) + val synqResponse = synqService.createOrder(payload.toOrder().toSynqPayload()) + // If SynQ didn't throw an error, but returned something that wasn't a new order, + // then it is likely some error or edge-case + if (!synqResponse.statusCode.isSameCodeAs(HttpStatus.CREATED)) { + throw ServerErrorException("Unexpected error with SynQ", null) + } + // Return what the database saved, as it could contain changes val order = db.save(payload.toOrder()) .timeout(Duration.ofSeconds(6)) .onErrorMap(TimeoutException::class.java) { logger.error { "Saving order timed out for payload: %s".format(payload.toString()) } - ServerErrorException("Failed to create the order in storage system", it) + ServerErrorException("Failed to save the order in the database", it) } .awaitSingle() return ResponseEntity.status(HttpStatus.CREATED).body(order.toApiOrderPayload()) } + + private fun throwIfInvalidPayload(payload: ApiOrderPayload) { + if (payload.orderId.isBlank()) { + throw ServerWebInputException("The order's orderId is required, and can not be blank") + } + if (payload.hostOrderId.isBlank()) { + throw ServerWebInputException("The order's hostOrderId is required, and can not be blank") + } + if (payload.productLine.isEmpty()) { + throw ServerWebInputException("The order must contain product lines") + } + } } diff --git a/src/test/kotlin/no/nb/mlt/wls/order/controller/OrderControllerTest.kt b/src/test/kotlin/no/nb/mlt/wls/order/controller/OrderControllerTest.kt new file mode 100644 index 00000000..ca13c930 --- /dev/null +++ b/src/test/kotlin/no/nb/mlt/wls/order/controller/OrderControllerTest.kt @@ -0,0 +1,181 @@ +package no.nb.mlt.wls.order.controller + +import com.ninjasquad.springmockk.MockkBean +import io.mockk.coEvery +import io.mockk.junit5.MockKExtension +import kotlinx.coroutines.reactor.awaitSingle +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runTest +import no.nb.mlt.wls.EnableTestcontainers +import no.nb.mlt.wls.core.data.HostName +import no.nb.mlt.wls.core.data.Owner +import no.nb.mlt.wls.core.data.synq.SynqError +import no.nb.mlt.wls.order.model.OrderLineStatus +import no.nb.mlt.wls.order.model.OrderReceiver +import no.nb.mlt.wls.order.model.OrderStatus +import no.nb.mlt.wls.order.model.OrderType +import no.nb.mlt.wls.order.model.ProductLine +import no.nb.mlt.wls.order.payloads.ApiOrderPayload +import no.nb.mlt.wls.order.payloads.toOrder +import no.nb.mlt.wls.order.repository.OrderRepository +import no.nb.mlt.wls.order.service.OrderService +import no.nb.mlt.wls.order.service.SynqOrderService +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS +import org.junit.jupiter.api.extension.ExtendWith +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity +import org.springframework.security.test.context.support.WithMockUser +import org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.csrf +import org.springframework.test.web.reactive.server.WebTestClient +import java.net.URI + +@EnableTestcontainers +@TestInstance(PER_CLASS) +@AutoConfigureWebTestClient +@ExtendWith(MockKExtension::class) +@EnableMongoRepositories("no.nb.mlt.wls") +@SpringBootTest(webEnvironment = RANDOM_PORT) +class OrderControllerTest( + @Autowired val repository: OrderRepository +) { + @MockkBean + private lateinit var synqOrderService: SynqOrderService + + private lateinit var webTestClient: WebTestClient + + @BeforeEach + fun setUp() { + webTestClient = + WebTestClient + .bindToController(OrderController(OrderService(repository, synqOrderService))) + .configureClient() + .baseUrl("/v1/order") + .build() + + populateDb() + } + + @Test + @WithMockUser + fun `createOrder with valid payload creates order`() = + runTest { + coEvery { + synqOrderService.createOrder(any()) + } returns ResponseEntity.created(URI.create("")).build() + + webTestClient + .mutateWith(csrf()) + .post() + .uri("/batch/create") + .accept(MediaType.APPLICATION_JSON) + .bodyValue(testOrderPayload) + .exchange() + .expectStatus().isCreated + + val order = repository.findByHostNameAndHostOrderId(testOrderPayload.hostName, testOrderPayload.hostOrderId).awaitSingle() + + assertThat(order) + .isNotNull + .extracting("callbackUrl", "status") + .containsExactly("callbackUrl", OrderStatus.NOT_STARTED) + } + + @Test + @WithMockUser + fun `createOrder with duplicate payload returns OK`() { + // How to handle this? OK or error? + } + + @Test + @WithMockUser + fun `createOrder payload with different data but same ID returns DB entry`() { + // How to handle this? OK or error? + } + + @Test + @WithMockUser + fun `createOrder where SynQ says it's a duplicate returns OK`() { + // How to handle this? OK or error? + } + + @Test + @WithMockUser + fun `createOrder handles SynQ error`() { + coEvery { + synqOrderService.createOrder(any()) + } returns ResponseEntity.internalServerError().body(SynqError(9001, "Unexpected error")) + + webTestClient + .mutateWith(csrf()) + .post() + .uri("/batch/create") + .accept(MediaType.APPLICATION_JSON) + .bodyValue(testOrderPayload) + .exchange() + .expectStatus().is5xxServerError + } + +// ///////////////////////////////////////////////////////////////////////////// +// //////////////////////////////// Test Help ////////////////////////////////// +// ///////////////////////////////////////////////////////////////////////////// + + // Will be used in most tests + private val testOrderPayload = + ApiOrderPayload( + orderId = "axiell-order-69", + hostName = HostName.AXIELL, + hostOrderId = "axiell-order-69", + status = OrderStatus.NOT_STARTED, + productLine = listOf(ProductLine("mlt-420", OrderLineStatus.NOT_STARTED)), + orderType = OrderType.LOAN, + owner = Owner.NB, + receiver = + OrderReceiver( + name = "name", + address = "address", + postalCode = "postalCode", + city = "city", + phoneNumber = "phoneNumber", + location = "location" + ), + callbackUrl = "callbackUrl" + ) + + // Will exist in the database + private val duplicateOrderPayload = + ApiOrderPayload( + orderId = "order-123456", + hostName = HostName.AXIELL, + hostOrderId = "order-123456", + status = OrderStatus.NOT_STARTED, + productLine = listOf(ProductLine("product-123456", OrderLineStatus.NOT_STARTED)), + orderType = OrderType.LOAN, + owner = Owner.NB, + receiver = + OrderReceiver( + name = "name", + address = "address", + postalCode = "postalCode", + city = "city", + phoneNumber = "phoneNumber", + location = "location" + ), + callbackUrl = "callbackUrl" + ) + + fun populateDb() { + // Make sure we start with clean DB instance for each test + runBlocking { + repository.deleteAll().then(repository.save(duplicateOrderPayload.toOrder())).awaitSingle() + } + } +} diff --git a/src/test/kotlin/no/nb/mlt/wls/order/model/OrderModelConversionTest.kt b/src/test/kotlin/no/nb/mlt/wls/order/model/OrderModelConversionTest.kt new file mode 100644 index 00000000..b6184c3d --- /dev/null +++ b/src/test/kotlin/no/nb/mlt/wls/order/model/OrderModelConversionTest.kt @@ -0,0 +1,108 @@ +package no.nb.mlt.wls.order.model + +import no.nb.mlt.wls.core.data.HostName +import no.nb.mlt.wls.core.data.Owner +import no.nb.mlt.wls.core.data.synq.SynqOwner +import no.nb.mlt.wls.order.payloads.ApiOrderPayload +import no.nb.mlt.wls.order.payloads.SynqOrderPayload +import no.nb.mlt.wls.order.payloads.toApiOrderPayload +import no.nb.mlt.wls.order.payloads.toOrder +import no.nb.mlt.wls.order.payloads.toSynqPayload +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import java.time.LocalDateTime + +class OrderModelConversionTest { + private val testApiOrderPayload = + ApiOrderPayload( + orderId = "hostOrderId", + hostName = HostName.AXIELL, + hostOrderId = "hostOrderId", + status = OrderStatus.NOT_STARTED, + productLine = listOf(ProductLine("hostProductId", OrderLineStatus.NOT_STARTED)), + orderType = OrderType.LOAN, + owner = Owner.NB, + receiver = + OrderReceiver( + name = "name", + address = "address", + postalCode = "postalCode", + city = "city", + phoneNumber = "phoneNumber", + location = "location" + ), + callbackUrl = "callbackUrl" + ) + + private val testOrder = + Order( + hostName = HostName.AXIELL, + hostOrderId = "hostOrderId", + status = OrderStatus.NOT_STARTED, + productLine = listOf(ProductLine("hostProductId", OrderLineStatus.NOT_STARTED)), + orderType = OrderType.LOAN, + owner = Owner.NB, + receiver = + OrderReceiver( + name = "name", + address = "address", + postalCode = "postalCode", + city = "city", + phoneNumber = "phoneNumber", + location = "location" + ), + callbackUrl = "callbackUrl" + ) + + private val testSynqOrderPayload = + SynqOrderPayload( + orderId = "hostOrderId", + orderType = SynqOrderPayload.SynqOrderType.STANDARD, + dispatchDate = LocalDateTime.now(), + orderDate = LocalDateTime.now(), + priority = 1, + owner = SynqOwner.NB, + orderLine = listOf(SynqOrderPayload.OrderLine(1, "hostProductId", 1.0)) + ) + + @Test + fun `order converts to API payload`() { + val payload = testOrder.toApiOrderPayload() + + assertThat(payload.orderId).isEqualTo(testApiOrderPayload.orderId) + assertThat(payload.hostName).isEqualTo(testApiOrderPayload.hostName) + assertThat(payload.hostOrderId).isEqualTo(testApiOrderPayload.hostOrderId) + assertThat(payload.status).isEqualTo(testApiOrderPayload.status) + assertThat(payload.productLine).isEqualTo(testApiOrderPayload.productLine) + assertThat(payload.orderType).isEqualTo(testApiOrderPayload.orderType) + assertThat(payload.owner).isEqualTo(testApiOrderPayload.owner) + assertThat(payload.receiver).isEqualTo(testApiOrderPayload.receiver) + assertThat(payload.callbackUrl).isEqualTo(testApiOrderPayload.callbackUrl) + } + + @Test + fun `order converts to SynQ payload`() { + val synqPayload = testOrder.toSynqPayload() + + // Dates are not compared as they are generated in the function + assertThat(synqPayload.orderId).isEqualTo(testSynqOrderPayload.orderId) + assertThat(synqPayload.orderType).isEqualTo(testSynqOrderPayload.orderType) + assertThat(synqPayload.priority).isEqualTo(testSynqOrderPayload.priority) + assertThat(synqPayload.owner).isEqualTo(testSynqOrderPayload.owner) + assertThat(synqPayload.orderLine).isEqualTo(testSynqOrderPayload.orderLine) + } + + @Test + fun `API payload converts to order`() { + val order = testApiOrderPayload.toOrder() + + assertThat(order.hostName).isEqualTo(testOrder.hostName) + assertThat(order.hostOrderId).isEqualTo(testOrder.hostOrderId) + assertThat(order.status).isEqualTo(testOrder.status) + assertThat(order.productLine).isEqualTo(testOrder.productLine) + assertThat(order.orderType).isEqualTo(testOrder.orderType) + assertThat(order.owner).isEqualTo(testOrder.owner) + assertThat(order.receiver).isEqualTo(testOrder.receiver) + assertThat(order.callbackUrl).isEqualTo(testOrder.callbackUrl) + } +} diff --git a/src/test/kotlin/no/nb/mlt/wls/order/service/OrderServiceTest.kt b/src/test/kotlin/no/nb/mlt/wls/order/service/OrderServiceTest.kt new file mode 100644 index 00000000..97b8c8bf --- /dev/null +++ b/src/test/kotlin/no/nb/mlt/wls/order/service/OrderServiceTest.kt @@ -0,0 +1,150 @@ +package no.nb.mlt.wls.order.service + +import io.mockk.coEvery +import io.mockk.every +import io.mockk.impl.annotations.InjectMockKs +import io.mockk.impl.annotations.MockK +import io.mockk.junit5.MockKExtension +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runTest +import no.nb.mlt.wls.core.data.HostName +import no.nb.mlt.wls.core.data.Owner +import no.nb.mlt.wls.order.model.OrderLineStatus +import no.nb.mlt.wls.order.model.OrderReceiver +import no.nb.mlt.wls.order.model.OrderStatus +import no.nb.mlt.wls.order.model.OrderType +import no.nb.mlt.wls.order.model.ProductLine +import no.nb.mlt.wls.order.payloads.ApiOrderPayload +import no.nb.mlt.wls.order.payloads.toOrder +import no.nb.mlt.wls.order.repository.OrderRepository +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatExceptionOfType +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.TestInstance +import org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS +import org.junit.jupiter.api.extension.ExtendWith +import org.springframework.http.HttpStatus +import org.springframework.http.ResponseEntity +import org.springframework.web.server.ServerErrorException +import org.springframework.web.server.ServerWebInputException +import reactor.core.publisher.Mono + +@TestInstance(PER_CLASS) +@ExtendWith(MockKExtension::class) +class OrderServiceTest { + @MockK + private lateinit var db: OrderRepository + + @MockK + private lateinit var synq: SynqOrderService + + @InjectMockKs + private lateinit var cut: OrderService // cut = class under test + + @Test + fun `save called with payload missing orderId throws`() { + assertExceptionThrownWithMessage(top.copy(orderId = ""), "orderId is required", ServerWebInputException::class.java) + assertExceptionThrownWithMessage(top.copy(orderId = "\t\n"), "orderId is required", ServerWebInputException::class.java) + assertExceptionThrownWithMessage(top.copy(orderId = " "), "orderId is required", ServerWebInputException::class.java) + } + + @Test + fun `save called with payload missing hostOrderId throws`() { + assertExceptionThrownWithMessage(top.copy(hostOrderId = ""), "hostOrderId is required", ServerWebInputException::class.java) + assertExceptionThrownWithMessage(top.copy(hostOrderId = "\t\n"), "hostOrderId is required", ServerWebInputException::class.java) + assertExceptionThrownWithMessage(top.copy(hostOrderId = " "), "hostOrderId is required", ServerWebInputException::class.java) + } + + @Test + fun `save with payload missing product lines throws`() { + assertExceptionThrownWithMessage(top.copy(productLine = listOf()), "must contain product lines", ServerWebInputException::class.java) + } + + @Test + fun `save when order exists throws`() { + runTest { + every { db.findByHostNameAndHostOrderId(top.hostName, top.hostOrderId) } returns Mono.just(top.toOrder()) + assertThat(cut.createOrder(top).statusCode.is4xxClientError) + } + } + + @Test + fun `save called with Order that SynQ says exists throws`() { + runTest { + every { db.findByHostNameAndHostOrderId(top.hostName, top.hostOrderId) } returns Mono.empty() + coEvery { synq.createOrder(any()) } throws ServerErrorException("Duplicate order found in in SynQ", null) + + assertExceptionThrownWithMessage(top, "Duplicate order", ServerErrorException::class.java) + } + } + + @Test + fun `save called when SynQ fails is handled gracefully`() { + every { db.findByHostNameAndHostOrderId(top.hostName, top.hostOrderId) } returns Mono.empty() + coEvery { synq.createOrder(any()) } throws ServerErrorException("Unexpected error", null) + + assertThatExceptionOfType(ServerErrorException::class.java).isThrownBy { + runBlocking { + cut.createOrder(top) + } + } + } + + @Test + fun `save called when db is down is handled gracefully`() { + runTest { + every { db.findByHostNameAndHostOrderId(any(), any()) } returns Mono.error(Exception("db is down")) + + assertThatExceptionOfType(ServerErrorException::class.java).isThrownBy { + runBlocking { + cut.createOrder(top) + } + } + } + } + + @Test + fun `save with no errors returns created order`() { + runTest { + every { db.findByHostNameAndHostOrderId(top.hostName, top.hostOrderId) } returns Mono.empty() + coEvery { synq.createOrder(any()) } returns ResponseEntity(HttpStatus.CREATED) + every { db.save(any()) } returns Mono.just(top.toOrder()) + + assertThat(cut.createOrder(top).statusCode.is2xxSuccessful) + } + } + +// ///////////////////////////////////////////////////////////////////////////// +// //////////////////////////////// Test Help ////////////////////////////////// +// ///////////////////////////////////////////////////////////////////////////// + + // Will be used in most tests (top = test order payload) + private val top = + ApiOrderPayload( + orderId = "axiell-order-69", + hostName = HostName.AXIELL, + hostOrderId = "axiell-order-69", + status = OrderStatus.NOT_STARTED, + productLine = listOf(ProductLine("mlt-420", OrderLineStatus.NOT_STARTED)), + orderType = OrderType.LOAN, + owner = Owner.NB, + receiver = + OrderReceiver( + name = "name", + address = "address", + postalCode = "postalCode", + city = "city", + phoneNumber = "phoneNumber", + location = "location" + ), + callbackUrl = "callbackUrl" + ) + + private fun assertExceptionThrownWithMessage( + payload: ApiOrderPayload, + message: String, + exception: Class + ) = assertThatExceptionOfType(exception).isThrownBy { + runBlocking { cut.createOrder(payload) } + }.withMessageContaining(message) +} diff --git a/src/test/kotlin/no/nb/mlt/wls/product/ProductConvertiontests.kt b/src/test/kotlin/no/nb/mlt/wls/product/model/ProductModelConversionTest.kt similarity index 80% rename from src/test/kotlin/no/nb/mlt/wls/product/ProductConvertiontests.kt rename to src/test/kotlin/no/nb/mlt/wls/product/model/ProductModelConversionTest.kt index 7cecc701..36276bae 100644 --- a/src/test/kotlin/no/nb/mlt/wls/product/ProductConvertiontests.kt +++ b/src/test/kotlin/no/nb/mlt/wls/product/model/ProductModelConversionTest.kt @@ -1,11 +1,10 @@ -package no.nb.mlt.wls.product +package no.nb.mlt.wls.product.model import no.nb.mlt.wls.core.data.Environment import no.nb.mlt.wls.core.data.HostName import no.nb.mlt.wls.core.data.Owner import no.nb.mlt.wls.core.data.Packaging import no.nb.mlt.wls.core.data.synq.SynqOwner -import no.nb.mlt.wls.product.model.Product import no.nb.mlt.wls.product.payloads.ApiProductPayload import no.nb.mlt.wls.product.payloads.SynqProductPayload import no.nb.mlt.wls.product.payloads.toApiPayload @@ -14,8 +13,8 @@ import no.nb.mlt.wls.product.payloads.toSynqPayload import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProductConvertiontests { - val testProductPayload = +class ProductModelConversionTest { + private val testProductPayload = ApiProductPayload( hostId = "mlt-test-1234", hostName = HostName.AXIELL, @@ -28,7 +27,7 @@ class ProductConvertiontests { quantity = 1.0 ) - val testProduct = + private val testProduct = Product( hostId = "mlt-test-1234", hostName = HostName.AXIELL, @@ -41,7 +40,7 @@ class ProductConvertiontests { quantity = 1.0 ) - val testSynqPayload = + private val testSynqPayload = SynqProductPayload( productId = "mlt-test-1234", owner = SynqOwner.NB, @@ -54,7 +53,7 @@ class ProductConvertiontests { ) @Test - fun `product converts to payload`() { + fun `product converts to API payload`() { val payload = testProduct.toApiPayload() assertThat(payload.hostId).isEqualTo(testProductPayload.hostId) assertThat(payload.hostName).isEqualTo(testProductPayload.hostName) @@ -80,7 +79,7 @@ class ProductConvertiontests { } @Test - fun `payload converts to product`() { + fun `API payload converts to product`() { val product = testProductPayload.toProduct() assertThat(product.hostId).isEqualTo(testProduct.hostId) assertThat(product.hostName).isEqualTo(testProduct.hostName) @@ -92,16 +91,4 @@ class ProductConvertiontests { assertThat(product.location).isEqualTo(testProduct.location) assertThat(product.quantity).isEqualTo(testProduct.quantity) } - - @Test - fun `payload converts to SynQ payload`() { - val synq = testProductPayload.toProduct().toSynqPayload() - assertThat(synq.hostName).isEqualTo(testSynqPayload.hostName) - assertThat(synq.productId).isEqualTo(testSynqPayload.productId) - assertThat(synq.productUom.uomId).isEqualTo(testSynqPayload.productUom.uomId) - assertThat(synq.productCategory).isEqualTo(testSynqPayload.productCategory) - assertThat(synq.barcode.barcodeId).isEqualTo(testSynqPayload.barcode.barcodeId) - assertThat(synq.owner).isEqualTo(testSynqPayload.owner) - assertThat(synq.description).isEqualTo(testSynqPayload.description) - } }