mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#2335 Initial test work
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package org.tests.model.basic.cache;
|
||||
|
||||
import io.ebean.Model;
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.SoftDelete;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Cache
|
||||
@Entity
|
||||
@Table(name = "e_softwithcache")
|
||||
public class ESoftWithCache extends Model {
|
||||
|
||||
@Id
|
||||
long id;
|
||||
|
||||
String name;
|
||||
|
||||
String description;
|
||||
|
||||
@SoftDelete
|
||||
boolean deleted;
|
||||
|
||||
@Version
|
||||
long version;
|
||||
|
||||
public ESoftWithCache(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ESoftWithCache id(long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ESoftWithCache name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public ESoftWithCache description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long version() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public ESoftWithCache version(long version) {
|
||||
this.version = version;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package org.tests.model.basic.cache;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestCacheWithSoftDelete extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void idIn_expect_hitCache() {
|
||||
|
||||
ESoftWithCache bean = new ESoftWithCache("hello");
|
||||
DB.save(bean);
|
||||
|
||||
final List<ESoftWithCache> found = DB.find(ESoftWithCache.class)
|
||||
.where().idIn(bean.id())
|
||||
//.setUseCache(true)
|
||||
.findList();
|
||||
|
||||
assertThat(found).hasSize(1);
|
||||
|
||||
final List<ESoftWithCache> foundAgain = DB.find(ESoftWithCache.class)
|
||||
.where().idIn(bean.id())
|
||||
//.setUseCache(true)
|
||||
.findList();
|
||||
|
||||
assertThat(foundAgain).hasSize(1);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user