From d37629ff729cbd1dfe5eb847ab87749c173c6675 Mon Sep 17 00:00:00 2001 From: bossanyit Date: Sat, 28 Nov 2020 09:37:46 +0100 Subject: [PATCH] API 1.0.16 CustomerExerciseDeviceTest --- .../api/test/CustomerExerciseDeviceTest.kt | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/test/kotlin/com/aitrainer/api/test/CustomerExerciseDeviceTest.kt b/src/test/kotlin/com/aitrainer/api/test/CustomerExerciseDeviceTest.kt index 3ecc14d..8a43de8 100644 --- a/src/test/kotlin/com/aitrainer/api/test/CustomerExerciseDeviceTest.kt +++ b/src/test/kotlin/com/aitrainer/api/test/CustomerExerciseDeviceTest.kt @@ -21,14 +21,14 @@ class CustomerExerciseDeviceTest { private lateinit var customerExerciseDeviceRepository: CustomerExerciseDeviceRepository @Test - fun testGetPurchaseByCustomerId() { + fun testGetDevicesByCustomerId() { val controller = CustomerExerciseDeviceController(customerExerciseDeviceRepository) val response = controller.getAllByCustomerId(90) val devices = response.body assertTrue(devices is List) - assertTrue(devices.isNotEmpty()) + assertTrue(devices!!.isNotEmpty()) assertEquals(devices.size, 2) assertEquals(devices[0].exerciseDeviceId, 1) assertEquals(devices[0].customerId, 90) @@ -58,7 +58,7 @@ class CustomerExerciseDeviceTest { } @Test - fun deleteDevice() { + fun testDeleteDevice() { val customerExerciseDevice = CustomerExerciseDevice( exerciseDeviceId = 3, favourite = false, @@ -73,7 +73,31 @@ class CustomerExerciseDeviceTest { val device = response.body assertTrue(device != null) - val responseDelete = controller.deleteCustomerExerciseDevice(device) + val responseDelete = controller.deleteCustomerExerciseDevice(device.customerExerciseDeviceId) + assertEquals(responseDelete.statusCode, HttpStatus.OK) + } + + @Test + fun testFindById() { + val device = customerExerciseDeviceRepository.findById(1).orElse(null); + assertTrue(device != null); + } + + + + @Test + fun testJustDeleteDevice() { + val device = CustomerExerciseDevice( + customerExerciseDeviceId = 3, + exerciseDeviceId = 5, + favourite = false, + dateAdd = "2020-11-23 04:32:00", + customerId = 90 + ) + + val controller = CustomerExerciseDeviceController(customerExerciseDeviceRepository) + + val responseDelete = controller.deleteCustomerExerciseDevice(device.customerExerciseDeviceId) assertEquals(responseDelete.statusCode, HttpStatus.OK) }