Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. package com.marcelustrojahn.models
  2.  
  3. import io.ebean.Ebean
  4. import io.kotlintest.matchers.shouldBe
  5. import io.kotlintest.matchers.shouldNotBe
  6. import io.kotlintest.specs.FreeSpec
  7.  
  8. class BaseEntityTests: FreeSpec() {
  9. init {
  10. // remember the database will always be empty in the beggining of tests
  11. // so the id will be 1
  12. "should be able to save a Person" {
  13. val person = Person().apply { name = "John" }
  14. Ebean.save(person)
  15. person.id shouldNotBe null // id is filled on save
  16. }
  17. "should be able to select the Person from the database" {
  18. val person = Ebean.find(Person::class.java).where().idEq(1).findOne()
  19. person shouldNotBe null
  20. }
  21. "should be able to update the Person" {
  22. val person = Ebean.find(Person::class.java).where().idEq(1).findOne()
  23. person?.name = "Jack"
  24. Ebean.save(person)
  25. Ebean.find(Person::class.java).where().idEq(1).findOne()?.name shouldBe "Jack"
  26. }
  27. "should be able to delete the Person" {
  28. Ebean.delete(Person::class.java, 1)
  29. Ebean.find(Person::class.java).where().idEq(1).findOne() shouldBe null
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement