mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#704 - Update tests for 704 removing the use of Query.setUseCache(true) which is redundant
This commit is contained in:
@@ -3,7 +3,6 @@ package com.avaje.tests.basic;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
@@ -13,6 +12,9 @@ import com.avaje.tests.model.basic.Address;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class TestLazyLoadInCache extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
@@ -23,12 +25,11 @@ public class TestLazyLoadInCache extends BaseTestCase {
|
||||
Map<?, Customer> map = Ebean.find(Customer.class)
|
||||
.select("id, name")
|
||||
.setLoadBeanCache(true)
|
||||
//.setUseCache(true)
|
||||
.setReadOnly(true)
|
||||
.orderBy().asc("id")
|
||||
.findMap();
|
||||
|
||||
Assert.assertTrue(map.size() > 0);
|
||||
assertTrue(map.size() > 0);
|
||||
|
||||
Object id = map.keySet().iterator().next();
|
||||
|
||||
@@ -36,28 +37,27 @@ public class TestLazyLoadInCache extends BaseTestCase {
|
||||
|
||||
Customer cust1B = Ebean.find(Customer.class)
|
||||
.setReadOnly(true)
|
||||
.setUseCache(true)
|
||||
.setId(id)
|
||||
.findUnique();
|
||||
|
||||
Assert.assertTrue(cust1 != cust1B);
|
||||
assertTrue(cust1 != cust1B);
|
||||
|
||||
Set<String> loadedProps = Ebean.getBeanState(cust1).getLoadedProps();
|
||||
|
||||
Assert.assertTrue(loadedProps.contains("name"));
|
||||
Assert.assertFalse(loadedProps.contains("status"));
|
||||
assertTrue(loadedProps.contains("name"));
|
||||
assertFalse(loadedProps.contains("status"));
|
||||
|
||||
cust1.getStatus();
|
||||
|
||||
// a readOnly reference
|
||||
Address billingAddress = cust1.getBillingAddress();
|
||||
BeanState billAddrState = Ebean.getBeanState(billingAddress);
|
||||
Assert.assertTrue(billAddrState.isReference());
|
||||
Assert.assertTrue(billAddrState.isReadOnly());
|
||||
assertTrue(billAddrState.isReference());
|
||||
assertTrue(billAddrState.isReadOnly());
|
||||
|
||||
// lazy load .. no longer a reference
|
||||
billingAddress.getCity();
|
||||
Assert.assertFalse(billAddrState.isReference());
|
||||
assertFalse(billAddrState.isReference());
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user