Guest User

Untitled

a guest
Dec 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. interface BrandController {
  2. fun findDTOs(pageable: Pageable): ResponseEntity<Page<SomeDTO>>
  3. }
  4.  
  5. var response: ResponseEntity<*>
  6.  
  7. @Test
  8. fun `test`() {
  9. `given TestRestTemplate`()
  10. `when findDTOs`()
  11. `then check body`()
  12. }
  13.  
  14. protected fun `given not authorization`() {
  15. restTemplate = TestRestTemplate()
  16. }
  17.  
  18. private fun `when findDTOs`() {
  19. // RestResponsePage<T> extends PageImpl<T>
  20. response = restTemplate.getForEntity<RestResponsePage<SomeDTO>>(createUrlWithParams(url, requestPage))
  21. }
  22.  
  23. private fun `then check body`() {
  24. val body: Page<SomeDTO> = response.body as Page<SomeDTO> // body: "Page 2 of 2 containing java.util.LinkedHashMap instances"
  25.  
  26. assertEquals(requestPage.size, body.size) // success
  27.  
  28. val content: List<SomeDTO> = body.content as List<SomeDTO> // content: size = 10 body: "Page 2 of 2 containing java.util.LinkedHashMap instances"
  29.  
  30. brands.forEachIndexed { index, someDTO: SomeDTO-> //Error
  31. assertEquals(list[index].name, someDTO.name)
  32. assertEquals(list[index].id, someDTO.id)
  33. }
  34. }
  35.  
  36. java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com....SomeDTO
Add Comment
Please, Sign In to add comment