#704 - Update tests for 704 removing the use of Query.setUseCache(true) which is redundant

This commit is contained in:
Robin Bygrave
2016-05-13 14:31:03 +12:00
parent e344b5c0a1
commit 8c6653605d
8 changed files with 113 additions and 179 deletions
@@ -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());
}