API 1.0.16 CustomerExerciseDevice.delete fix
This commit is contained in:
parent
d37629ff72
commit
5e75fce2bc
1
.gitignore
vendored
1
.gitignore
vendored
@ -30,3 +30,4 @@ out/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
logs/aitrainer.log
|
||||
|
1161
data/db/install.sql
1161
data/db/install.sql
File diff suppressed because it is too large
Load Diff
@ -33,10 +33,12 @@ class CustomerExerciseDeviceController(private val customerExerciseDeviceReposit
|
||||
}
|
||||
|
||||
@Secured
|
||||
@PostMapping("/customer_exercise_device/delete/")
|
||||
fun deleteCustomerExerciseDevice(@Valid @RequestBody customerExerciseDevice: CustomerExerciseDevice) :ResponseEntity<HttpStatus> {
|
||||
val returnDevice = customerExerciseDeviceRepository.findById(customerExerciseDevice.customerExerciseDeviceId).orElse(null)
|
||||
?: return ResponseEntity.notFound().build()
|
||||
@PostMapping("/customer_exercise_device/delete/{id}")
|
||||
fun deleteCustomerExerciseDevice(@PathVariable(value = "id") customerExerciseDeviceId: Long) :ResponseEntity<HttpStatus> {
|
||||
logger.info("Delete device by ID: $customerExerciseDeviceId")
|
||||
val returnDevice = customerExerciseDeviceRepository.findById(customerExerciseDeviceId).orElse(null)
|
||||
?: return ResponseEntity.notFound().build()
|
||||
|
||||
try {
|
||||
customerExerciseDeviceRepository.delete(returnDevice)
|
||||
} catch (e: IllegalArgumentException ) {
|
||||
|
@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull
|
||||
data class CustomerExerciseDevice (
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
val customerExerciseDeviceId: Long = 0,
|
||||
var customerExerciseDeviceId: Long = 0,
|
||||
@get: NotNull var exerciseDeviceId: Long?,
|
||||
@get: NotNull var customerId: Long?,
|
||||
@get: NotNull var favourite: Boolean?,
|
||||
|
13
src/main/resources/application-testmac.properties
Normal file
13
src/main/resources/application-testmac.properties
Normal file
@ -0,0 +1,13 @@
|
||||
spring.profiles.active=testmac
|
||||
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
|
||||
#spring.datasource.url = jdbc:mysql://localhost:3306/aitrainer?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
|
||||
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/aitrainer2?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&allowMultiQueries=true
|
||||
spring.datasource.username = root
|
||||
spring.datasource.password = andio2009
|
||||
|
||||
|
||||
## Hibernate Properties
|
||||
|
||||
|
||||
# The SQL dialect makes Hibernate generate better SQL for the chosen database
|
||||
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
|
@ -24,7 +24,7 @@ class ApplicationStartTest {
|
||||
var foundTable = false
|
||||
val rs: ResultSet = Singleton.execQuery("Show tables;")
|
||||
while ( rs.next() ) {
|
||||
if ( rs.getString("tables_in_aitrainer2") == "customer_information" ) {
|
||||
if ( rs.getString("Tables_in_aitrainer2") == "customer_information" ) {
|
||||
foundTable = true
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ class CustomerExerciseDeviceTest {
|
||||
|
||||
val devices = response.body
|
||||
|
||||
assertTrue(devices is List)
|
||||
assertTrue(devices!!.isNotEmpty())
|
||||
assertEquals(devices.size, 2)
|
||||
assertTrue(devices != null)
|
||||
assertTrue(devices.isNotEmpty())
|
||||
assertEquals(devices.size, 3)
|
||||
assertEquals(devices[0].exerciseDeviceId, 1)
|
||||
assertEquals(devices[0].customerId, 90)
|
||||
|
||||
@ -75,30 +75,6 @@ class CustomerExerciseDeviceTest {
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -14,8 +14,10 @@ class PropertiesTest {
|
||||
|
||||
@Test
|
||||
fun testDatasourceUrl() {
|
||||
val url: String = properties.getDatasourceUrl()
|
||||
assertEquals(url, "jdbc:mysql://localhost:3306/aitrainer2?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true")
|
||||
//val url: String = properties.getDatasourceUrl()
|
||||
//assertEquals(url, "jdbc:mysql://localhost:3306/aitrainer2?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true")
|
||||
val dialect: String = properties.getDatasourceUsername()
|
||||
assertEquals(dialect, "root")
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user