Customer.findByEmail
This commit is contained in:
parent
c04f0cbbc4
commit
83939110af
@ -41,12 +41,19 @@ class CustomerController ( private val customerRepository: CustomerRepository )
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Secured
|
@Secured
|
||||||
@GetMapping("/customers/firebase/{uid}")
|
@GetMapping("/customers/find_by_firebaseuid/{uid}")
|
||||||
fun getCustomerByFirebaseUid(@PathVariable(value = "uid") firebaseUid: String): ResponseEntity<Customer> {
|
fun getCustomerByFirebaseUid(@PathVariable(value = "uid") firebaseUid: String): ResponseEntity<Customer> {
|
||||||
val customer: Customer? = customerRepository.findByFirebaseUid(firebaseUid)
|
val customer: Customer? = customerRepository.findByFirebaseUid(firebaseUid)
|
||||||
return if (customer == null) ResponseEntity.notFound().build() else ResponseEntity.ok().body(customer)
|
return if (customer == null) ResponseEntity.notFound().build() else ResponseEntity.ok().body(customer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Secured
|
||||||
|
@GetMapping("/customers/find_by_email/{email}")
|
||||||
|
fun getCustomerByEmail(@PathVariable(value = "email") email: String): ResponseEntity<Customer> {
|
||||||
|
val customer: Customer? = customerRepository.findByEmail(email)
|
||||||
|
return if (customer == null) ResponseEntity.notFound().build() else ResponseEntity.ok().body(customer)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Secured
|
@Secured
|
||||||
@GetMapping("/customers/real")
|
@GetMapping("/customers/real")
|
||||||
|
@ -206,6 +206,19 @@ class CustomerTests {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testGetCustomerByEmail() {
|
||||||
|
val email = "sw2@andio.biz"
|
||||||
|
val customerController = CustomerController(customerRepository)
|
||||||
|
val response: ResponseEntity<*> = customerController.getCustomerByEmail(email)
|
||||||
|
assertEquals(response.statusCode, HttpStatus.OK)
|
||||||
|
val newCustomer: Customer? = response.body as Customer
|
||||||
|
assertEquals(newCustomer!!.name, "Bos")
|
||||||
|
assertEquals(newCustomer.email, "sw2@andio.biz")
|
||||||
|
assertEquals(newCustomer.firebaseUid, "3FirebaseU1d")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*@Test fun _testLogin() {
|
/*@Test fun _testLogin() {
|
||||||
val json = "{\"username\":\"bosi2@example.com\",\"password\":\"94333385\"}"
|
val json = "{\"username\":\"bosi2@example.com\",\"password\":\"94333385\"}"
|
||||||
val user: User = User().fromJson(json)
|
val user: User = User().fromJson(json)
|
||||||
|
Loading…
Reference in New Issue
Block a user