mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-23 21:15:52 +00:00
no effective change - format test code
This commit is contained in:
@@ -10,12 +10,12 @@ import org.slf4j.LoggerFactory;
|
||||
import java.sql.Types;
|
||||
|
||||
public class BaseTestCase {
|
||||
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(BaseTestCase.class);
|
||||
|
||||
|
||||
static {
|
||||
logger.debug("... preStart");
|
||||
if (!AgentLoader.loadAgentFromClasspath("ebean-agent","debug=1;packages=com.avaje.tests,org.avaje.test")) {
|
||||
if (!AgentLoader.loadAgentFromClasspath("ebean-agent", "debug=1;packages=com.avaje.tests,org.avaje.test")) {
|
||||
logger.info("avaje-ebeanorm-agent not found in classpath - not dynamically loaded");
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class BaseTestCase {
|
||||
protected void loadCountryCache() {
|
||||
|
||||
Ebean.find(Country.class)
|
||||
.setLoadBeanCache(true)
|
||||
.findList();
|
||||
.setLoadBeanCache(true)
|
||||
.findList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,36 +13,37 @@ public class ColumnTest {
|
||||
|
||||
@Test
|
||||
public void equals_when_same() {
|
||||
assertSame(col(1, "name", null),col(1, "name", null));
|
||||
assertSame(col(1, "name", null), col(1, "name", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_same_withAlias() {
|
||||
assertSame(col(1, "t0.name", "t0"),col(1, "t0.name", "t0"));
|
||||
assertSame(col(1, "t0.name", "t0"), col(1, "t0.name", "t0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffIndex() {
|
||||
assertDifferent(col(1, "name", null),col(2, "name", null));
|
||||
assertDifferent(col(1, "name", null), col(2, "name", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffProperty() {
|
||||
assertDifferent(col(1, "name", null),col(1, "diffName", null));
|
||||
assertDifferent(col(1, "name", null), col(1, "diffName", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffAlias() {
|
||||
assertDifferent(col(1, "t1.name", "t1"),col(1, "t1.name", "t0"));
|
||||
assertDifferent(col(1, "t1.name", "t1"), col(1, "t1.name", "t0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffAliasNullLast() {
|
||||
assertDifferent(col(1, "t1.name", "t1"),col(1, "t1.name", null));
|
||||
assertDifferent(col(1, "t1.name", "t1"), col(1, "t1.name", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equals_when_diffAliasNullFirst() {
|
||||
assertDifferent(col(1, "t1.name", null),col(1, "t1.name", "t1"));
|
||||
assertDifferent(col(1, "t1.name", null), col(1, "t1.name", "t1"));
|
||||
}
|
||||
|
||||
|
||||
@@ -55,4 +56,4 @@ public class ColumnTest {
|
||||
assertThat(key).isNotEqualTo(key1);
|
||||
assertThat(key.hashCode()).isNotEqualTo(key1.hashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ public class EbeanServer_eqlTest extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = server()
|
||||
.createNamedQuery(Customer.class, "withContacts")
|
||||
.setParameter("id", 1);
|
||||
.createNamedQuery(Customer.class, "withContacts")
|
||||
.setParameter("id", 1);
|
||||
|
||||
query.setUseCache(false);
|
||||
query.findUnique();
|
||||
@@ -112,12 +112,12 @@ public class EbeanServer_eqlTest extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = server()
|
||||
.createNamedQuery(Customer.class, "withContactsById")
|
||||
.setParameter("id", 1);
|
||||
.createNamedQuery(Customer.class, "withContactsById")
|
||||
.setParameter("id", 1);
|
||||
|
||||
query.setUseCache(false);
|
||||
query.findUnique();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("from o_customer t0 left join contact t1 on t1.customer_id = t0.id ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.avaje.ebean;
|
||||
|
||||
import com.avaje.tests.model.basic.EBasic;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import com.avaje.tests.model.basic.OrderDetail;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -22,7 +21,7 @@ public class EbeanServer_refresh {
|
||||
server.save(basic);
|
||||
|
||||
int rows =
|
||||
server.update(EBasic.class)
|
||||
server.update(EBasic.class)
|
||||
.set("status", EBasic.Status.ACTIVE)
|
||||
.where().idEq(basic.getId())
|
||||
.update();
|
||||
|
||||
@@ -29,7 +29,7 @@ public class EbeanServer_saveAllTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
for (EBasicVer someBean : someBeans) {
|
||||
someBean.setName(someBean.getName()+"-mod");
|
||||
someBean.setName(someBean.getName() + "-mod");
|
||||
}
|
||||
|
||||
// act
|
||||
@@ -113,11 +113,10 @@ public class EbeanServer_saveAllTest extends BaseTestCase {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<EBasicVer> beans(int count) {
|
||||
List<EBasicVer> beans = new ArrayList<>();
|
||||
for (int i = 0; i <count; i++) {
|
||||
beans.add(bean("foo"+i));
|
||||
for (int i = 0; i < count; i++) {
|
||||
beans.add(bean("foo" + i));
|
||||
}
|
||||
return beans;
|
||||
}
|
||||
@@ -125,4 +124,4 @@ public class EbeanServer_saveAllTest extends BaseTestCase {
|
||||
private EBasicVer bean(String name) {
|
||||
return new EBasicVer(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ package com.avaje.ebean;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
public class PropertyTest {
|
||||
|
||||
@@ -40,4 +41,4 @@ public class PropertyTest {
|
||||
return new OrderBy.Property(name, asc, nulls, highLow);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ public class RawSqlKeyTest {
|
||||
@Test
|
||||
public void equals_when_sameColumnMapping() {
|
||||
|
||||
RawSql.Key key = RawSqlBuilder.parse("select id from customer").columnMapping("id","b").create().getKey();
|
||||
RawSql.Key key1 = RawSqlBuilder.parse("select id from customer").columnMapping("id","b").create().getKey();
|
||||
RawSql.Key key = RawSqlBuilder.parse("select id from customer").columnMapping("id", "b").create().getKey();
|
||||
RawSql.Key key1 = RawSqlBuilder.parse("select id from customer").columnMapping("id", "b").create().getKey();
|
||||
|
||||
assertSame(key, key1);
|
||||
}
|
||||
@@ -37,8 +37,8 @@ public class RawSqlKeyTest {
|
||||
@Test
|
||||
public void equals_when_diffColumnMapping() {
|
||||
|
||||
RawSql.Key key = RawSqlBuilder.parse("select a from customer").columnMapping("a","b").create().getKey();
|
||||
RawSql.Key key1 = RawSqlBuilder.parse("select a from customer").columnMapping("a","c").create().getKey();
|
||||
RawSql.Key key = RawSqlBuilder.parse("select a from customer").columnMapping("a", "b").create().getKey();
|
||||
RawSql.Key key1 = RawSqlBuilder.parse("select a from customer").columnMapping("a", "c").create().getKey();
|
||||
|
||||
assertDifferent(key, key1);
|
||||
}
|
||||
@@ -46,8 +46,8 @@ public class RawSqlKeyTest {
|
||||
@Test
|
||||
public void equals_when_parseToUnpased() {
|
||||
|
||||
RawSql.Key key = RawSqlBuilder.parse("select a from customer").columnMapping("a","b").create().getKey();
|
||||
RawSql.Key key1 = RawSqlBuilder.unparsed("select a from customer").columnMapping("a","c").create().getKey();
|
||||
RawSql.Key key = RawSqlBuilder.parse("select a from customer").columnMapping("a", "b").create().getKey();
|
||||
RawSql.Key key1 = RawSqlBuilder.unparsed("select a from customer").columnMapping("a", "c").create().getKey();
|
||||
|
||||
assertDifferent(key, key1);
|
||||
}
|
||||
@@ -61,4 +61,4 @@ public class RawSqlKeyTest {
|
||||
assertThat(key).isNotEqualTo(key1);
|
||||
assertThat(key.hashCode()).isNotEqualTo(key1.hashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,88 +1,86 @@
|
||||
package com.avaje.ebean;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebean.bean.EntityBeanIntercept;
|
||||
import com.avaje.ebeaninternal.server.core.DefaultBeanState;
|
||||
import com.avaje.tests.model.embedded.EMain;
|
||||
import com.avaje.tests.model.embedded.Eembeddable;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class TestDirtyProperties extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void testEmbeddedUpdateEmbeddedProperty() {
|
||||
|
||||
|
||||
EMain emain = new EMain();
|
||||
|
||||
EntityBean eb = (EntityBean)emain;
|
||||
EntityBean eb = (EntityBean) emain;
|
||||
EntityBeanIntercept ebi = eb._ebean_getIntercept();
|
||||
|
||||
emain.setId(1);
|
||||
emain.setName("foo");
|
||||
Eembeddable embeddable = setEmbeddedBean(emain, "bar");
|
||||
setEmbeddedLoaded(embeddable);
|
||||
|
||||
|
||||
// sets loaded state so follow setters are deemed as changes to the bean
|
||||
ebi.setLoaded();
|
||||
|
||||
|
||||
emain.setName("changedFoo");
|
||||
|
||||
|
||||
DefaultBeanState beanState = new DefaultBeanState(eb);
|
||||
|
||||
|
||||
Set<String> changedProps = beanState.getChangedProps();
|
||||
Assert.assertEquals(1, changedProps.size());
|
||||
Assert.assertTrue(changedProps.contains("name"));
|
||||
|
||||
|
||||
Map<String, ValuePair> dirtyValues = beanState.getDirtyValues();
|
||||
Assert.assertEquals(1, dirtyValues.size());
|
||||
Assert.assertTrue(dirtyValues.keySet().contains("name"));
|
||||
|
||||
|
||||
ValuePair valuePair = dirtyValues.get("name");
|
||||
Assert.assertNotNull(valuePair);
|
||||
Assert.assertEquals("changedFoo",valuePair.getNewValue());
|
||||
Assert.assertEquals("foo",valuePair.getOldValue());
|
||||
|
||||
Assert.assertEquals("changedFoo", valuePair.getNewValue());
|
||||
Assert.assertEquals("foo", valuePair.getOldValue());
|
||||
|
||||
Eembeddable embeddableRead = emain.getEmbeddable();
|
||||
embeddableRead.setDescription("embChanged");
|
||||
|
||||
|
||||
Set<String> changedProps2 = beanState.getChangedProps();
|
||||
Assert.assertEquals(2, changedProps2.size());
|
||||
Assert.assertTrue(changedProps2.contains("name"));
|
||||
Assert.assertTrue(changedProps2.contains("embeddable.description"));
|
||||
|
||||
|
||||
Map<String, ValuePair> dirtyValues2 = beanState.getDirtyValues();
|
||||
Assert.assertEquals(2, dirtyValues2.size());
|
||||
Assert.assertTrue(dirtyValues2.keySet().contains("name"));
|
||||
Assert.assertTrue(dirtyValues2.keySet().contains("embeddable.description"));
|
||||
|
||||
ValuePair valuePair2 = dirtyValues2.get("embeddable.description");
|
||||
Assert.assertEquals("embChanged",valuePair2.getNewValue());
|
||||
Assert.assertEquals("bar",valuePair2.getOldValue());
|
||||
}
|
||||
|
||||
ValuePair valuePair2 = dirtyValues2.get("embeddable.description");
|
||||
Assert.assertEquals("embChanged", valuePair2.getNewValue());
|
||||
Assert.assertEquals("bar", valuePair2.getOldValue());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEmbeddedUpdateSetNewBean() {
|
||||
|
||||
|
||||
EMain emain = new EMain();
|
||||
|
||||
EntityBean eb = (EntityBean)emain;
|
||||
EntityBean eb = (EntityBean) emain;
|
||||
EntityBeanIntercept ebi = eb._ebean_getIntercept();
|
||||
|
||||
emain.setId(1);
|
||||
emain.setName("foo");
|
||||
Eembeddable embeddable = setEmbeddedBean(emain, "bar");
|
||||
setEmbeddedLoaded(embeddable);
|
||||
|
||||
|
||||
// sets loaded state so follow setters are deemed as changes to the bean
|
||||
ebi.setLoaded();
|
||||
|
||||
|
||||
emain.setName("changedFoo");
|
||||
|
||||
Assert.assertSame(embeddable, emain.getEmbeddable());
|
||||
@@ -90,48 +88,48 @@ public class TestDirtyProperties extends BaseTestCase {
|
||||
Eembeddable embeddable2 = setEmbeddedBean(emain, "changeEmbeddedInstance");
|
||||
Assert.assertSame(embeddable2, emain.getEmbeddable());
|
||||
Assert.assertNotSame(embeddable, emain.getEmbeddable());
|
||||
|
||||
|
||||
|
||||
|
||||
DefaultBeanState beanState = new DefaultBeanState(eb);
|
||||
|
||||
|
||||
Set<String> changedProps2 = beanState.getChangedProps();
|
||||
Assert.assertEquals(2, changedProps2.size());
|
||||
Assert.assertTrue(changedProps2.contains("name"));
|
||||
|
||||
|
||||
Assert.assertTrue("The whole bean instance has changed", changedProps2.contains("embeddable"));
|
||||
|
||||
|
||||
Map<String, ValuePair> dirtyValues2 = beanState.getDirtyValues();
|
||||
Assert.assertEquals(2, dirtyValues2.size());
|
||||
Assert.assertTrue(dirtyValues2.keySet().contains("name"));
|
||||
Assert.assertTrue(dirtyValues2.keySet().contains("embeddable"));
|
||||
|
||||
|
||||
|
||||
|
||||
ValuePair valuePair2 = dirtyValues2.get("embeddable");
|
||||
Assert.assertSame(embeddable2, valuePair2.getNewValue());
|
||||
Assert.assertSame(embeddable, valuePair2.getOldValue());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void setEmbeddedLoaded(Eembeddable embeddable) {
|
||||
((EntityBean)embeddable)._ebean_getIntercept().setLoaded();
|
||||
((EntityBean) embeddable)._ebean_getIntercept().setLoaded();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Eembeddable setEmbeddedBean(EMain emain, String description) {
|
||||
|
||||
|
||||
Eembeddable embeddable = new Eembeddable();
|
||||
embeddable.setDescription(description);
|
||||
|
||||
|
||||
emain.setEmbeddable(embeddable);
|
||||
|
||||
EntityBean owner = (EntityBean)emain;
|
||||
EntityBeanIntercept ebi= owner._ebean_getIntercept();
|
||||
|
||||
|
||||
EntityBean owner = (EntityBean) emain;
|
||||
EntityBeanIntercept ebi = owner._ebean_getIntercept();
|
||||
|
||||
// hooks the embeddable bean back to the owner
|
||||
int embeddablePropertyIndex = ebi.findProperty("embeddable");
|
||||
Assert.assertTrue(embeddablePropertyIndex > -1);
|
||||
((EntityBean)embeddable)._ebean_getIntercept().setEmbeddedOwner(owner, embeddablePropertyIndex);
|
||||
((EntityBean) embeddable)._ebean_getIntercept().setEmbeddedOwner(owner, embeddablePropertyIndex);
|
||||
return embeddable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.avaje.ebean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TestFilterWithEnum extends BaseTestCase {
|
||||
|
||||
|
||||
@@ -1,50 +1,49 @@
|
||||
package com.avaje.ebean;
|
||||
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
|
||||
public class TestPropertyChangeListener extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
|
||||
List<Customer> list = Ebean.find(Customer.class).findList();
|
||||
|
||||
|
||||
Listener listener = new Listener();
|
||||
|
||||
|
||||
Customer customer = list.get(0);
|
||||
Ebean.getBeanState(customer).addPropertyChangeListener(listener);
|
||||
|
||||
|
||||
customer.setName("modName");
|
||||
customer.setSmallnote("modSmallNote");
|
||||
|
||||
|
||||
Assert.assertEquals(2, listener.events.size());
|
||||
Assert.assertEquals("modName", listener.events.get(0).getNewValue());
|
||||
Assert.assertEquals("name", listener.events.get(0).getPropertyName());
|
||||
Assert.assertEquals("modSmallNote", listener.events.get(1).getNewValue());
|
||||
Assert.assertEquals("smallnote", listener.events.get(1).getPropertyName());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class Listener implements PropertyChangeListener {
|
||||
|
||||
List<PropertyChangeEvent> events = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
events.add(evt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.avaje.ebean;
|
||||
|
||||
import com.avaje.ebean.RawSql.Sql;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import com.avaje.tests.model.rawsql.ERawSqlAggBean;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.RawSql.Sql;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
@@ -50,8 +49,8 @@ public class TestRawSqlBuilder extends BaseTestCase {
|
||||
RawSql rawSql = r.create();
|
||||
|
||||
Ebean.find(Customer.class)
|
||||
.setRawSql(rawSql)
|
||||
.findList();
|
||||
.setRawSql(rawSql)
|
||||
.findList();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,7 +83,7 @@ public class TestRawSqlBuilder extends BaseTestCase {
|
||||
assertEquals("id desc", sql.getOrderBy());
|
||||
|
||||
r = RawSqlBuilder
|
||||
.parse("select id, sum(x) from t_cust where id > ? group by id order by id desc");
|
||||
.parse("select id, sum(x) from t_cust where id > ? group by id order by id desc");
|
||||
sql = r.getSql();
|
||||
assertEquals("id, sum(x)", sql.getPreFrom());
|
||||
assertEquals("from t_cust where id > ?", sql.getPreWhere());
|
||||
@@ -96,7 +95,7 @@ public class TestRawSqlBuilder extends BaseTestCase {
|
||||
public void testWithHaving() {
|
||||
|
||||
RawSqlBuilder r = RawSqlBuilder
|
||||
.parse("select id, sum(x) from t_cust where id > ? group by id having sum(x) > ? order by id desc");
|
||||
.parse("select id, sum(x) from t_cust where id > ? group by id having sum(x) > ? order by id desc");
|
||||
Sql sql = r.getSql();
|
||||
assertEquals("id, sum(x)", sql.getPreFrom());
|
||||
assertEquals("from t_cust where id > ?", sql.getPreWhere());
|
||||
@@ -106,7 +105,7 @@ public class TestRawSqlBuilder extends BaseTestCase {
|
||||
|
||||
// no where
|
||||
r = RawSqlBuilder
|
||||
.parse("select id, sum(x) from t_cust group by id having sum(x) > ? order by id desc");
|
||||
.parse("select id, sum(x) from t_cust group by id having sum(x) > ? order by id desc");
|
||||
sql = r.getSql();
|
||||
assertEquals("id, sum(x)", sql.getPreFrom());
|
||||
assertEquals("from t_cust", sql.getPreWhere());
|
||||
@@ -125,7 +124,7 @@ public class TestRawSqlBuilder extends BaseTestCase {
|
||||
|
||||
// no order by
|
||||
r = RawSqlBuilder
|
||||
.parse("select id, sum(x) from t_cust where id > ? group by id having sum(x) > ?");
|
||||
.parse("select id, sum(x) from t_cust where id > ? group by id having sum(x) > ?");
|
||||
sql = r.getSql();
|
||||
assertEquals("id, sum(x)", sql.getPreFrom());
|
||||
assertEquals("from t_cust where id > ?", sql.getPreWhere());
|
||||
@@ -140,7 +139,7 @@ public class TestRawSqlBuilder extends BaseTestCase {
|
||||
@Test
|
||||
public void testWithOrderSiblingsByName() {
|
||||
|
||||
String s = "SELECT ID, DESCRIPTION, NAME, PARENT_ID FROM SOME_TABLE WHERE lower(NAME) like :name START WITH ID = :parentId CONNECT BY PRIOR ID = PARENT_ID order siblings by NAME";
|
||||
String s = "SELECT ID, DESCRIPTION, NAME, PARENT_ID FROM SOME_TABLE WHERE lower(NAME) like :name START WITH ID = :parentId CONNECT BY PRIOR ID = PARENT_ID order siblings by NAME";
|
||||
|
||||
RawSql rawSql = RawSqlBuilder.parse(s).create();
|
||||
|
||||
@@ -153,24 +152,23 @@ public class TestRawSqlBuilder extends BaseTestCase {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testWithAlias() {
|
||||
|
||||
String rs = "select o.id, o.status, c.id, c.name, "+
|
||||
" d.id, d.order_qty, p.id, p.name " +
|
||||
"from o_order o join o_customer c on c.id = o.kcustomer_id " +
|
||||
"join o_order_detail d on d.order_id = o.id " +
|
||||
"join o_product p on p.id = d.product_id " +
|
||||
"where o.id <= :maxOrderId and p.id = :productId "+
|
||||
"order by o.id, d.id asc";
|
||||
String rs = "select o.id, o.status, c.id, c.name, " +
|
||||
" d.id, d.order_qty, p.id, p.name " +
|
||||
"from o_order o join o_customer c on c.id = o.kcustomer_id " +
|
||||
"join o_order_detail d on d.order_id = o.id " +
|
||||
"join o_product p on p.id = d.product_id " +
|
||||
"where o.id <= :maxOrderId and p.id = :productId " +
|
||||
"order by o.id, d.id asc";
|
||||
|
||||
|
||||
RawSql rawSql = RawSqlBuilder.parse(rs)
|
||||
.tableAliasMapping("c", "customer")
|
||||
.tableAliasMapping("d", "details")
|
||||
.tableAliasMapping("p", "details.product")
|
||||
.create();
|
||||
.tableAliasMapping("c", "customer")
|
||||
.tableAliasMapping("d", "details")
|
||||
.tableAliasMapping("p", "details.product")
|
||||
.create();
|
||||
|
||||
RawSql.ColumnMapping columnMapping = rawSql.getColumnMapping();
|
||||
assertEquals(0, columnMapping.getIndexPosition("id"));
|
||||
@@ -187,12 +185,12 @@ public class TestRawSqlBuilder extends BaseTestCase {
|
||||
@Test
|
||||
public void testWithCoalesceFunction() {
|
||||
|
||||
String rs = "select id, coalesce(status,'E') as status, "+
|
||||
" budgets.amount as budget," +
|
||||
" COALESCE(month_sums.sum,0.0) as transaction_sum, " +
|
||||
" COALESCE(month_balances.balance,0.0) as balance, " +
|
||||
" COALESCE(month_sums.end_date,date_trunc('month',budgets.month),month_balances.end_date) as data_month"+
|
||||
" from o_order order by id asc";
|
||||
String rs = "select id, coalesce(status,'E') as status, " +
|
||||
" budgets.amount as budget," +
|
||||
" COALESCE(month_sums.sum,0.0) as transaction_sum, " +
|
||||
" COALESCE(month_balances.balance,0.0) as balance, " +
|
||||
" COALESCE(month_sums.end_date,date_trunc('month',budgets.month),month_balances.end_date) as data_month" +
|
||||
" from o_order order by id asc";
|
||||
|
||||
RawSqlBuilder builder = RawSqlBuilder.parse(rs);
|
||||
|
||||
@@ -217,11 +215,11 @@ public class TestRawSqlBuilder extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
String sql = "select DATE_TRUNC('DAY', d.order_date) as day," +
|
||||
" count(*) as total," +
|
||||
" sum(case when d.status = 0 then 2 else 3 end) as scheduled," +
|
||||
" sum(case when d.status = 1 then 1 else 0 end) as completed" +
|
||||
" from o_order d" +
|
||||
" group by DATE_TRUNC('DAY', d.order_date)";
|
||||
" count(*) as total," +
|
||||
" sum(case when d.status = 0 then 2 else 3 end) as scheduled," +
|
||||
" sum(case when d.status = 1 then 1 else 0 end) as completed" +
|
||||
" from o_order d" +
|
||||
" group by DATE_TRUNC('DAY', d.order_date)";
|
||||
|
||||
RawSql rawSql = RawSqlBuilder.parse(sql).create();
|
||||
|
||||
@@ -233,9 +231,9 @@ public class TestRawSqlBuilder extends BaseTestCase {
|
||||
assertEquals(3, columnMapping.getIndexPosition("completed"));
|
||||
|
||||
Query<ERawSqlAggBean> query = Ebean.find(ERawSqlAggBean.class)
|
||||
.setRawSql(rawSql)
|
||||
.having().gt("total", 2)
|
||||
.query();
|
||||
.setRawSql(rawSql)
|
||||
.having().gt("total", 2)
|
||||
.query();
|
||||
|
||||
|
||||
query.findList();
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.avaje.ebean;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.avaje.ebean.RawSql.Sql;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Assert;
|
||||
|
||||
public class TestRawSqlBuilderDistinct extends TestCase {
|
||||
|
||||
|
||||
@@ -1,164 +1,163 @@
|
||||
package com.avaje.ebean;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.avaje.ebean.RawSql.ColumnMapping;
|
||||
import com.avaje.ebean.RawSql.ColumnMapping.Column;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class TestRawSqlColumnParsing extends TestCase {
|
||||
|
||||
public void test_simple() {
|
||||
|
||||
ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a,b,c");
|
||||
Map<String, Column> mapping = columnMapping.mapping();
|
||||
Column c = mapping.get("a");
|
||||
|
||||
assertEquals("a",c.getDbColumn());
|
||||
assertEquals(0, c.getIndexPos());
|
||||
assertEquals("a",c.getPropertyName());
|
||||
public void test_simple() {
|
||||
|
||||
c = mapping.get("b");
|
||||
assertEquals("b",c.getDbColumn());
|
||||
assertEquals(1, c.getIndexPos());
|
||||
assertEquals("b",c.getPropertyName());
|
||||
ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a,b,c");
|
||||
Map<String, Column> mapping = columnMapping.mapping();
|
||||
Column c = mapping.get("a");
|
||||
|
||||
c = mapping.get("c");
|
||||
assertEquals("c",c.getDbColumn());
|
||||
assertEquals(2, c.getIndexPos());
|
||||
assertEquals("c",c.getPropertyName());
|
||||
assertEquals("a", c.getDbColumn());
|
||||
assertEquals(0, c.getIndexPos());
|
||||
assertEquals("a", c.getPropertyName());
|
||||
|
||||
}
|
||||
c = mapping.get("b");
|
||||
assertEquals("b", c.getDbColumn());
|
||||
assertEquals(1, c.getIndexPos());
|
||||
assertEquals("b", c.getPropertyName());
|
||||
|
||||
public void test_simpleWithSpacing() {
|
||||
|
||||
ColumnMapping columnMapping = DRawSqlColumnsParser.parse(" a , b , c ");
|
||||
Map<String, Column> mapping = columnMapping.mapping();
|
||||
Column c = mapping.get("a");
|
||||
|
||||
assertEquals("a",c.getDbColumn());
|
||||
assertEquals(0, c.getIndexPos());
|
||||
assertEquals("a", c.getPropertyName());
|
||||
c = mapping.get("c");
|
||||
assertEquals("c", c.getDbColumn());
|
||||
assertEquals(2, c.getIndexPos());
|
||||
assertEquals("c", c.getPropertyName());
|
||||
|
||||
c = mapping.get("b");
|
||||
assertEquals("b",c.getDbColumn());
|
||||
assertEquals(1, c.getIndexPos());
|
||||
assertEquals("b",c.getPropertyName());
|
||||
}
|
||||
|
||||
c = mapping.get("c");
|
||||
assertEquals("c",c.getDbColumn());
|
||||
assertEquals(2, c.getIndexPos());
|
||||
assertEquals("c",c.getPropertyName());
|
||||
public void test_simpleWithSpacing() {
|
||||
|
||||
}
|
||||
|
||||
public void test_withAlias() {
|
||||
|
||||
ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a a0,b b1, c c2 , d d3 , e e4 ");
|
||||
Map<String, Column> mapping = columnMapping.mapping();
|
||||
|
||||
assertEquals(5, mapping.size());
|
||||
|
||||
Column c = mapping.get("a0");
|
||||
|
||||
assertEquals("a",c.getDbColumn());
|
||||
assertEquals(0, c.getIndexPos());
|
||||
assertEquals("a0",c.getPropertyName());
|
||||
ColumnMapping columnMapping = DRawSqlColumnsParser.parse(" a , b , c ");
|
||||
Map<String, Column> mapping = columnMapping.mapping();
|
||||
Column c = mapping.get("a");
|
||||
|
||||
c = mapping.get("b1");
|
||||
assertEquals("b",c.getDbColumn());
|
||||
assertEquals(1, c.getIndexPos());
|
||||
assertEquals("b1",c.getPropertyName());
|
||||
assertEquals("a", c.getDbColumn());
|
||||
assertEquals(0, c.getIndexPos());
|
||||
assertEquals("a", c.getPropertyName());
|
||||
|
||||
c = mapping.get("c2");
|
||||
assertEquals("c",c.getDbColumn());
|
||||
assertEquals(2, c.getIndexPos());
|
||||
assertEquals("c2",c.getPropertyName());
|
||||
c = mapping.get("b");
|
||||
assertEquals("b", c.getDbColumn());
|
||||
assertEquals(1, c.getIndexPos());
|
||||
assertEquals("b", c.getPropertyName());
|
||||
|
||||
c = mapping.get("d3");
|
||||
assertEquals("d",c.getDbColumn());
|
||||
assertEquals(3, c.getIndexPos());
|
||||
assertEquals("d3",c.getPropertyName());
|
||||
c = mapping.get("c");
|
||||
assertEquals("c", c.getDbColumn());
|
||||
assertEquals(2, c.getIndexPos());
|
||||
assertEquals("c", c.getPropertyName());
|
||||
|
||||
|
||||
c = mapping.get("e4");
|
||||
assertEquals("e",c.getDbColumn());
|
||||
assertEquals(4, c.getIndexPos());
|
||||
assertEquals("e4",c.getPropertyName());
|
||||
}
|
||||
|
||||
}
|
||||
public void test_withAlias() {
|
||||
|
||||
public void test_withDatabaseFunction() {
|
||||
ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a a0,b b1, c c2 , d d3 , e e4 ");
|
||||
Map<String, Column> mapping = columnMapping.mapping();
|
||||
|
||||
ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a a0,b b1, MONTH(MAKEDATE(2015, 241)) m2 , d d3 , e e4 ");
|
||||
Map<String, Column> mapping = columnMapping.mapping();
|
||||
assertEquals(5, mapping.size());
|
||||
|
||||
assertEquals(5, mapping.size());
|
||||
Column c = mapping.get("a0");
|
||||
|
||||
Column c = mapping.get("a0");
|
||||
assertEquals("a", c.getDbColumn());
|
||||
assertEquals(0, c.getIndexPos());
|
||||
assertEquals("a0", c.getPropertyName());
|
||||
|
||||
assertEquals("a",c.getDbColumn());
|
||||
assertEquals(0, c.getIndexPos());
|
||||
assertEquals("a0",c.getPropertyName());
|
||||
c = mapping.get("b1");
|
||||
assertEquals("b", c.getDbColumn());
|
||||
assertEquals(1, c.getIndexPos());
|
||||
assertEquals("b1", c.getPropertyName());
|
||||
|
||||
c = mapping.get("b1");
|
||||
assertEquals("b",c.getDbColumn());
|
||||
assertEquals(1, c.getIndexPos());
|
||||
assertEquals("b1",c.getPropertyName());
|
||||
c = mapping.get("c2");
|
||||
assertEquals("c", c.getDbColumn());
|
||||
assertEquals(2, c.getIndexPos());
|
||||
assertEquals("c2", c.getPropertyName());
|
||||
|
||||
c = mapping.get("m2");
|
||||
assertEquals("MONTH(MAKEDATE(2015, 241))",c.getDbColumn());
|
||||
assertEquals(2, c.getIndexPos());
|
||||
assertEquals("m2",c.getPropertyName());
|
||||
|
||||
c = mapping.get("d3");
|
||||
assertEquals("d",c.getDbColumn());
|
||||
assertEquals(3, c.getIndexPos());
|
||||
assertEquals("d3",c.getPropertyName());
|
||||
c = mapping.get("d3");
|
||||
assertEquals("d", c.getDbColumn());
|
||||
assertEquals(3, c.getIndexPos());
|
||||
assertEquals("d3", c.getPropertyName());
|
||||
|
||||
|
||||
c = mapping.get("e4");
|
||||
assertEquals("e",c.getDbColumn());
|
||||
assertEquals(4, c.getIndexPos());
|
||||
assertEquals("e4",c.getPropertyName());
|
||||
c = mapping.get("e4");
|
||||
assertEquals("e", c.getDbColumn());
|
||||
assertEquals(4, c.getIndexPos());
|
||||
assertEquals("e4", c.getPropertyName());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void test_withAsAlias() {
|
||||
|
||||
ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a as a0,'b' b1, \"c(blah)\" as c2 , d as d3 , e as e4 ");
|
||||
Map<String, Column> mapping = columnMapping.mapping();
|
||||
|
||||
assertEquals(5, mapping.size());
|
||||
|
||||
Column c = mapping.get("a0");
|
||||
|
||||
assertEquals("a",c.getDbColumn());
|
||||
assertEquals(0, c.getIndexPos());
|
||||
assertEquals("a0",c.getPropertyName());
|
||||
public void test_withDatabaseFunction() {
|
||||
|
||||
c = mapping.get("b1");
|
||||
assertEquals("'b'",c.getDbColumn());
|
||||
assertEquals(1, c.getIndexPos());
|
||||
assertEquals("b1",c.getPropertyName());
|
||||
ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a a0,b b1, MONTH(MAKEDATE(2015, 241)) m2 , d d3 , e e4 ");
|
||||
Map<String, Column> mapping = columnMapping.mapping();
|
||||
|
||||
c = mapping.get("c2");
|
||||
assertEquals("\"c(blah)\"",c.getDbColumn());
|
||||
assertEquals(2, c.getIndexPos());
|
||||
assertEquals("c2",c.getPropertyName());
|
||||
assertEquals(5, mapping.size());
|
||||
|
||||
c = mapping.get("d3");
|
||||
assertEquals("d",c.getDbColumn());
|
||||
assertEquals(3, c.getIndexPos());
|
||||
assertEquals("d3",c.getPropertyName());
|
||||
Column c = mapping.get("a0");
|
||||
|
||||
|
||||
c = mapping.get("e4");
|
||||
assertEquals("e",c.getDbColumn());
|
||||
assertEquals(4, c.getIndexPos());
|
||||
assertEquals("e4",c.getPropertyName());
|
||||
assertEquals("a", c.getDbColumn());
|
||||
assertEquals(0, c.getIndexPos());
|
||||
assertEquals("a0", c.getPropertyName());
|
||||
|
||||
}
|
||||
c = mapping.get("b1");
|
||||
assertEquals("b", c.getDbColumn());
|
||||
assertEquals(1, c.getIndexPos());
|
||||
assertEquals("b1", c.getPropertyName());
|
||||
|
||||
c = mapping.get("m2");
|
||||
assertEquals("MONTH(MAKEDATE(2015, 241))", c.getDbColumn());
|
||||
assertEquals(2, c.getIndexPos());
|
||||
assertEquals("m2", c.getPropertyName());
|
||||
|
||||
c = mapping.get("d3");
|
||||
assertEquals("d", c.getDbColumn());
|
||||
assertEquals(3, c.getIndexPos());
|
||||
assertEquals("d3", c.getPropertyName());
|
||||
|
||||
|
||||
c = mapping.get("e4");
|
||||
assertEquals("e", c.getDbColumn());
|
||||
assertEquals(4, c.getIndexPos());
|
||||
assertEquals("e4", c.getPropertyName());
|
||||
|
||||
}
|
||||
|
||||
public void test_withAsAlias() {
|
||||
|
||||
ColumnMapping columnMapping = DRawSqlColumnsParser.parse("a as a0,'b' b1, \"c(blah)\" as c2 , d as d3 , e as e4 ");
|
||||
Map<String, Column> mapping = columnMapping.mapping();
|
||||
|
||||
assertEquals(5, mapping.size());
|
||||
|
||||
Column c = mapping.get("a0");
|
||||
|
||||
assertEquals("a", c.getDbColumn());
|
||||
assertEquals(0, c.getIndexPos());
|
||||
assertEquals("a0", c.getPropertyName());
|
||||
|
||||
c = mapping.get("b1");
|
||||
assertEquals("'b'", c.getDbColumn());
|
||||
assertEquals(1, c.getIndexPos());
|
||||
assertEquals("b1", c.getPropertyName());
|
||||
|
||||
c = mapping.get("c2");
|
||||
assertEquals("\"c(blah)\"", c.getDbColumn());
|
||||
assertEquals(2, c.getIndexPos());
|
||||
assertEquals("c2", c.getPropertyName());
|
||||
|
||||
c = mapping.get("d3");
|
||||
assertEquals("d", c.getDbColumn());
|
||||
assertEquals(3, c.getIndexPos());
|
||||
assertEquals("d3", c.getPropertyName());
|
||||
|
||||
|
||||
c = mapping.get("e4");
|
||||
assertEquals("e", c.getDbColumn());
|
||||
assertEquals(4, c.getIndexPos());
|
||||
assertEquals("e4", c.getPropertyName());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class TestUnsetLoadedProperties extends BaseTestCase {
|
||||
assertThat(beanState.getLoadedProps()).containsExactly("id", "name", "email");
|
||||
|
||||
// unset the loaded state for email
|
||||
((EntityBean)user)._ebean_getIntercept().setPropertyLoaded("email", false);
|
||||
((EntityBean) user)._ebean_getIntercept().setPropertyLoaded("email", false);
|
||||
|
||||
assertThat(beanState.getLoadedProps()).containsExactly("id", "name");
|
||||
}
|
||||
|
||||
@@ -12,51 +12,51 @@ public class TextExpressionListTest {
|
||||
public void syntax() {
|
||||
|
||||
Ebean.find(Order.class)
|
||||
.text().match("name", "rob");
|
||||
.text().match("name", "rob");
|
||||
|
||||
|
||||
Ebean.find(Order.class)
|
||||
.text().should()
|
||||
.match("name", "rob")
|
||||
.match("note", "war and peace");
|
||||
.text().should()
|
||||
.match("name", "rob")
|
||||
.match("note", "war and peace");
|
||||
|
||||
|
||||
Ebean.find(Order.class)
|
||||
.text()
|
||||
.should()
|
||||
.match("title", "war and peace")
|
||||
.match("author", "leo tolstoy")
|
||||
.should()
|
||||
.match("translator", "Constance Garnett")
|
||||
.match("translator", "Louise Maude");
|
||||
.text()
|
||||
.should()
|
||||
.match("title", "war and peace")
|
||||
.match("author", "leo tolstoy")
|
||||
.should()
|
||||
.match("translator", "Constance Garnett")
|
||||
.match("translator", "Louise Maude");
|
||||
|
||||
|
||||
Ebean.find(Order.class)
|
||||
.text()
|
||||
.should()
|
||||
.match("title", "war and peace")
|
||||
.match("author", "leo tolstoy")
|
||||
.should()
|
||||
.match("translator", "Constance Garnett", new Match().opAnd().boost(2).minShouldMatch("75%"))
|
||||
.match("translator", "Louise Maude")
|
||||
.where()
|
||||
.gt("reviewDate", 12345);
|
||||
.text()
|
||||
.should()
|
||||
.match("title", "war and peace")
|
||||
.match("author", "leo tolstoy")
|
||||
.should()
|
||||
.match("translator", "Constance Garnett", new Match().opAnd().boost(2).minShouldMatch("75%"))
|
||||
.match("translator", "Louise Maude")
|
||||
.where()
|
||||
.gt("reviewDate", 12345);
|
||||
|
||||
|
||||
Ebean.find(Order.class)
|
||||
.text()
|
||||
.must()
|
||||
.match("title", "quick")
|
||||
.endJunction()
|
||||
.should()
|
||||
.match("title", "brown")
|
||||
.match("title", "dog")
|
||||
.endJunction()
|
||||
.mustNot()
|
||||
.match("title", "lazy")
|
||||
.endJunction()
|
||||
.where()
|
||||
.gt("reviewDate", 12345);
|
||||
.text()
|
||||
.must()
|
||||
.match("title", "quick")
|
||||
.endJunction()
|
||||
.should()
|
||||
.match("title", "brown")
|
||||
.match("title", "dog")
|
||||
.endJunction()
|
||||
.mustNot()
|
||||
.match("title", "lazy")
|
||||
.endJunction()
|
||||
.where()
|
||||
.gt("reviewDate", 12345);
|
||||
|
||||
|
||||
}
|
||||
@@ -65,16 +65,16 @@ public class TextExpressionListTest {
|
||||
public void syntax_multiMatch() {
|
||||
|
||||
Ebean.find(Order.class)
|
||||
.text()
|
||||
.multiMatch("Will Smith", "title", "*name");
|
||||
.text()
|
||||
.multiMatch("Will Smith", "title", "*name");
|
||||
|
||||
MultiMatch match = MultiMatch.fields("title", "*name")
|
||||
.opAnd()
|
||||
.type(MultiMatch.Type.PHRASE_PREFIX);
|
||||
.opAnd()
|
||||
.type(MultiMatch.Type.PHRASE_PREFIX);
|
||||
|
||||
Ebean.find(Order.class)
|
||||
.text()
|
||||
.multiMatch("Will Smith", match);
|
||||
.text()
|
||||
.multiMatch("Will Smith", match);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@ package com.avaje.ebean;
|
||||
import com.avaje.ebean.config.PersistBatch;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TxScopeTest {
|
||||
|
||||
@@ -64,4 +65,4 @@ public class TxScopeTest {
|
||||
assertNull(scope.getBatch());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ public class UpdateQueryTest extends BaseTestCase {
|
||||
EbeanServer server = server();
|
||||
UpdateQuery<Customer> update = server.update(Customer.class);
|
||||
Query<Customer> query = update
|
||||
.set("status", Customer.Status.ACTIVE)
|
||||
.set("updtime", new Timestamp(System.currentTimeMillis()))
|
||||
.where()
|
||||
.eq("status", Customer.Status.NEW)
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
.set("status", Customer.Status.ACTIVE)
|
||||
.set("updtime", new Timestamp(System.currentTimeMillis()))
|
||||
.where()
|
||||
.eq("status", Customer.Status.NEW)
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
|
||||
query.update();
|
||||
|
||||
@@ -42,14 +42,14 @@ public class UpdateQueryTest extends BaseTestCase {
|
||||
|
||||
UpdateQuery<Customer> update = server.update(Customer.class);
|
||||
Query<Customer> query = update
|
||||
.set("status", Customer.Status.ACTIVE)
|
||||
.set("updtime", new Timestamp(System.currentTimeMillis()))
|
||||
.where()
|
||||
.eq("status", Customer.Status.NEW)
|
||||
.eq("billingAddress.country", nz)
|
||||
//.isEmpty("contacts")
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
.set("status", Customer.Status.ACTIVE)
|
||||
.set("updtime", new Timestamp(System.currentTimeMillis()))
|
||||
.where()
|
||||
.eq("status", Customer.Status.NEW)
|
||||
.eq("billingAddress.country", nz)
|
||||
//.isEmpty("contacts")
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
|
||||
query.update();
|
||||
|
||||
@@ -62,12 +62,12 @@ public class UpdateQueryTest extends BaseTestCase {
|
||||
EbeanServer server = server();
|
||||
|
||||
Query<Customer> updateQuery = server
|
||||
.update(Customer.class)
|
||||
.set("status", Customer.Status.ACTIVE)
|
||||
.where()
|
||||
.isEmpty("contacts")
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
.update(Customer.class)
|
||||
.set("status", Customer.Status.ACTIVE)
|
||||
.where()
|
||||
.isEmpty("contacts")
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
|
||||
updateQuery.update();
|
||||
|
||||
@@ -80,11 +80,11 @@ public class UpdateQueryTest extends BaseTestCase {
|
||||
EbeanServer server = server();
|
||||
|
||||
Query<Customer> updateQuery = server
|
||||
.update(Customer.class)
|
||||
.setNull("status")
|
||||
.where()
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
.update(Customer.class)
|
||||
.setNull("status")
|
||||
.where()
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
|
||||
updateQuery.update();
|
||||
|
||||
@@ -97,11 +97,11 @@ public class UpdateQueryTest extends BaseTestCase {
|
||||
EbeanServer server = server();
|
||||
|
||||
Query<Customer> updateQuery = server
|
||||
.update(Customer.class)
|
||||
.set("status", null)
|
||||
.where()
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
.update(Customer.class)
|
||||
.set("status", null)
|
||||
.where()
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
|
||||
updateQuery.update();
|
||||
|
||||
@@ -114,11 +114,11 @@ public class UpdateQueryTest extends BaseTestCase {
|
||||
EbeanServer server = server();
|
||||
|
||||
Query<Customer> updateQuery = server
|
||||
.update(Customer.class)
|
||||
.setRaw("status = coalesce(status, 'A')")
|
||||
.where()
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
.update(Customer.class)
|
||||
.setRaw("status = coalesce(status, 'A')")
|
||||
.where()
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
|
||||
updateQuery.update();
|
||||
|
||||
@@ -131,11 +131,11 @@ public class UpdateQueryTest extends BaseTestCase {
|
||||
EbeanServer server = server();
|
||||
|
||||
Query<Customer> updateQuery = server
|
||||
.update(Customer.class)
|
||||
.setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE)
|
||||
.where()
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
.update(Customer.class)
|
||||
.setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE)
|
||||
.where()
|
||||
.gt("id", 1000)
|
||||
.query();
|
||||
|
||||
updateQuery.update();
|
||||
|
||||
@@ -148,11 +148,11 @@ public class UpdateQueryTest extends BaseTestCase {
|
||||
EbeanServer server = server();
|
||||
|
||||
int rows = server
|
||||
.update(Customer.class)
|
||||
.setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE)
|
||||
.where()
|
||||
.gt("id", 10000)
|
||||
.update();
|
||||
.update(Customer.class)
|
||||
.setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE)
|
||||
.where()
|
||||
.gt("id", 10000)
|
||||
.update();
|
||||
|
||||
assertThat(rows).isEqualTo(0);
|
||||
}
|
||||
@@ -161,11 +161,11 @@ public class UpdateQueryTest extends BaseTestCase {
|
||||
public void useViaEbean() {
|
||||
|
||||
int rows = Ebean.update(Customer.class)
|
||||
.setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE)
|
||||
.where()
|
||||
.gt("id", 10000)
|
||||
.update();
|
||||
.setRaw("status = coalesce(status, ?)", Customer.Status.ACTIVE)
|
||||
.where()
|
||||
.gt("id", 10000)
|
||||
.update();
|
||||
|
||||
assertThat(rows).isEqualTo(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class EntityBeanInterceptTest extends BaseTestCase {
|
||||
|
||||
|
||||
Customer customer = list.get(0);
|
||||
EntityBeanIntercept ebi = ((EntityBean)customer)._ebean_getIntercept();
|
||||
EntityBeanIntercept ebi = ((EntityBean) customer)._ebean_getIntercept();
|
||||
|
||||
assertFalse(ebi.hasDirtyProperty(propertyNames));
|
||||
|
||||
@@ -76,4 +76,4 @@ public class EntityBeanInterceptTest extends BaseTestCase {
|
||||
assertThat(ebi.isPartial()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.junit.Test;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class BeanListTest {
|
||||
@@ -270,7 +270,7 @@ public class BeanListTest {
|
||||
return true;
|
||||
}
|
||||
if (other instanceof SomeBean) {
|
||||
return this.val.equals(((SomeBean)other).val);
|
||||
return this.val.equals(((SomeBean) other).val);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class BeanMapTest {
|
||||
@Test
|
||||
public void testAdd() throws Exception {
|
||||
|
||||
BeanMap<String,Object> map = new BeanMap<>();
|
||||
BeanMap<String, Object> map = new BeanMap<>();
|
||||
map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
|
||||
map.put("1", object1);
|
||||
map.put("4", null);
|
||||
@@ -59,7 +59,7 @@ public class BeanMapTest {
|
||||
@Test
|
||||
public void testAddAll_given_emptyStart() throws Exception {
|
||||
|
||||
BeanMap<String,Object> set = new BeanMap<>();
|
||||
BeanMap<String, Object> set = new BeanMap<>();
|
||||
set.setModifyListening(BeanCollection.ModifyListenMode.ALL);
|
||||
|
||||
// act
|
||||
@@ -72,7 +72,7 @@ public class BeanMapTest {
|
||||
@Test
|
||||
public void testAdd_given_someAlreadyIn() throws Exception {
|
||||
|
||||
BeanMap<String,Object> map = new BeanMap<>(some());
|
||||
BeanMap<String, Object> map = new BeanMap<>(some());
|
||||
map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
|
||||
|
||||
// act
|
||||
@@ -88,7 +88,7 @@ public class BeanMapTest {
|
||||
@Test
|
||||
public void testAddSome_given_someAlreadyIn() throws Exception {
|
||||
|
||||
BeanMap<String,Object> map = new BeanMap<>(some());
|
||||
BeanMap<String, Object> map = new BeanMap<>(some());
|
||||
map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
|
||||
|
||||
// act
|
||||
@@ -101,7 +101,7 @@ public class BeanMapTest {
|
||||
@Test
|
||||
public void testRemove_given_beansInAdditions() throws Exception {
|
||||
|
||||
BeanMap<String,Object> map = new BeanMap<>();
|
||||
BeanMap<String, Object> map = new BeanMap<>();
|
||||
map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
|
||||
map.putAll(all());
|
||||
assertThat(map.getModifyAdditions()).containsExactly(object1, object2, object3);
|
||||
@@ -117,7 +117,7 @@ public class BeanMapTest {
|
||||
@Test
|
||||
public void testRemoveAll_given_beansInAdditions() throws Exception {
|
||||
|
||||
BeanMap<String,Object> map = new BeanMap<>();
|
||||
BeanMap<String, Object> map = new BeanMap<>();
|
||||
map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
|
||||
map.putAll(all());
|
||||
assertThat(map.getModifyAdditions()).containsExactly(object1, object2, object3);
|
||||
@@ -133,7 +133,7 @@ public class BeanMapTest {
|
||||
@Test
|
||||
public void testRemove_given_beansNotInAdditions() throws Exception {
|
||||
|
||||
BeanMap<String,Object> map = new BeanMap<>(all());
|
||||
BeanMap<String, Object> map = new BeanMap<>(all());
|
||||
map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
|
||||
|
||||
// act
|
||||
@@ -148,7 +148,7 @@ public class BeanMapTest {
|
||||
@Test
|
||||
public void testRemoveAll_given_beansNotInAdditions() throws Exception {
|
||||
|
||||
BeanMap<String,Object> map = new BeanMap<>(all());
|
||||
BeanMap<String, Object> map = new BeanMap<>(all());
|
||||
map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
|
||||
|
||||
// act
|
||||
@@ -163,7 +163,7 @@ public class BeanMapTest {
|
||||
@Test
|
||||
public void testClear() throws Exception {
|
||||
|
||||
BeanMap<String,Object> map = new BeanMap<>(all());
|
||||
BeanMap<String, Object> map = new BeanMap<>(all());
|
||||
map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
|
||||
|
||||
// act
|
||||
@@ -177,8 +177,8 @@ public class BeanMapTest {
|
||||
@Test
|
||||
public void testClear_given_someBeansInAdditions() throws Exception {
|
||||
|
||||
BeanMap<String,Object> map = new BeanMap<>();
|
||||
map.put("1",object1);
|
||||
BeanMap<String, Object> map = new BeanMap<>();
|
||||
map.put("1", object1);
|
||||
map.setModifyListening(BeanCollection.ModifyListenMode.ALL);
|
||||
map.put("2", object2);
|
||||
map.put("3", object3);
|
||||
@@ -191,4 +191,4 @@ public class BeanMapTest {
|
||||
assertThat(map.getModifyAdditions()).isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.avaje.ebean.config;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class DbMigrationConfigTest {
|
||||
@@ -20,4 +20,4 @@ public class DbMigrationConfigTest {
|
||||
|
||||
assertThat(migrationConfig.getMigrationPath()).isEqualTo("dbmigration/myapp");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class PropertiesWrapperTest {
|
||||
public void testGetEnum() {
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put("platform","postgres");
|
||||
properties.put("platform", "postgres");
|
||||
|
||||
PropertiesWrapper pw = new PropertiesWrapper("pref", "myserver", properties);
|
||||
assertEquals(Platform.POSTGRES, pw.getEnum(Platform.class, "platform", Platform.H2));
|
||||
@@ -33,17 +33,17 @@ public class PropertiesWrapperTest {
|
||||
public void testTrimPropertyValues() {
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put("someBasic"," hello ");
|
||||
properties.put("someInt"," 42 ");
|
||||
properties.put("noTrimReqr","jim");
|
||||
properties.put("includeSpaces"," jim bob ");
|
||||
properties.put("someBasic", " hello ");
|
||||
properties.put("someInt", " 42 ");
|
||||
properties.put("noTrimReqr", "jim");
|
||||
properties.put("includeSpaces", " jim bob ");
|
||||
|
||||
PropertiesWrapper pw = new PropertiesWrapper("pref", "myserver", properties);
|
||||
assertEquals("hello",pw.get("someBasic"));
|
||||
assertEquals("hello", pw.get("someBasic"));
|
||||
assertEquals(42, pw.getInt("someInt", 1));
|
||||
assertNull(pw.get("doesNotExist", null));
|
||||
assertEquals("jim",pw.get("noTrimReqr"));
|
||||
assertEquals("jim bob",pw.get("includeSpaces"));
|
||||
assertEquals("jim", pw.get("noTrimReqr"));
|
||||
assertEquals("jim bob", pw.get("includeSpaces"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -53,9 +53,9 @@ public class PropertiesWrapperTest {
|
||||
String tmpDir = System.getProperty("java.io.tmpdir");
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.put("someBasic","hello");
|
||||
properties.put("someInt","42");
|
||||
properties.put("someDouble","5.5");
|
||||
properties.put("someBasic", "hello");
|
||||
properties.put("someInt", "42");
|
||||
properties.put("someDouble", "5.5");
|
||||
properties.put("somePath", "${HOME}/hello");
|
||||
properties.put("someSystemProp", "/aaa/${java.io.tmpdir}/bbb");
|
||||
|
||||
@@ -63,28 +63,28 @@ public class PropertiesWrapperTest {
|
||||
|
||||
assertEquals(42, pw.getInt("someInt", 99));
|
||||
assertEquals(Double.valueOf(5.5D), (Double.valueOf(pw.getDouble("someDouble", 99.9D))));
|
||||
assertEquals(home+"/hello", pw.get("somePath", null));
|
||||
assertEquals(tmpDir, "/aaa/"+tmpDir+"/bbb", pw.get("someSystemProp"));
|
||||
assertEquals(home + "/hello", pw.get("somePath", null));
|
||||
assertEquals(tmpDir, "/aaa/" + tmpDir + "/bbb", pw.get("someSystemProp"));
|
||||
|
||||
Properties properties1 = pw.asPropertiesLowerCase();
|
||||
assertEquals("hello", properties1.getProperty("somebasic"));
|
||||
assertEquals("42", properties1.getProperty("someint"));
|
||||
assertEquals(home+"/hello", properties1.get("somepath"));
|
||||
assertEquals(tmpDir, "/aaa/"+tmpDir+"/bbb", properties1.get("somesystemprop"));
|
||||
assertEquals(home + "/hello", properties1.get("somepath"));
|
||||
assertEquals(tmpDir, "/aaa/" + tmpDir + "/bbb", properties1.get("somesystemprop"));
|
||||
|
||||
|
||||
pw = new PropertiesWrapper(properties);
|
||||
|
||||
assertEquals(42, pw.getInt("someInt", 99));
|
||||
assertEquals(Double.valueOf(5.5D), (Double.valueOf(pw.getDouble("someDouble", 99.9D))));
|
||||
assertEquals(home+"/hello", pw.get("somePath", null));
|
||||
assertEquals(tmpDir, "/aaa/"+tmpDir+"/bbb", pw.get("someSystemProp"));
|
||||
assertEquals(home + "/hello", pw.get("somePath", null));
|
||||
assertEquals(tmpDir, "/aaa/" + tmpDir + "/bbb", pw.get("someSystemProp"));
|
||||
|
||||
properties1 = pw.asPropertiesLowerCase();
|
||||
assertEquals("hello", properties1.getProperty("somebasic"));
|
||||
assertEquals("42", properties1.getProperty("someint"));
|
||||
assertEquals(home+"/hello", properties1.get("somepath"));
|
||||
assertEquals(tmpDir, "/aaa/"+tmpDir+"/bbb", properties1.get("somesystemprop"));
|
||||
assertEquals(home + "/hello", properties1.get("somepath"));
|
||||
assertEquals(tmpDir, "/aaa/" + tmpDir + "/bbb", properties1.get("somesystemprop"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ServerConfigTest {
|
||||
Properties props = new Properties();
|
||||
props.setProperty("persistBatch", "INSERT");
|
||||
props.setProperty("persistBatchOnCascade", "INSERT");
|
||||
props.setProperty("dbuuid","binary");
|
||||
props.setProperty("dbuuid", "binary");
|
||||
props.setProperty("jdbcFetchSizeFindEach", "42");
|
||||
props.setProperty("jdbcFetchSizeFindList", "43");
|
||||
props.setProperty("backgroundExecutorShutdownSecs", "98");
|
||||
|
||||
@@ -13,7 +13,7 @@ public class BasicSqlLimitOffsetTest {
|
||||
|
||||
String query = "select * from mytab order by id";
|
||||
String sql = limiter.limit(query, 0, 10);
|
||||
assertThat(sql).isEqualTo(query+" limit 10");
|
||||
assertThat(sql).isEqualTo(query + " limit 10");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -21,7 +21,7 @@ public class BasicSqlLimitOffsetTest {
|
||||
|
||||
String query = "select * from mytab order by id";
|
||||
String sql = limiter.limit(query, 5, 10);
|
||||
assertThat(sql).isEqualTo(query+" limit 10 offset 5");
|
||||
assertThat(sql).isEqualTo(query + " limit 10 offset 5");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -31,4 +31,4 @@ public class BasicSqlLimitOffsetTest {
|
||||
String sql = limiter.limit(query, 0, 0);
|
||||
assertThat(sql).isEqualTo(query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class BasicSqlStandardLimiterTest {
|
||||
|
||||
String query = "select * from mytab order by id";
|
||||
String sql = limiter.limit(query, 0, 10);
|
||||
assertThat(sql).isEqualTo(query+" fetch next 10 rows only");
|
||||
assertThat(sql).isEqualTo(query + " fetch next 10 rows only");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -21,7 +21,7 @@ public class BasicSqlStandardLimiterTest {
|
||||
|
||||
String query = "select * from mytab order by id";
|
||||
String sql = limiter.limit(query, 5, 10);
|
||||
assertThat(sql).isEqualTo(query+" offset 5 rows fetch next 10 rows only");
|
||||
assertThat(sql).isEqualTo(query + " offset 5 rows fetch next 10 rows only");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -32,4 +32,4 @@ public class BasicSqlStandardLimiterTest {
|
||||
assertThat(sql).isEqualTo(query);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.junit.Test;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DbPlatformTypeLookupTest {
|
||||
|
||||
@@ -50,4 +50,4 @@ public class DbPlatformTypeLookupTest {
|
||||
assertEquals(lookup.byId(ExtraDbTypes.JSONVarchar), DbType.JSONVARCHAR);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.avaje.ebean.config.dbplatform;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DbPlatformTypeParserTest {
|
||||
|
||||
@@ -64,4 +64,4 @@ public class DbPlatformTypeParserTest {
|
||||
assertEquals(type.getDefaultScale(), 0);
|
||||
assertEquals(type.renderType(0, 0), "something(asd");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.avaje.ebean.config.dbplatform;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class DbTypeMapTest {
|
||||
@@ -13,16 +13,16 @@ public class DbTypeMapTest {
|
||||
PostgresPlatform pg = new PostgresPlatform();
|
||||
DbPlatformTypeMapping dbTypeMap = pg.getDbTypeMap();
|
||||
|
||||
assertThat(dbTypeMap.lookup("clob", false).renderType(0,0)).isEqualTo("text");
|
||||
assertThat(dbTypeMap.lookup("clob", false).renderType(0, 0)).isEqualTo("text");
|
||||
assertThat(dbTypeMap.lookup("CLOB", false).renderType(0, 0)).isEqualTo("text");
|
||||
|
||||
assertThat(dbTypeMap.lookup("varchar", true).renderType(20,0)).isEqualTo("varchar(20)");
|
||||
assertThat(dbTypeMap.lookup("varchar", true).renderType(20, 0)).isEqualTo("varchar(20)");
|
||||
|
||||
assertThat(dbTypeMap.lookup("json", false).renderType(0,0)).isEqualTo("json");
|
||||
assertThat(dbTypeMap.lookup("jsonb", false).renderType(0,0)).isEqualTo("jsonb");
|
||||
assertThat(dbTypeMap.lookup("jsonclob", false).renderType(0,0)).isEqualTo("text");
|
||||
assertThat(dbTypeMap.lookup("jsonblob", false).renderType(0,0)).isEqualTo("bytea");
|
||||
assertThat(dbTypeMap.lookup("jsonvarchar", false).renderType(200,0)).isEqualTo("varchar(200)");
|
||||
assertThat(dbTypeMap.lookup("json", false).renderType(0, 0)).isEqualTo("json");
|
||||
assertThat(dbTypeMap.lookup("jsonb", false).renderType(0, 0)).isEqualTo("jsonb");
|
||||
assertThat(dbTypeMap.lookup("jsonclob", false).renderType(0, 0)).isEqualTo("text");
|
||||
assertThat(dbTypeMap.lookup("jsonblob", false).renderType(0, 0)).isEqualTo("bytea");
|
||||
assertThat(dbTypeMap.lookup("jsonvarchar", false).renderType(200, 0)).isEqualTo("varchar(200)");
|
||||
|
||||
}
|
||||
|
||||
@@ -35,4 +35,4 @@ public class DbTypeMapTest {
|
||||
|
||||
assertThat(dbType).isSameAs(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import static org.junit.Assert.assertEquals;
|
||||
public class MySqlHistorySupportTest {
|
||||
|
||||
private MySqlHistorySupport support = new MySqlHistorySupport();
|
||||
|
||||
|
||||
@Test
|
||||
public void getAsOfPredicate() {
|
||||
|
||||
@@ -29,4 +29,4 @@ public class MySqlHistorySupportTest {
|
||||
String upper = support.getSysPeriodUpper("t0", "sys_period");
|
||||
assertEquals(upper, "t0.sys_period_end");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.avaje.ebean.config.dbplatform;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class PostgresHistorySupportTest {
|
||||
|
||||
@@ -35,4 +35,4 @@ public class PostgresHistorySupportTest {
|
||||
assertEquals(upper, "upper(t0.sys_period)");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class PostgresPlatformTest {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testTypeConversion() {
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class Helper {
|
||||
public static String asText(Object instance, String relativePath) throws IOException {
|
||||
InputStream is = instance.getClass().getResourceAsStream(relativePath);
|
||||
if (is == null) {
|
||||
throw new IllegalArgumentException("resource "+relativePath+" not found");
|
||||
throw new IllegalArgumentException("resource " + relativePath + " not found");
|
||||
}
|
||||
return asText(is);
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ public class H2HistoryDdlTest {
|
||||
@Test
|
||||
public void testRegenerateHistoryTriggers() throws Exception {
|
||||
|
||||
SpiEbeanServer ebeanServer = (SpiEbeanServer)Ebean.getDefaultServer();
|
||||
SpiEbeanServer ebeanServer = (SpiEbeanServer) Ebean.getDefaultServer();
|
||||
|
||||
HistoryTableUpdate update = new HistoryTableUpdate("c_user");
|
||||
update.add(HistoryTableUpdate.Change.ADD, "one");
|
||||
@@ -38,4 +38,4 @@ public class H2HistoryDdlTest {
|
||||
assertThat(write.dropAll().isEmpty()).isTrue();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@ package com.avaje.ebean.dbmigration.ddlgeneration.platform;
|
||||
import com.avaje.ebean.dbmigration.ddlgeneration.platform.util.IndexSet;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
public class IndexSetTest {
|
||||
@@ -18,9 +19,9 @@ public class IndexSetTest {
|
||||
assertFalse(set.add(new String[]{"one_column"}));
|
||||
|
||||
assertTrue(set.add(new String[]{"a", "b"}));
|
||||
assertTrue(set.add(new String[]{"b","c"}));
|
||||
assertTrue(set.add(new String[]{"b", "c"}));
|
||||
assertTrue(set.add(new String[]{"a"}));
|
||||
assertFalse(set.add(new String[]{"a", "b"}));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package com.avaje.ebean.dbmigration.ddlgeneration.platform.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class VowelRemoverTest {
|
||||
|
||||
@@ -10,8 +10,8 @@ public class VowelRemoverTest {
|
||||
public void testTrim() throws Exception {
|
||||
|
||||
|
||||
assertEquals("fk_abcd",VowelRemover.trim("fk_abcde",4));
|
||||
assertEquals("fk_abcd", VowelRemover.trim("fk_abcde", 4));
|
||||
assertEquals("fk_a", VowelRemover.trim("fk_aaaaaa", 4));
|
||||
assertEquals("ab_avrylngtblnm", VowelRemover.trim("ab_averylongtablename", 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -16,14 +16,14 @@ public class MigrationXmlWriterTest {
|
||||
assertThat(migration.getChangeSet()).hasSize(1);
|
||||
assertThat(migration.getChangeSet().get(0).getChangeSetChildren()).hasSize(3);
|
||||
|
||||
File temp = File.createTempFile("migrationWrite",".xml");
|
||||
File temp = File.createTempFile("migrationWrite", ".xml");
|
||||
new MigrationXmlWriter("THIS IS A GENERATED FILE - DO NOT MODIFY").write(migration, temp);
|
||||
|
||||
Migration migrationRead = MigrationXmlReader.read(temp);
|
||||
assertThat(migrationRead.getChangeSet()).hasSize(1);
|
||||
assertThat(migrationRead.getChangeSet().get(0).getChangeSetChildren()).hasSize(3);
|
||||
|
||||
temp = File.createTempFile("migrationWrite",".xml");
|
||||
temp = File.createTempFile("migrationWrite", ".xml");
|
||||
new MigrationXmlWriter(null).write(migration, temp);
|
||||
|
||||
Migration migrationRead2 = MigrationXmlReader.read(temp);
|
||||
@@ -31,4 +31,4 @@ public class MigrationXmlWriterTest {
|
||||
assertThat(migrationRead2.getChangeSet()).hasSize(1);
|
||||
assertThat(migrationRead.getChangeSet().get(0).getChangeSetChildren()).hasSize(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class EntryTest {
|
||||
|
||||
PendingDrops.Entry entry = createEntry(pending);
|
||||
|
||||
assertThat(entry.removeDrops(changeSet("one","two"))).isTrue();
|
||||
assertThat(entry.removeDrops(changeSet("one", "two"))).isTrue();
|
||||
assertThat(entry.list).asList().doesNotContain(pending);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class EntryTest {
|
||||
|
||||
PendingDrops.Entry entry = createEntry(pending);
|
||||
|
||||
assertThat(entry.removeDrops(changeSet("one","two"))).isFalse();
|
||||
assertThat(entry.removeDrops(changeSet("one", "two"))).isFalse();
|
||||
assertThat(entry.list).asList().contains(pending);
|
||||
assertThat(pending.getChangeSetChildren()).asList().hasSize(2);
|
||||
|
||||
@@ -143,9 +143,9 @@ public class EntryTest {
|
||||
static PendingDrops.Entry createEntry(ChangeSet... pending) {
|
||||
|
||||
PendingDrops.Entry entry = new PendingDrops.Entry(MigrationVersion.parse("1.1"));
|
||||
for (ChangeSet changeSet: pending) {
|
||||
for (ChangeSet changeSet : pending) {
|
||||
entry.add(changeSet);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.avaje.ebean.dbmigration.migration.AlterColumn;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class MColumnTest {
|
||||
@@ -319,4 +319,4 @@ public class MColumnTest {
|
||||
assertThat(diff.getApplyChanges()).hasSize(1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,35 +10,35 @@ import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class MTableTest {
|
||||
|
||||
static MTable base() {
|
||||
MTable table = new MTable("tab");
|
||||
table.addColumn(new MColumn("id","bigint"));
|
||||
table.addColumn(new MColumn("name","varchar(20)"));
|
||||
table.addColumn(new MColumn("status","varchar(3)"));
|
||||
table.addColumn(new MColumn("id", "bigint"));
|
||||
table.addColumn(new MColumn("name", "varchar(20)"));
|
||||
table.addColumn(new MColumn("status", "varchar(3)"));
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
static MTable newTable() {
|
||||
MTable table = new MTable("tab");
|
||||
table.addColumn(new MColumn("id","bigint"));
|
||||
table.addColumn(new MColumn("name","varchar(20)"));
|
||||
table.addColumn(new MColumn("comment","varchar(1000)"));
|
||||
table.addColumn(new MColumn("id", "bigint"));
|
||||
table.addColumn(new MColumn("name", "varchar(20)"));
|
||||
table.addColumn(new MColumn("comment", "varchar(1000)"));
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
static MTable newTableAdd2Columns() {
|
||||
MTable table = new MTable("tab");
|
||||
table.addColumn(new MColumn("id","bigint"));
|
||||
table.addColumn(new MColumn("name","varchar(20)"));
|
||||
table.addColumn(new MColumn("status","varchar(3)"));
|
||||
table.addColumn(new MColumn("comment","varchar(1000)"));
|
||||
table.addColumn(new MColumn("note","varchar(2000)"));
|
||||
table.addColumn(new MColumn("id", "bigint"));
|
||||
table.addColumn(new MColumn("name", "varchar(20)"));
|
||||
table.addColumn(new MColumn("status", "varchar(3)"));
|
||||
table.addColumn(new MColumn("comment", "varchar(1000)"));
|
||||
table.addColumn(new MColumn("note", "varchar(2000)"));
|
||||
return table;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ public class MTableTest {
|
||||
|
||||
MTable table = new MTable("tab");
|
||||
table.addColumn(modCol);
|
||||
table.addColumn(new MColumn("id","bigint"));
|
||||
table.addColumn(new MColumn("status","varchar(3)"));
|
||||
table.addColumn(new MColumn("id", "bigint"));
|
||||
table.addColumn(new MColumn("status", "varchar(3)"));
|
||||
return table;
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ public class MTableTest {
|
||||
base.registerPendingDropColumn("fullName");
|
||||
base.registerPendingDropColumn("last");
|
||||
|
||||
assertThat(base.allHistoryColumns(false)).containsExactly("id","name","status");
|
||||
assertThat(base.allHistoryColumns(true)).containsExactly("id","name","status","fullName","last");
|
||||
assertThat(base.allHistoryColumns(false)).containsExactly("id", "name", "status");
|
||||
assertThat(base.allHistoryColumns(true)).containsExactly("id", "name", "status", "fullName", "last");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,14 +80,14 @@ public class MTableTest {
|
||||
|
||||
List<Object> createChanges = diff.getApplyChanges();
|
||||
assertThat(createChanges).hasSize(1);
|
||||
AddColumn addColumn = (AddColumn)createChanges.get(0);
|
||||
AddColumn addColumn = (AddColumn) createChanges.get(0);
|
||||
assertThat(addColumn.getColumn()).extracting("name").contains("comment");
|
||||
assertThat(addColumn.getColumn()).extracting("type").contains("varchar(1000)");
|
||||
|
||||
List<Object> dropChanges = diff.getDropChanges();
|
||||
assertThat(dropChanges).hasSize(1);
|
||||
|
||||
DropColumn dropColumn = (DropColumn)dropChanges.get(0);
|
||||
DropColumn dropColumn = (DropColumn) dropChanges.get(0);
|
||||
assertThat(dropColumn.getColumnName()).isEqualTo("status");
|
||||
assertThat(dropColumn.getTableName()).isEqualTo("tab");
|
||||
}
|
||||
@@ -101,9 +101,9 @@ public class MTableTest {
|
||||
List<Object> createChanges = diff.getApplyChanges();
|
||||
assertThat(createChanges).hasSize(1);
|
||||
|
||||
AddColumn addColumn = (AddColumn)createChanges.get(0);
|
||||
assertThat(addColumn.getColumn()).extracting("name").contains("comment","note");
|
||||
assertThat(addColumn.getColumn()).extracting("type").contains("varchar(1000)","varchar(2000)");
|
||||
AddColumn addColumn = (AddColumn) createChanges.get(0);
|
||||
assertThat(addColumn.getColumn()).extracting("name").contains("comment", "note");
|
||||
assertThat(addColumn.getColumn()).extracting("type").contains("varchar(1000)", "varchar(2000)");
|
||||
|
||||
assertThat(diff.getDropChanges()).hasSize(0);
|
||||
|
||||
@@ -118,7 +118,7 @@ public class MTableTest {
|
||||
List<Object> createChanges = diff.getApplyChanges();
|
||||
assertThat(createChanges).hasSize(1);
|
||||
|
||||
AlterColumn alterColumn = (AlterColumn)createChanges.get(0);
|
||||
AlterColumn alterColumn = (AlterColumn) createChanges.get(0);
|
||||
assertThat(alterColumn.getColumnName()).isEqualTo("name");
|
||||
assertThat(alterColumn.getType()).isEqualTo("varchar(30)");
|
||||
assertThat(alterColumn.isNotnull()).isEqualTo(true);
|
||||
@@ -224,4 +224,4 @@ public class MTableTest {
|
||||
assertThat(diff.getDropChanges().get(0)).isInstanceOf(DropHistoryTable.class);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class MigrationVersionTest {
|
||||
@Test
|
||||
public void sort() {
|
||||
|
||||
List<MigrationVersion> list= new ArrayList<>();
|
||||
List<MigrationVersion> list = new ArrayList<>();
|
||||
list.add(MigrationVersion.parse("1.1__point"));
|
||||
list.add(MigrationVersion.parse("3.0__three"));
|
||||
list.add(MigrationVersion.parse("1.0__init"));
|
||||
@@ -166,4 +166,4 @@ public class MigrationVersionTest {
|
||||
assertThat(v1.compareTo(v3)).isEqualTo(-1);
|
||||
assertThat(v1.compareTo(v4)).isEqualTo(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ public class ModelContainerTest {
|
||||
List<String> normalColumns = base.getTable("document").allHistoryColumns(false);
|
||||
List<String> historyColumns = base.getTable("document").allHistoryColumns(true);
|
||||
|
||||
assertThat(historyColumns).contains("zong","boom","baz","bar");
|
||||
assertThat(normalColumns).doesNotContain("zing","zong","boom","baz","bar");
|
||||
assertThat(historyColumns).contains("zong", "boom", "baz", "bar");
|
||||
assertThat(normalColumns).doesNotContain("zing", "zong", "boom", "baz", "bar");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -90,4 +90,4 @@ public class ModelContainerTest {
|
||||
private Migration mig(String path) {
|
||||
return MigrationXmlReader.read(ModelContainerTest.class.getResourceAsStream(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ public class PendingDropsTest {
|
||||
|
||||
DropColumn one = col("one");
|
||||
DropColumn two = col("two");
|
||||
pendingDrops.add(V1_1, changeSet(one,two));
|
||||
pendingDrops.add(V1_1, changeSet("three","four"));
|
||||
pendingDrops.add(V1_1, changeSet(one, two));
|
||||
pendingDrops.add(V1_1, changeSet("three", "four"));
|
||||
assertThat(pendingDrops.testGetEntryFor(V1_1).list).asList().hasSize(2);
|
||||
|
||||
ChangeSet applied = changeSet("two");
|
||||
@@ -50,11 +50,11 @@ public class PendingDropsTest {
|
||||
|
||||
DropColumn one = col("one");
|
||||
DropColumn two = col("two");
|
||||
pendingDrops.add(V1_1, changeSet(one,two));
|
||||
pendingDrops.add(V1_1, changeSet("three","four"));
|
||||
pendingDrops.add(V1_1, changeSet(one, two));
|
||||
pendingDrops.add(V1_1, changeSet("three", "four"));
|
||||
assertThat(pendingDrops.testGetEntryFor(V1_1).list).asList().hasSize(2);
|
||||
|
||||
ChangeSet applied = changeSet("two","one");
|
||||
ChangeSet applied = changeSet("two", "one");
|
||||
applied.setDropsFor("1.1");
|
||||
|
||||
assertThat(pendingDrops.appliedDropsFor(applied)).isFalse();
|
||||
@@ -243,4 +243,4 @@ public class PendingDropsTest {
|
||||
return EntryTest.col(colName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,10 +5,10 @@ import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.config.DbConstraintNaming;
|
||||
import com.avaje.ebean.dbmigration.ddlgeneration.platform.DefaultConstraintMaxLength;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebean.dbmigration.model.MTable;
|
||||
import com.avaje.ebean.dbmigration.model.ModelContainer;
|
||||
import com.avaje.ebean.dbmigration.model.visitor.VisitAllUsing;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -18,7 +18,7 @@ public class ModelBuildBeanVisitorTest extends BaseTestCase {
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
SpiEbeanServer defaultServer = (SpiEbeanServer)Ebean.getDefaultServer();
|
||||
SpiEbeanServer defaultServer = (SpiEbeanServer) Ebean.getDefaultServer();
|
||||
|
||||
ModelContainer model = new ModelContainer();
|
||||
|
||||
@@ -39,4 +39,4 @@ public class ModelBuildBeanVisitorTest extends BaseTestCase {
|
||||
MTable customer = model.getTable("o_customer");
|
||||
assertThat(customer).isNotNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,7 @@ import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class BeanFindControllerTest extends BaseTestCase {
|
||||
|
||||
@@ -93,7 +90,7 @@ public class BeanFindControllerTest extends BaseTestCase {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T find(BeanQueryRequest<T> request) {
|
||||
return (T)createBean();
|
||||
return (T) createBean();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,7 +104,7 @@ public class BeanFindControllerTest extends BaseTestCase {
|
||||
public <T> BeanCollection<T> findMany(BeanQueryRequest<T> request) {
|
||||
|
||||
BeanList<T> list = new BeanList<>();
|
||||
list.add((T)createBean());
|
||||
list.add((T) createBean());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -118,4 +115,4 @@ public class BeanFindControllerTest extends BaseTestCase {
|
||||
b.setName("47");
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ public class BeanPostLoadTest extends BaseTestCase {
|
||||
ebeanServer.save(bean);
|
||||
|
||||
EBasicVer found = ebeanServer.find(EBasicVer.class)
|
||||
.select("name, other")
|
||||
.setId(bean.getId())
|
||||
.findUnique();
|
||||
.select("name, other")
|
||||
.setId(bean.getId())
|
||||
.findUnique();
|
||||
|
||||
assertThat(postLoad.methodsCalled).hasSize(1);
|
||||
assertThat(postLoad.methodsCalled).containsExactly("postLoad");
|
||||
@@ -61,7 +61,7 @@ public class BeanPostLoadTest extends BaseTestCase {
|
||||
config.getClasses().add(EBasicVer.class);
|
||||
|
||||
config.add(postLoad);
|
||||
|
||||
|
||||
return EbeanServerFactory.create(config);
|
||||
}
|
||||
|
||||
@@ -97,4 +97,4 @@ public class BeanPostLoadTest extends BaseTestCase {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,30 +14,26 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class EJsonTests {
|
||||
|
||||
@Test
|
||||
public void test_map_simple() throws IOException {
|
||||
|
||||
|
||||
JsonFactory factory = new JsonFactory();
|
||||
|
||||
|
||||
String jsonInput = "{\"name\":\"rob\",\"age\":12}";
|
||||
|
||||
JsonParser jsonParser = factory.createParser(jsonInput);
|
||||
|
||||
Object result = EJson.parse(jsonParser);
|
||||
|
||||
|
||||
assertTrue(result instanceof Map);
|
||||
Map<?,?> map = (Map<?,?>)result;
|
||||
Map<?, ?> map = (Map<?, ?>) result;
|
||||
assertEquals("rob", map.get("name"));
|
||||
assertEquals(12L, map.get("age"));
|
||||
|
||||
|
||||
String jsonOutput = EJson.write(result);
|
||||
assertEquals(jsonInput, jsonOutput);
|
||||
}
|
||||
@@ -51,7 +47,7 @@ public class EJsonTests {
|
||||
|
||||
JsonParser jsonParser = factory.createParser(jsonInput);
|
||||
|
||||
Map<String,Object> map = EJson.parseObject(jsonParser);
|
||||
Map<String, Object> map = EJson.parseObject(jsonParser);
|
||||
|
||||
assertNotNull(map);
|
||||
assertEquals("rob", map.get("name"));
|
||||
@@ -85,16 +81,16 @@ public class EJsonTests {
|
||||
Object result = EJson.parse(jsonInput);
|
||||
|
||||
assertTrue(result instanceof Map);
|
||||
Map<?,?> map = (Map<?,?>)result;
|
||||
Map<?, ?> map = (Map<?, ?>) result;
|
||||
assertEquals(4, map.size());
|
||||
assertEquals("rob", map.get("name"));
|
||||
assertEquals(12L, map.get("age"));
|
||||
|
||||
Map<?,?> org = (Map<?,?>)map.get("org");
|
||||
Map<?, ?> org = (Map<?, ?>) map.get("org");
|
||||
assertEquals("superorg", org.get("name"));
|
||||
assertEquals(4L, org.get("rating"));
|
||||
|
||||
List<?> nums = (List<?>)map.get("nums");
|
||||
List<?> nums = (List<?>) map.get("nums");
|
||||
assertEquals(3, nums.size());
|
||||
assertEquals(1L, nums.get(0));
|
||||
assertEquals(2L, nums.get(1));
|
||||
@@ -111,7 +107,7 @@ public class EJsonTests {
|
||||
Object result = EJson.parse(jsonInput);
|
||||
|
||||
assertTrue(result instanceof Map);
|
||||
Map<?,?> map = (Map<?,?>)result;
|
||||
Map<?, ?> map = (Map<?, ?>) result;
|
||||
assertEquals("rob", map.get("name"));
|
||||
assertNull(map.get("age"));
|
||||
|
||||
@@ -181,7 +177,7 @@ public class EJsonTests {
|
||||
|
||||
assertTrue(result instanceof List);
|
||||
|
||||
List<Map<?,?>> list = (List<Map<?,?>>)result;
|
||||
List<Map<?, ?>> list = (List<Map<?, ?>>) result;
|
||||
assertEquals(2, list.size());
|
||||
assertEquals("rob", list.get(0).get("name"));
|
||||
assertEquals(12L, list.get(0).get("age"));
|
||||
@@ -201,11 +197,11 @@ public class EJsonTests {
|
||||
Object result = EJson.parse(reader);
|
||||
|
||||
assertTrue(result instanceof Map);
|
||||
Map<?,?> map = (Map<?,?>)result;
|
||||
Map<?, ?> map = (Map<?, ?>) result;
|
||||
assertEquals("rob", map.get("name"));
|
||||
assertNull(map.get("age"));
|
||||
|
||||
Map<?,?> friend = (Map<?,?>)map.get("friend");
|
||||
Map<?, ?> friend = (Map<?, ?>) map.get("friend");
|
||||
assertEquals("mike", friend.get("name"));
|
||||
assertEquals(13L, friend.get("age"));
|
||||
}
|
||||
@@ -215,7 +211,7 @@ public class EJsonTests {
|
||||
public void test_map_nested_modifyAware() throws IOException {
|
||||
|
||||
String jsonInput = "{\"name\":\"rob\",\"age\":12,\"org\":{\"name\":\"superorg\",\"rating\":4},\"nums\":[1,2,3]}";
|
||||
ModifyAwareMap<String,Object> map = (ModifyAwareMap<String, Object>) EJson.parseObject(jsonInput, true);
|
||||
ModifyAwareMap<String, Object> map = (ModifyAwareMap<String, Object>) EJson.parseObject(jsonInput, true);
|
||||
|
||||
assertFalse(map.isMarkedDirty());
|
||||
assertEquals(4, map.size());
|
||||
@@ -229,7 +225,7 @@ public class EJsonTests {
|
||||
public void test_map_nested_modifyAwareNestedList() throws IOException {
|
||||
|
||||
String jsonInput = "{\"name\":\"rob\",\"age\":12,\"org\":{\"name\":\"superorg\",\"rating\":4},\"nums\":[1,2,3]}";
|
||||
ModifyAwareMap<String,Object> map = (ModifyAwareMap<String, Object>) EJson.parseObject(jsonInput, true);
|
||||
ModifyAwareMap<String, Object> map = (ModifyAwareMap<String, Object>) EJson.parseObject(jsonInput, true);
|
||||
assertFalse(map.isMarkedDirty());
|
||||
|
||||
List<Object> nums = (List<Object>) map.get("nums");
|
||||
@@ -242,11 +238,11 @@ public class EJsonTests {
|
||||
public void test_map_nested_modifyAwareNestedObject() throws IOException {
|
||||
|
||||
String jsonInput = "{\"name\":\"rob\",\"age\":12,\"org\":{\"name\":\"superorg\",\"rating\":4},\"nums\":[1,2,3]}";
|
||||
ModifyAwareMap<String,Object> map = (ModifyAwareMap<String, Object>) EJson.parseObject(jsonInput, true);
|
||||
ModifyAwareMap<String, Object> map = (ModifyAwareMap<String, Object>) EJson.parseObject(jsonInput, true);
|
||||
assertFalse(map.isMarkedDirty());
|
||||
|
||||
Map<String,Object> org = (Map<String, Object>) map.get("org");
|
||||
org.put("extra","foo");
|
||||
Map<String, Object> org = (Map<String, Object>) map.get("org");
|
||||
org.put("extra", "foo");
|
||||
assertTrue(map.isMarkedDirty());
|
||||
}
|
||||
|
||||
@@ -272,13 +268,13 @@ public class EJsonTests {
|
||||
|
||||
Set set = EJson.parseSet(jsonInput, true);
|
||||
|
||||
ModifyAwareOwner modAware = (ModifyAwareOwner)set;
|
||||
ModifyAwareOwner modAware = (ModifyAwareOwner) set;
|
||||
assertFalse(modAware.isMarkedDirty());
|
||||
|
||||
Iterator iterator = set.iterator();
|
||||
if (iterator.hasNext()) {
|
||||
Map map = (Map)iterator.next();
|
||||
map.put("name","stu");
|
||||
Map map = (Map) iterator.next();
|
||||
map.put("name", "stu");
|
||||
assertTrue(modAware.isMarkedDirty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,7 @@ import com.avaje.tests.model.basic.Vehicle;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class BeanTypeTest {
|
||||
@@ -123,7 +121,7 @@ public class BeanTypeTest {
|
||||
BeanDocType<Order> orderDocType = beanType(Order.class).docStore();
|
||||
FetchPath customer = orderDocType.getEmbedded("customer");
|
||||
assertThat(customer).isNotNull();
|
||||
assertThat(customer.getProperties(null)).contains("id","name");
|
||||
assertThat(customer.getProperties(null)).contains("id", "name");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -173,12 +171,12 @@ public class BeanTypeTest {
|
||||
@Test
|
||||
public void docStoreApplyPath() throws Exception {
|
||||
|
||||
SpiQuery<Order> orderQuery = (SpiQuery<Order>)server.find(Order.class);
|
||||
SpiQuery<Order> orderQuery = (SpiQuery<Order>) server.find(Order.class);
|
||||
beanType(Order.class).docStore().applyPath(orderQuery);
|
||||
|
||||
OrmQueryDetail detail = orderQuery.getDetail();
|
||||
assertThat(detail.getChunk("customer", false).getSelectProperties())
|
||||
.containsExactly("id", "name");
|
||||
.containsExactly("id", "name");
|
||||
}
|
||||
|
||||
|
||||
@@ -214,12 +212,12 @@ public class BeanTypeTest {
|
||||
|
||||
@Test
|
||||
public void getDiscColumn_when_default() {
|
||||
assertEquals(beanType(Car.class).getDiscColumn(),"dtype");
|
||||
assertEquals(beanType(Car.class).getDiscColumn(), "dtype");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDiscColumn_when_set() {
|
||||
assertEquals(beanType(Stockforecast.class).getDiscColumn(),"type");
|
||||
assertEquals(beanType(Stockforecast.class).getDiscColumn(), "type");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -231,13 +229,13 @@ public class BeanTypeTest {
|
||||
@Test
|
||||
public void addInheritanceWhere_when_leaf() {
|
||||
Query<Vehicle> query = server.find(Vehicle.class);
|
||||
beanType(Car.class).addInheritanceWhere((SpiQuery<?>)query);
|
||||
beanType(Car.class).addInheritanceWhere((SpiQuery<?>) query);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addInheritanceWhere_when_root() {
|
||||
Query<Vehicle> query = server.find(Vehicle.class);
|
||||
beanType(Vehicle.class).addInheritanceWhere((SpiQuery<?>)query);
|
||||
beanType(Vehicle.class).addInheritanceWhere((SpiQuery<?>) query);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,37 +82,37 @@ public class ExpressionPathTest {
|
||||
|
||||
BeanType<Customer> customerBeanType = beanType(Customer.class);
|
||||
BeanType<Order> orderBeanType = beanType(Order.class);
|
||||
|
||||
|
||||
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.setName("foo");
|
||||
server.save(customer);
|
||||
|
||||
|
||||
customer = server.find(Customer.class, customer.getId());
|
||||
assertThat(customer.getName()).isEqualTo("foo");
|
||||
|
||||
|
||||
customerBeanType.getExpressionPath("name").pathSet(customer, "bar");
|
||||
server.save(customer);
|
||||
|
||||
|
||||
customer = server.find(Customer.class, customer.getId());
|
||||
assertThat(customer.getName()).isEqualTo("bar");
|
||||
|
||||
|
||||
|
||||
|
||||
Order order = new Order();
|
||||
order.setCustomer(customer);
|
||||
|
||||
|
||||
server.save(order);
|
||||
|
||||
|
||||
order = server.find(Order.class, order.getId());
|
||||
|
||||
|
||||
ExpressionPath customerNamePath = orderBeanType.getExpressionPath("customer.name");
|
||||
assertThat(customerNamePath.pathGet(order)).isEqualTo("bar");
|
||||
|
||||
|
||||
customerNamePath.pathSet(order, "baz");
|
||||
server.save(order);
|
||||
|
||||
|
||||
order = server.find(Order.class, order.getId());
|
||||
assertThat(order.getCustomer().getName()).isEqualTo("baz");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,7 @@ import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class SpiServerTest {
|
||||
@@ -51,4 +46,4 @@ public class SpiServerTest {
|
||||
assertTrue(!allTypes.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import com.avaje.ebean.annotation.EnumValue;
|
||||
*/
|
||||
public enum MyDayOfWeek {
|
||||
|
||||
@EnumValue("MONDAY ") MONDAY,
|
||||
@EnumValue("TUESDAY ") TUESDAY,
|
||||
@EnumValue("WEDNESDAY") WEDNESDAY,
|
||||
@EnumValue("THURSDAY ") THURSDAY,
|
||||
@EnumValue("FRIDAY ") FRIDAY,
|
||||
@EnumValue("SATURDAY ") SATURDAY,
|
||||
@EnumValue("SUNDAY ") SUNDAY
|
||||
@EnumValue("MONDAY ")MONDAY,
|
||||
@EnumValue("TUESDAY ")TUESDAY,
|
||||
@EnumValue("WEDNESDAY")WEDNESDAY,
|
||||
@EnumValue("THURSDAY ")THURSDAY,
|
||||
@EnumValue("FRIDAY ")FRIDAY,
|
||||
@EnumValue("SATURDAY ")SATURDAY,
|
||||
@EnumValue("SUNDAY ")SUNDAY
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class TestTypeManager extends BaseTestCase {
|
||||
Assert.assertTrue(checkImmutable.isImmutable());
|
||||
|
||||
ScalarDataReader<?> dataReader = typeManager
|
||||
.recursiveCreateScalarDataReader(ExhangeCMoneyRate.class);
|
||||
.recursiveCreateScalarDataReader(ExhangeCMoneyRate.class);
|
||||
Assert.assertTrue(dataReader instanceof CtCompoundType<?>);
|
||||
|
||||
dataReader = typeManager.recursiveCreateScalarDataReader(CMoney.class);
|
||||
|
||||
@@ -4,9 +4,7 @@ import com.avaje.ebean.FetchPath;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class PathPropertiesTests {
|
||||
|
||||
|
||||
@@ -16,11 +16,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.StrictAssertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class JsonContextTest {
|
||||
|
||||
@@ -40,9 +36,9 @@ public class JsonContextTest {
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Order> orders = Ebean.find(Order.class)
|
||||
.fetch("customer", "id, name")
|
||||
.where().eq("customer.id", 1)
|
||||
.findList();
|
||||
.fetch("customer", "id, name")
|
||||
.where().eq("customer.id", 1)
|
||||
.findList();
|
||||
|
||||
String json = Ebean.json().toJson(orders);
|
||||
|
||||
@@ -65,9 +61,9 @@ public class JsonContextTest {
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Order> orders = Ebean.find(Order.class)
|
||||
.select("status")
|
||||
.fetch("customer", "id, name")
|
||||
.findList();
|
||||
.select("status")
|
||||
.fetch("customer", "id, name")
|
||||
.findList();
|
||||
|
||||
String json = Ebean.json().toJson(orders);
|
||||
|
||||
@@ -220,4 +216,4 @@ public class JsonContextTest {
|
||||
|
||||
assertEquals("START[{\"count\":12}]END", writer.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ public class JsonWriteOptionsTests {
|
||||
|
||||
@Test
|
||||
public void test_parse() {
|
||||
|
||||
|
||||
JsonWriteOptions options = JsonWriteOptions.parsePath("id,status,name");
|
||||
FetchPath pathProps = options.getPathProperties();
|
||||
|
||||
|
||||
//Assert.assertEquals(1, pathProps.getPaths().size());
|
||||
assertTrue(pathProps.getProperties(null).contains("id"));
|
||||
assertTrue(pathProps.getProperties(null).contains("name"));
|
||||
@@ -57,5 +57,4 @@ public class JsonWriteOptionsTests {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.avaje.ebean.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class CamelCaseHelperTest {
|
||||
|
||||
@@ -28,4 +28,4 @@ public class CamelCaseHelperTest {
|
||||
assertEquals(CamelCaseHelper.toCamelFromUnderscore("HELLO"), "HELLO");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,27 +13,27 @@ public class HashQueryPlanBuilderTest {
|
||||
|
||||
@Test
|
||||
public void test_pair_0_1() {
|
||||
assertThat(combine(0, 31)).isNotEqualTo(combine(1,0));
|
||||
assertThat(combine(0, 31)).isNotEqualTo(combine(1, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_pair_0_10_adjust_0() {
|
||||
assertThat(combine(0, 310)).isNotEqualTo(combine(10,0));
|
||||
assertThat(combine(0, 310)).isNotEqualTo(combine(10, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_pair_0_10_adjust_10() {
|
||||
assertThat(combine(0, 320)).isNotEqualTo(combine(10,10));
|
||||
assertThat(combine(0, 320)).isNotEqualTo(combine(10, 10));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_pair_0_10_adjust_40() {
|
||||
assertThat(combine(0, 350)).isNotEqualTo(combine(10,40));
|
||||
assertThat(combine(0, 350)).isNotEqualTo(combine(10, 40));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_pair_0_10_adjust_90() {
|
||||
assertThat(combine(0, 400)).isNotEqualTo(combine(10,90));
|
||||
assertThat(combine(0, 400)).isNotEqualTo(combine(10, 90));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,28 +18,28 @@ public class HashQueryPlanTest {
|
||||
@Test
|
||||
public void testEquals() throws Exception {
|
||||
|
||||
assertThat(hqp("foo",10, 7)).isEqualTo(hqp("foo",10, 7));
|
||||
assertThat(hqp("foo",10, 7)).isNotEqualTo(hqp("foo", 11, 7));
|
||||
assertThat(hqp("foo",10, 7)).isNotEqualTo(hqp("foo", 9, 7));
|
||||
assertThat(hqp("foo",10, 7)).isNotEqualTo(hqp("foo", 10, 8));
|
||||
assertThat(hqp("foo",10, 7)).isNotEqualTo(hqp("foo", 10, 6));
|
||||
assertThat(hqp("foo",10, 7)).isNotEqualTo(hqp("bar", 10, 6));
|
||||
assertThat(hqp("foo",10, 7)).isNotEqualTo(hqp(null, 10, 7));
|
||||
assertThat(hqp(null,10, 7)).isNotEqualTo(hqp("foo", 10, 7));
|
||||
assertThat(hqp(null,10, 7)).isEqualTo(hqp(null, 10, 7));
|
||||
assertThat(hqp("foo", 10, 7)).isEqualTo(hqp("foo", 10, 7));
|
||||
assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("foo", 11, 7));
|
||||
assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("foo", 9, 7));
|
||||
assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("foo", 10, 8));
|
||||
assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("foo", 10, 6));
|
||||
assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("bar", 10, 6));
|
||||
assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp(null, 10, 7));
|
||||
assertThat(hqp(null, 10, 7)).isNotEqualTo(hqp("foo", 10, 7));
|
||||
assertThat(hqp(null, 10, 7)).isEqualTo(hqp(null, 10, 7));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCode() throws Exception {
|
||||
|
||||
assertThat(hc("foo",10, 7)).isEqualTo(hc("foo",10, 7));
|
||||
assertThat(hc("foo",10, 7)).isNotEqualTo(hc("foo", 11, 7));
|
||||
assertThat(hc("foo",10, 7)).isNotEqualTo(hc("foo", 9, 7));
|
||||
assertThat(hc("foo",10, 7)).isNotEqualTo(hc("foo", 10, 8));
|
||||
assertThat(hc("foo",10, 7)).isNotEqualTo(hc("foo", 10, 6));
|
||||
assertThat(hc("foo",10, 7)).isNotEqualTo(hc("bar", 10, 6));
|
||||
assertThat(hc("foo",10, 7)).isNotEqualTo(hc(null, 10, 7));
|
||||
assertThat(hc(null,10, 7)).isNotEqualTo(hc("foo", 10, 7));
|
||||
assertThat(hc(null,10, 7)).isEqualTo(hc(null, 10, 7));
|
||||
assertThat(hc("foo", 10, 7)).isEqualTo(hc("foo", 10, 7));
|
||||
assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("foo", 11, 7));
|
||||
assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("foo", 9, 7));
|
||||
assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("foo", 10, 8));
|
||||
assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("foo", 10, 6));
|
||||
assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("bar", 10, 6));
|
||||
assertThat(hc("foo", 10, 7)).isNotEqualTo(hc(null, 10, 7));
|
||||
assertThat(hc(null, 10, 7)).isNotEqualTo(hc("foo", 10, 7));
|
||||
assertThat(hc(null, 10, 7)).isEqualTo(hc(null, 10, 7));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,34 @@
|
||||
package com.avaje.ebeaninternal.api;
|
||||
|
||||
import com.avaje.ebean.*;
|
||||
import com.avaje.ebean.AutoTune;
|
||||
import com.avaje.ebean.BackgroundExecutor;
|
||||
import com.avaje.ebean.BeanState;
|
||||
import com.avaje.ebean.CallableSql;
|
||||
import com.avaje.ebean.DocumentStore;
|
||||
import com.avaje.ebean.ExpressionFactory;
|
||||
import com.avaje.ebean.Filter;
|
||||
import com.avaje.ebean.FutureIds;
|
||||
import com.avaje.ebean.FutureList;
|
||||
import com.avaje.ebean.FutureRowCount;
|
||||
import com.avaje.ebean.PagedList;
|
||||
import com.avaje.ebean.PersistenceContextScope;
|
||||
import com.avaje.ebean.Query;
|
||||
import com.avaje.ebean.QueryEachConsumer;
|
||||
import com.avaje.ebean.QueryEachWhileConsumer;
|
||||
import com.avaje.ebean.QueryIterator;
|
||||
import com.avaje.ebean.SqlQuery;
|
||||
import com.avaje.ebean.SqlRow;
|
||||
import com.avaje.ebean.SqlUpdate;
|
||||
import com.avaje.ebean.Transaction;
|
||||
import com.avaje.ebean.TransactionCallback;
|
||||
import com.avaje.ebean.TxCallable;
|
||||
import com.avaje.ebean.TxIsolation;
|
||||
import com.avaje.ebean.TxRunnable;
|
||||
import com.avaje.ebean.TxScope;
|
||||
import com.avaje.ebean.Update;
|
||||
import com.avaje.ebean.UpdateQuery;
|
||||
import com.avaje.ebean.ValuePair;
|
||||
import com.avaje.ebean.Version;
|
||||
import com.avaje.ebean.bean.BeanCollection;
|
||||
import com.avaje.ebean.bean.CallStack;
|
||||
import com.avaje.ebean.bean.EntityBeanIntercept;
|
||||
@@ -34,8 +62,10 @@ import java.util.Set;
|
||||
public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
|
||||
String name;
|
||||
|
||||
public TDSpiEbeanServer() {
|
||||
}
|
||||
|
||||
public TDSpiEbeanServer(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class CacheBeanDataTest extends BaseTestCase {
|
||||
|
||||
assertNotNull(cacheData);
|
||||
|
||||
EPerson newPerson = (EPerson)desc.cacheEmbeddedBeanLoad(cacheData, context);
|
||||
EPerson newPerson = (EPerson) desc.cacheEmbeddedBeanLoad(cacheData, context);
|
||||
|
||||
assertNotNull(newPerson.getId());
|
||||
assertNotNull(newPerson.getName());
|
||||
|
||||
+3
-3
@@ -53,15 +53,15 @@ public class CachedBeanDataFromBeanTest extends BaseTestCase {
|
||||
car.setDriver("Jimmy");
|
||||
car.setNotes("some notes");
|
||||
|
||||
BeanDescriptor<Car> carDesc = server.getBeanDescriptor(Car.class);
|
||||
BeanDescriptor<Car> carDesc = server.getBeanDescriptor(Car.class);
|
||||
CachedBeanData cacheData = CachedBeanDataFromBean.extract(carDesc, (EntityBean) car);
|
||||
|
||||
Car newCar = new Car();
|
||||
EntityBean entityBean = (EntityBean)newCar;
|
||||
EntityBean entityBean = (EntityBean) newCar;
|
||||
CachedBeanDataToBean.load(carDesc, entityBean, cacheData, new DefaultPersistenceContext());
|
||||
|
||||
assertEquals(newCar.getId(), car.getId());
|
||||
assertEquals(newCar.getDriver(), car.getDriver());
|
||||
assertEquals(newCar.getNotes(), car.getNotes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -32,7 +32,7 @@ public class CachedBeanDataSerializeTest extends BaseTestCase {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("name", "rob");
|
||||
map.put("some", "thing");
|
||||
map.put("whenCreated", ""+System.currentTimeMillis());
|
||||
map.put("whenCreated", "" + System.currentTimeMillis());
|
||||
|
||||
long version = System.currentTimeMillis();
|
||||
CachedBeanData write = new CachedBeanData(null, "C", map, version);
|
||||
@@ -65,13 +65,13 @@ public class CachedBeanDataSerializeTest extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Customer> customers = Ebean.find(Customer.class)
|
||||
.orderBy().asc("id")
|
||||
.setMaxRows(1).findList();
|
||||
.orderBy().asc("id")
|
||||
.setMaxRows(1).findList();
|
||||
|
||||
Customer customer = customers.get(0);
|
||||
|
||||
BeanDescriptor<Customer> desc = getBeanDescriptor(Customer.class);
|
||||
CachedBeanData extract = CachedBeanDataFromBean.extract(desc, (EntityBean)customer);
|
||||
CachedBeanData extract = CachedBeanDataFromBean.extract(desc, (EntityBean) customer);
|
||||
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
writeToStream(extract, os);
|
||||
@@ -83,7 +83,7 @@ public class CachedBeanDataSerializeTest extends BaseTestCase {
|
||||
assertEquals(read.getData(), extract.getData());
|
||||
|
||||
Customer loadCustomer = new Customer();
|
||||
CachedBeanDataToBean.load(desc, (EntityBean)loadCustomer, read, new DefaultPersistenceContext());
|
||||
CachedBeanDataToBean.load(desc, (EntityBean) loadCustomer, read, new DefaultPersistenceContext());
|
||||
|
||||
assertEquals(loadCustomer.getVersion(), customer.getVersion());
|
||||
assertEquals(loadCustomer.getId(), customer.getId());
|
||||
@@ -101,20 +101,20 @@ public class CachedBeanDataSerializeTest extends BaseTestCase {
|
||||
bean.setContent(stringContent.getBytes("UTF-8"));
|
||||
|
||||
BeanDescriptor<TBytesOnly> desc = getBeanDescriptor(TBytesOnly.class);
|
||||
CachedBeanData extract = CachedBeanDataFromBean.extract(desc, (EntityBean)bean);
|
||||
CachedBeanData extract = CachedBeanDataFromBean.extract(desc, (EntityBean) bean);
|
||||
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
writeToStream(extract, os);
|
||||
byte[] bytes = os.toByteArray();
|
||||
|
||||
CachedBeanData read = readFromStream(bytes);
|
||||
byte[] extraContent = (byte[])extract.getData("content");
|
||||
byte[] extraContent = (byte[]) extract.getData("content");
|
||||
|
||||
assertEquals(stringContent, new String(extraContent));
|
||||
assertTrue(Arrays.equals(bean.getContent(), extraContent));
|
||||
|
||||
TBytesOnly loadBean= new TBytesOnly();
|
||||
CachedBeanDataToBean.load(desc, (EntityBean)loadBean, read, new DefaultPersistenceContext());
|
||||
TBytesOnly loadBean = new TBytesOnly();
|
||||
CachedBeanDataToBean.load(desc, (EntityBean) loadBean, read, new DefaultPersistenceContext());
|
||||
|
||||
assertEquals(loadBean.getId(), bean.getId());
|
||||
assertTrue(Arrays.equals(loadBean.getContent(), bean.getContent()));
|
||||
@@ -124,7 +124,7 @@ public class CachedBeanDataSerializeTest extends BaseTestCase {
|
||||
|
||||
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
|
||||
ObjectInputStream ois = new ObjectInputStream(is);
|
||||
return (CachedBeanData)ois.readObject();
|
||||
return (CachedBeanData) ois.readObject();
|
||||
}
|
||||
|
||||
private void writeToStream(CachedBeanData extract, ByteArrayOutputStream os) throws IOException {
|
||||
@@ -135,4 +135,4 @@ public class CachedBeanDataSerializeTest extends BaseTestCase {
|
||||
oos.close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -7,7 +7,7 @@ import com.avaje.tests.model.basic.Order;
|
||||
import com.avaje.tests.model.basic.Product;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DefaultCacheHolder_getCacheOptions_Test {
|
||||
|
||||
@@ -49,4 +49,4 @@ public class DefaultCacheHolder_getCacheOptions_Test {
|
||||
ServerCacheOptions options = cacheHolder.getCacheOptions(Order.class.getName(), ServerCacheType.QUERY);
|
||||
assertEquals(options.getMaxSecsToLive(), 120);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ package com.avaje.ebeaninternal.server.cache;
|
||||
import com.avaje.ebean.cache.ServerCacheOptions;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DefaultServerCacheTest {
|
||||
|
||||
@@ -85,4 +85,4 @@ public class DefaultServerCacheTest {
|
||||
assertEquals(cache.trimFrequency, 42);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -26,7 +26,7 @@ public class DefaultServerCache_RunEvictionTest {
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
public DefaultServerCache_RunEvictionTest(){
|
||||
public DefaultServerCache_RunEvictionTest() {
|
||||
this.cache = createCache();
|
||||
}
|
||||
|
||||
@@ -46,14 +46,14 @@ public class DefaultServerCache_RunEvictionTest {
|
||||
private void doStuff() {
|
||||
|
||||
for (int i = 0; i < 500; i++) {
|
||||
String key = ""+random.nextInt(20000);
|
||||
String key = "" + random.nextInt(20000);
|
||||
|
||||
int mode = random.nextInt(10);
|
||||
if (mode < 8) {
|
||||
cache.get(key);
|
||||
} else {
|
||||
cache.put(key, key+"-"+System.currentTimeMillis());
|
||||
cache.put(key, key + "-" + System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-11
@@ -10,10 +10,7 @@ import com.avaje.tests.model.basic.Customer;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class DefaultChangeLogRegisterTest extends BaseTestCase {
|
||||
|
||||
@@ -26,17 +23,17 @@ public class DefaultChangeLogRegisterTest extends BaseTestCase {
|
||||
assertNull(register.getChangeFilter(Address.class));
|
||||
|
||||
ChangeLogFilter changeFilter = register.getChangeFilter(Customer.class);
|
||||
DefaultChangeLogRegister.UpdateFilter updateFilter = (DefaultChangeLogRegister.UpdateFilter)changeFilter;
|
||||
DefaultChangeLogRegister.UpdateFilter updateFilter = (DefaultChangeLogRegister.UpdateFilter) changeFilter;
|
||||
assertFalse(updateFilter.includeInserts);
|
||||
assertThat(updateFilter.updateProperties).containsExactly("name", "status");
|
||||
|
||||
changeFilter = register.getChangeFilter(Country.class);
|
||||
DefaultChangeLogRegister.BasicFilter countryFilter = (DefaultChangeLogRegister.BasicFilter)changeFilter;
|
||||
DefaultChangeLogRegister.BasicFilter countryFilter = (DefaultChangeLogRegister.BasicFilter) changeFilter;
|
||||
assertTrue(countryFilter.includeInserts);
|
||||
|
||||
// use default setting
|
||||
changeFilter = register.getChangeFilter(Contact.class);
|
||||
DefaultChangeLogRegister.BasicFilter contactFilter = (DefaultChangeLogRegister.BasicFilter)changeFilter;
|
||||
DefaultChangeLogRegister.BasicFilter contactFilter = (DefaultChangeLogRegister.BasicFilter) changeFilter;
|
||||
assertTrue(contactFilter.includeInserts);
|
||||
|
||||
}
|
||||
@@ -49,17 +46,17 @@ public class DefaultChangeLogRegisterTest extends BaseTestCase {
|
||||
assertNull(register.getChangeFilter(Address.class));
|
||||
|
||||
ChangeLogFilter changeFilter = register.getChangeFilter(Customer.class);
|
||||
DefaultChangeLogRegister.UpdateFilter updateFilter = (DefaultChangeLogRegister.UpdateFilter)changeFilter;
|
||||
DefaultChangeLogRegister.UpdateFilter updateFilter = (DefaultChangeLogRegister.UpdateFilter) changeFilter;
|
||||
assertFalse(updateFilter.includeInserts);
|
||||
assertThat(updateFilter.updateProperties).containsExactly("name", "status");
|
||||
|
||||
changeFilter = register.getChangeFilter(Country.class);
|
||||
DefaultChangeLogRegister.BasicFilter countryFilter = (DefaultChangeLogRegister.BasicFilter)changeFilter;
|
||||
DefaultChangeLogRegister.BasicFilter countryFilter = (DefaultChangeLogRegister.BasicFilter) changeFilter;
|
||||
assertTrue(countryFilter.includeInserts);
|
||||
|
||||
// use default setting
|
||||
changeFilter = register.getChangeFilter(Contact.class);
|
||||
DefaultChangeLogRegister.BasicFilter contactFilter = (DefaultChangeLogRegister.BasicFilter)changeFilter;
|
||||
DefaultChangeLogRegister.BasicFilter contactFilter = (DefaultChangeLogRegister.BasicFilter) changeFilter;
|
||||
assertFalse(contactFilter.includeInserts);
|
||||
|
||||
}
|
||||
@@ -70,7 +67,7 @@ public class DefaultChangeLogRegisterTest extends BaseTestCase {
|
||||
DefaultChangeLogRegister register = new DefaultChangeLogRegister(true);
|
||||
ChangeLogFilter changeFilter = register.getChangeFilter(ProductConfiguration.class);
|
||||
assertNotNull(changeFilter);
|
||||
DefaultChangeLogRegister.BasicFilter basicFilter = (DefaultChangeLogRegister.BasicFilter)changeFilter;
|
||||
DefaultChangeLogRegister.BasicFilter basicFilter = (DefaultChangeLogRegister.BasicFilter) changeFilter;
|
||||
assertTrue(basicFilter.includeInserts);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Helper {
|
||||
cs.setSource("myApp");
|
||||
cs.setUserId("user234");
|
||||
cs.setUserIpAddress("123.4.5.6");
|
||||
cs.getUserContext().put("someKey","user defined input");
|
||||
cs.getUserContext().put("someKey", "user defined input");
|
||||
|
||||
List<BeanChange> changes = cs.getChanges();
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Helper {
|
||||
values.put("name", new ValuePair("rob", null));
|
||||
values.put("modified", new ValuePair(new Timestamp(System.currentTimeMillis()), null));
|
||||
|
||||
BeanChange bean = new BeanChange("mytable", startId+1, ChangeType.INSERT, null);
|
||||
BeanChange bean = new BeanChange("mytable", startId + 1, ChangeType.INSERT, null);
|
||||
bean.setValues(values);
|
||||
return bean;
|
||||
}
|
||||
@@ -55,14 +55,14 @@ public class Helper {
|
||||
|
||||
values.put("modified", new ValuePair(new Timestamp(System.currentTimeMillis()), null));
|
||||
|
||||
BeanChange bean = new BeanChange("mytable", startId+2, ChangeType.UPDATE, null);
|
||||
BeanChange bean = new BeanChange("mytable", startId + 2, ChangeType.UPDATE, null);
|
||||
bean.setValues(values);
|
||||
return bean;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private BeanChange createDelete(long startId) {
|
||||
return new BeanChange("mytable", startId+3, ChangeType.DELETE, new HashMap<>());
|
||||
return new BeanChange("mytable", startId + 3, ChangeType.DELETE, new HashMap<>());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ package com.avaje.ebeaninternal.server.core;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BasicTypeConverterTest {
|
||||
|
||||
@@ -31,4 +32,4 @@ public class BasicTypeConverterTest {
|
||||
assertFalse(BasicTypeConverter.toBoolean("F", "T"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+11
-9
@@ -5,26 +5,28 @@ import org.junit.Test;
|
||||
|
||||
public class DefaultBackgroundExecutorTest {
|
||||
|
||||
@Test @Ignore
|
||||
@Test
|
||||
@Ignore
|
||||
public void shutdown_when_running_expect_waitAndNiceShutdown() throws Exception {
|
||||
|
||||
DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 20, "test");
|
||||
|
||||
es.execute(new RunFor(3000,"a"));
|
||||
es.execute(new RunFor(3000,"b"));
|
||||
es.execute(new RunFor(3000,"c"));
|
||||
es.execute(new RunFor(3000, "a"));
|
||||
es.execute(new RunFor(3000, "b"));
|
||||
es.execute(new RunFor(3000, "c"));
|
||||
|
||||
es.shutdown();
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
@Test
|
||||
@Ignore
|
||||
public void shutdown_when_rougeRunnable_expect_InterruptedException() throws Exception {
|
||||
|
||||
DefaultBackgroundExecutor es = new DefaultBackgroundExecutor(1, 10, "test");
|
||||
|
||||
es.execute(new RunFor(300000,"a"));
|
||||
es.execute(new RunFor(3000,"b"));
|
||||
es.execute(new RunFor(3000,"c"));
|
||||
es.execute(new RunFor(300000, "a"));
|
||||
es.execute(new RunFor(3000, "b"));
|
||||
es.execute(new RunFor(3000, "c"));
|
||||
|
||||
es.shutdown();
|
||||
}
|
||||
@@ -51,4 +53,4 @@ public class DefaultBackgroundExecutorTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+60
-60
@@ -69,14 +69,14 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void when_fetch_order_different_then_different() {
|
||||
|
||||
assertDifferent(detail(query().select("id,name").fetch("details").fetch("customer")),
|
||||
detail(query().select("id,name").fetch("customer").fetch("details")));
|
||||
detail(query().select("id,name").fetch("customer").fetch("details")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void when_extra_queryFetchToMany_then_same() {
|
||||
|
||||
assertDifferent(detail(query().select("id,name").fetch("customer")),
|
||||
detail(query().select("id,name").fetch("customer").fetch("details", new FetchConfig().query())));
|
||||
detail(query().select("id,name").fetch("customer").fetch("details", new FetchConfig().query())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,7 +84,7 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
|
||||
// with the fetch of customer the foreign key must be added to the root query
|
||||
assertDifferent(detail(query().select("id,name")),
|
||||
detail(query().select("id,name").fetch("customer", new FetchConfig().query())));
|
||||
detail(query().select("id,name").fetch("customer", new FetchConfig().query())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,15 +98,15 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void when_fetchConfig_then_differentPlan() throws Exception {
|
||||
|
||||
DefaultOrmQuery<Order> query1 = (DefaultOrmQuery<Order>) Ebean.find(Order.class)
|
||||
.select("status, shipDate")
|
||||
.fetch("details", "orderQty, unitPrice", new FetchConfig().query())
|
||||
.fetch("details.product", "sku, name");
|
||||
.select("status, shipDate")
|
||||
.fetch("details", "orderQty, unitPrice", new FetchConfig().query())
|
||||
.fetch("details.product", "sku, name");
|
||||
|
||||
|
||||
DefaultOrmQuery<Order> query2 = (DefaultOrmQuery<Order>) Ebean.find(Order.class)
|
||||
.select("status, shipDate")
|
||||
.fetch("details", "orderQty, unitPrice")
|
||||
.fetch("details.product", "sku, name");
|
||||
.select("status, shipDate")
|
||||
.fetch("details", "orderQty, unitPrice")
|
||||
.fetch("details.product", "sku, name");
|
||||
|
||||
assertDifferent(detail(query1), detail(query2));
|
||||
}
|
||||
@@ -115,9 +115,9 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void testJoinOrder_when_fetchJoins_expect_detailJoinsPreserveOrder() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.select("status, orderDate")
|
||||
.fetch("customer", "name")
|
||||
.fetch("details");
|
||||
.select("status, orderDate")
|
||||
.fetch("customer", "name")
|
||||
.fetch("details");
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -129,9 +129,9 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void testJoinOrder_when_fetchJoinsAndWhere_expect_fetchJoinsOnlyInFetchPaths() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.select("status, orderDate")
|
||||
.fetch("details")
|
||||
.where().eq("customer.name", "rob").query();
|
||||
.select("status, orderDate")
|
||||
.fetch("details")
|
||||
.where().eq("customer.name", "rob").query();
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -143,9 +143,9 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void testJoinOrder_when_queryFetch_expect_getFetchPaths_doesNotIncludeQueryJoin() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.select("status, orderDate")
|
||||
.fetch("customer", "name")
|
||||
.fetch("details", new FetchConfig().query());
|
||||
.select("status, orderDate")
|
||||
.fetch("customer", "name")
|
||||
.fetch("details", new FetchConfig().query());
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -157,9 +157,9 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void testJoinOrder_when_queryFetch_expect_getFetchPaths_doesNotIncludeQueryJoin_via_fetchQuery() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.select("status, orderDate")
|
||||
.fetch("customer", "name")
|
||||
.fetchQuery("details");
|
||||
.select("status, orderDate")
|
||||
.fetch("customer", "name")
|
||||
.fetchQuery("details");
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -171,9 +171,9 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void testJoinOrder_when_lazyFetch_expect_getFetchPaths_doesNotIncludeQueryJoin() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.select("status, orderDate")
|
||||
.fetch("customer", "name")
|
||||
.fetch("details", new FetchConfig().lazy());
|
||||
.select("status, orderDate")
|
||||
.fetch("customer", "name")
|
||||
.fetch("details", new FetchConfig().lazy());
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -185,9 +185,9 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void testJoinOrder_when_lazyFetch_expect_getFetchPaths_doesNotIncludeQueryJoin_via_fetchLazy() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.select("status, orderDate")
|
||||
.fetch("customer", "name")
|
||||
.fetchLazy("details");
|
||||
.select("status, orderDate")
|
||||
.fetch("customer", "name")
|
||||
.fetchLazy("details");
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -199,10 +199,10 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void testJoinOrder_when_lazyFetchAndHasChildren_expect_getFetchPaths_doesNotIncludeJoinOrChild() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.select("status, orderDate")
|
||||
.fetch("customer", "name")
|
||||
.fetch("details", new FetchConfig().lazy())
|
||||
.fetch("details.product");
|
||||
.select("status, orderDate")
|
||||
.fetch("customer", "name")
|
||||
.fetch("details", new FetchConfig().lazy())
|
||||
.fetch("details.product");
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -214,10 +214,10 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void testJoinOrder_when_fetchMany_expect_getFetchPaths_containsAllInOrder() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.select("status, orderDate")
|
||||
.fetch("details")
|
||||
.fetch("details.product")
|
||||
.fetch("customer", "name");
|
||||
.select("status, orderDate")
|
||||
.fetch("details")
|
||||
.fetch("details.product")
|
||||
.fetch("customer", "name");
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -229,10 +229,10 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void testJoinOrder_when_queryJoin_expect_getFetchPaths_excludesQueryJoinAndChildren() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.select("status, orderDate")
|
||||
.fetch("details", new FetchConfig().query())
|
||||
.fetch("details.product")
|
||||
.fetch("customer", "name");
|
||||
.select("status, orderDate")
|
||||
.fetch("details", new FetchConfig().query())
|
||||
.fetch("details.product")
|
||||
.fetch("customer", "name");
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -244,10 +244,10 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void test_removeJoinToMany_when_multipleManyPaths() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.fetch("details")
|
||||
.fetch("details.product")
|
||||
.fetch("customer")
|
||||
.fetch("customer.contacts"); // second many path
|
||||
.fetch("details")
|
||||
.fetch("details.product")
|
||||
.fetch("customer")
|
||||
.fetch("customer.contacts"); // second many path
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -259,11 +259,11 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void test_removeAllJoinToMany_when_firstRow() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.setFirstRow(1)
|
||||
.fetch("details") // many path
|
||||
.fetch("details.product")
|
||||
.fetch("customer")
|
||||
.fetch("customer.contacts"); // many path
|
||||
.setFirstRow(1)
|
||||
.fetch("details") // many path
|
||||
.fetch("details.product")
|
||||
.fetch("customer")
|
||||
.fetch("customer.contacts"); // many path
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -275,11 +275,11 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void test_removeAllJoinToMany_when_maxRows() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.setMaxRows(1)
|
||||
.fetch("details") // many path
|
||||
.fetch("details.product")
|
||||
.fetch("customer")
|
||||
.fetch("customer.contacts"); // many path
|
||||
.setMaxRows(1)
|
||||
.fetch("details") // many path
|
||||
.fetch("details.product")
|
||||
.fetch("customer")
|
||||
.fetch("customer.contacts"); // many path
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -291,12 +291,12 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
public void test_removeJoinToMany_when_filterMany() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.fetch("details")
|
||||
.fetch("details.product")
|
||||
.fetch("customer")
|
||||
.fetch("customer.contacts")
|
||||
.filterMany("details").eq("orderQuantity", 10)
|
||||
.query();
|
||||
.fetch("details")
|
||||
.fetch("details.product")
|
||||
.fetch("customer")
|
||||
.fetch("customer.contacts")
|
||||
.filterMany("details").eq("orderQuantity", 10)
|
||||
.query();
|
||||
|
||||
OrmQueryRequest<Order> queryRequest = queryRequest(query);
|
||||
OrmQueryDetail detail = queryRequest.getQuery().getDetail();
|
||||
@@ -313,4 +313,4 @@ public class DefaultServer_createOrmQueryRequestTest extends BaseTestCase {
|
||||
assertThat(detail1.isSameByPlan(detail2)).isFalse();
|
||||
assertThat(detail1.queryPlanHash()).isNotEqualTo(detail2.queryPlanHash());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,7 @@ import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TestDiffHelpInsertSimple extends BaseTestCase {
|
||||
|
||||
|
||||
+1
-3
@@ -13,9 +13,7 @@ import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TestDiffHelpInsertWithEmbedded extends BaseTestCase {
|
||||
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
package com.avaje.ebeaninternal.server.core;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
@@ -17,21 +9,28 @@ import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import com.avaje.tests.model.basic.Order.Status;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class TestDiffHelpSimple extends BaseTestCase {
|
||||
|
||||
long firstTime = System.currentTimeMillis()-10000;
|
||||
long firstTime = System.currentTimeMillis() - 10000;
|
||||
long secondTime = System.currentTimeMillis();
|
||||
|
||||
EbeanServer server;
|
||||
BeanDescriptor<Order> orderDesc;
|
||||
|
||||
|
||||
public TestDiffHelpSimple() {
|
||||
server = Ebean.getServer(null);
|
||||
SpiEbeanServer spiServer = (SpiEbeanServer)server;
|
||||
SpiEbeanServer spiServer = (SpiEbeanServer) server;
|
||||
orderDesc = spiServer.getBeanDescriptor(Order.class);
|
||||
}
|
||||
|
||||
|
||||
private Order createBaseOrder(EbeanServer server) {
|
||||
Order order1 = new Order();
|
||||
order1.setId(12);
|
||||
@@ -42,13 +41,13 @@ public class TestDiffHelpSimple extends BaseTestCase {
|
||||
order1.setOrderDate(new Date(firstTime));
|
||||
return order1;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBasicChanges() {
|
||||
|
||||
|
||||
|
||||
|
||||
Order order1 = createBaseOrder(server);
|
||||
|
||||
|
||||
Order order2 = new Order();
|
||||
order2.setId(14);
|
||||
order2.setCretime(new Timestamp(secondTime));
|
||||
@@ -56,11 +55,11 @@ public class TestDiffHelpSimple extends BaseTestCase {
|
||||
order2.setStatus(Status.COMPLETE);
|
||||
order2.setShipDate(new Date(secondTime));
|
||||
order2.setOrderDate(new Date(secondTime));
|
||||
|
||||
|
||||
Map<String, ValuePair> diff = DiffHelp.diff(order1, order2, orderDesc);
|
||||
|
||||
|
||||
Assert.assertEquals(5, diff.size());
|
||||
|
||||
|
||||
Set<String> keySet = diff.keySet();
|
||||
Assert.assertTrue(keySet.contains("cretime"));
|
||||
Assert.assertTrue(keySet.contains("status"));
|
||||
@@ -99,74 +98,74 @@ public class TestDiffHelpSimple extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void testIdIgnored() {
|
||||
|
||||
|
||||
Order order1 = createBaseOrder(server);
|
||||
Order order2 = createBaseOrder(server);
|
||||
order2.setId(14);
|
||||
|
||||
|
||||
Map<String, ValuePair> diff = DiffHelp.diff(order1, order2, orderDesc);
|
||||
|
||||
Assert.assertEquals(0, diff.size());
|
||||
|
||||
Assert.assertEquals(0, diff.size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSecondValueNull() {
|
||||
|
||||
|
||||
Order order1 = createBaseOrder(server);
|
||||
|
||||
|
||||
Order order2 = createBaseOrder(server);
|
||||
order2.setCustomer(server.getReference(Customer.class, 2133));
|
||||
order2.setStatus(Status.COMPLETE);
|
||||
order2.setShipDate(null);
|
||||
|
||||
|
||||
Map<String, ValuePair> diff = DiffHelp.diff(order1, order2, orderDesc);
|
||||
|
||||
|
||||
Assert.assertEquals(3, diff.size());
|
||||
|
||||
|
||||
Set<String> keySet = diff.keySet();
|
||||
Assert.assertTrue(keySet.contains("status"));
|
||||
Assert.assertTrue(keySet.contains("customer.id"));
|
||||
Assert.assertTrue(keySet.contains("shipDate"));
|
||||
|
||||
|
||||
ValuePair shipDatePair = diff.get("shipDate");
|
||||
Assert.assertEquals(order1.getShipDate(),shipDatePair.getNewValue());
|
||||
Assert.assertEquals(order2.getShipDate(),shipDatePair.getOldValue());
|
||||
Assert.assertEquals(order1.getShipDate(), shipDatePair.getNewValue());
|
||||
Assert.assertEquals(order2.getShipDate(), shipDatePair.getOldValue());
|
||||
Assert.assertNull(shipDatePair.getOldValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testFirstValueNull() {
|
||||
|
||||
|
||||
Order order1 = createBaseOrder(server);
|
||||
order1.setShipDate(null);
|
||||
|
||||
Order order2 = createBaseOrder(server);
|
||||
|
||||
Order order2 = createBaseOrder(server);
|
||||
order2.setShipDate(new Date(secondTime));
|
||||
|
||||
|
||||
Map<String, ValuePair> diff = DiffHelp.diff(order1, order2, orderDesc);
|
||||
|
||||
Assert.assertEquals(1, diff.size());
|
||||
|
||||
Assert.assertEquals(1, diff.size());
|
||||
Set<String> keySet = diff.keySet();
|
||||
Assert.assertTrue(keySet.contains("shipDate"));
|
||||
|
||||
|
||||
ValuePair shipDatePair = diff.get("shipDate");
|
||||
Assert.assertEquals(order1.getShipDate(),shipDatePair.getNewValue());
|
||||
Assert.assertEquals(order2.getShipDate(),shipDatePair.getOldValue());
|
||||
Assert.assertEquals(order1.getShipDate(), shipDatePair.getNewValue());
|
||||
Assert.assertEquals(order2.getShipDate(), shipDatePair.getOldValue());
|
||||
Assert.assertNull(shipDatePair.getNewValue());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBothNull() {
|
||||
|
||||
|
||||
Order order1 = createBaseOrder(server);
|
||||
order1.setShipDate(null);
|
||||
|
||||
Order order2 = createBaseOrder(server);
|
||||
|
||||
Order order2 = createBaseOrder(server);
|
||||
order2.setShipDate(null);
|
||||
|
||||
|
||||
Map<String, ValuePair> diff = DiffHelp.diff(order1, order2, orderDesc);
|
||||
|
||||
Assert.assertEquals(0, diff.size());
|
||||
|
||||
Assert.assertEquals(0, diff.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package com.avaje.ebeaninternal.server.core;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
@@ -13,57 +8,61 @@ import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.tests.model.embedded.EMain;
|
||||
import com.avaje.tests.model.embedded.Eembeddable;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class TestDiffHelpWithEmbedded extends BaseTestCase {
|
||||
|
||||
EbeanServer server;
|
||||
|
||||
BeanDescriptor<EMain> emainDesc;
|
||||
|
||||
|
||||
public TestDiffHelpWithEmbedded() {
|
||||
server = Ebean.getServer(null);
|
||||
SpiEbeanServer spiServer = (SpiEbeanServer)server;
|
||||
SpiEbeanServer spiServer = (SpiEbeanServer) server;
|
||||
emainDesc = spiServer.getBeanDescriptor(EMain.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testChangeExistingEmbedded() {
|
||||
|
||||
|
||||
EMain emain1 = createEMain();
|
||||
EMain emain2 = createEMain();
|
||||
|
||||
|
||||
emain2.getEmbeddable().setDescription("baz");
|
||||
|
||||
|
||||
Map<String, ValuePair> diff = DiffHelp.diff(emain1, emain2, emainDesc);
|
||||
Assert.assertEquals(1, diff.size());
|
||||
ValuePair valuePair = diff.get("embeddable.description");
|
||||
|
||||
|
||||
Assert.assertNotNull(valuePair);
|
||||
Assert.assertEquals("bar",valuePair.getNewValue());
|
||||
Assert.assertEquals("baz",valuePair.getOldValue());
|
||||
Assert.assertEquals("bar", valuePair.getNewValue());
|
||||
Assert.assertEquals("baz", valuePair.getOldValue());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Same result as testChangeExistingEmbedded.
|
||||
*/
|
||||
@Test
|
||||
public void testSetViaNewEmbedded() {
|
||||
|
||||
|
||||
EMain emain1 = createEMain();
|
||||
EMain emain2 = createEMain();
|
||||
|
||||
|
||||
Eembeddable embeddable = new Eembeddable();
|
||||
embeddable.setDescription("baz");
|
||||
emain2.setEmbeddable(embeddable);
|
||||
|
||||
|
||||
|
||||
|
||||
Map<String, ValuePair> diff = DiffHelp.diff(emain1, emain2, emainDesc);
|
||||
Assert.assertEquals(1, diff.size());
|
||||
ValuePair valuePair = diff.get("embeddable.description");
|
||||
|
||||
|
||||
Assert.assertNotNull(valuePair);
|
||||
Assert.assertEquals("bar",valuePair.getNewValue());
|
||||
Assert.assertEquals("baz",valuePair.getOldValue());
|
||||
Assert.assertEquals("bar", valuePair.getNewValue());
|
||||
Assert.assertEquals("baz", valuePair.getOldValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,37 +77,37 @@ public class TestDiffHelpWithEmbedded extends BaseTestCase {
|
||||
ValuePair valuePair = diff.get("embeddable.description");
|
||||
|
||||
Assert.assertNotNull(valuePair);
|
||||
Assert.assertEquals("bar",valuePair.getNewValue());
|
||||
Assert.assertEquals("baz",valuePair.getOldValue());
|
||||
Assert.assertEquals("bar", valuePair.getNewValue());
|
||||
Assert.assertEquals("baz", valuePair.getOldValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstEmbeddedIsNull() {
|
||||
|
||||
|
||||
EMain emain1 = createEMain();
|
||||
emain1.setEmbeddable(null);
|
||||
EMain emain2 = createEMain();
|
||||
|
||||
|
||||
Map<String, ValuePair> diff = DiffHelp.diff(emain1, emain2, emainDesc);
|
||||
Assert.assertEquals(1, diff.size());
|
||||
ValuePair valuePair = diff.get("embeddable.description");
|
||||
|
||||
|
||||
Assert.assertNotNull(valuePair);
|
||||
Assert.assertNull(valuePair.getNewValue());
|
||||
Assert.assertEquals("bar", valuePair.getOldValue());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSecondEmbeddedIsNull() {
|
||||
|
||||
|
||||
EMain emain1 = createEMain();
|
||||
EMain emain2 = createEMain();
|
||||
emain2.setEmbeddable(null);
|
||||
|
||||
|
||||
Map<String, ValuePair> diff = DiffHelp.diff(emain1, emain2, emainDesc);
|
||||
Assert.assertEquals(1, diff.size());
|
||||
ValuePair valuePair = diff.get("embeddable.description");
|
||||
|
||||
|
||||
Assert.assertNotNull(valuePair);
|
||||
Assert.assertNull(valuePair.getOldValue());
|
||||
Assert.assertEquals("bar", valuePair.getNewValue());
|
||||
@@ -132,27 +131,27 @@ public class TestDiffHelpWithEmbedded extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void testBothEmbeddedIsNull() {
|
||||
|
||||
|
||||
EMain emain1 = createEMain();
|
||||
emain1.setEmbeddable(null);
|
||||
EMain emain2 = createEMain();
|
||||
emain2.setEmbeddable(null);
|
||||
|
||||
|
||||
Map<String, ValuePair> diff = DiffHelp.diff(emain1, emain2, emainDesc);
|
||||
Assert.assertEquals(0, diff.size());
|
||||
}
|
||||
|
||||
private EMain createEMain() {
|
||||
|
||||
|
||||
EMain emain = new EMain();
|
||||
emain.setName("foo");
|
||||
emain.setVersion(13l);
|
||||
|
||||
|
||||
Eembeddable embeddable = new Eembeddable();
|
||||
embeddable.setDescription("bar");
|
||||
emain.setEmbeddable(embeddable);
|
||||
|
||||
|
||||
return emain;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.avaje.ebeaninternal.server.core.bootup;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class DistillPackagesTest {
|
||||
@@ -39,7 +41,7 @@ public class DistillPackagesTest {
|
||||
@Test
|
||||
public void when_unordered_expect_naturalOrder() throws Exception {
|
||||
|
||||
List<String> distill = DistillPackages.distill(group("z.x.y","two"), group("one", "one.sub.me"));
|
||||
List<String> distill = DistillPackages.distill(group("z.x.y", "two"), group("one", "one.sub.me"));
|
||||
assertThat(distill).containsExactly("one", "two", "z.x.y");
|
||||
}
|
||||
|
||||
@@ -47,4 +49,4 @@ public class DistillPackagesTest {
|
||||
return Arrays.asList(packages);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ import org.junit.Test;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BeanCascadeInfoTest {
|
||||
|
||||
@@ -78,4 +79,4 @@ public class BeanCascadeInfoTest {
|
||||
assertFalse(info.isRefresh());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,10 +61,10 @@ public class BeanDescriptorTest extends BaseTestCase {
|
||||
from.setName("rob");
|
||||
|
||||
Customer to = new Customer();
|
||||
customerDesc.merge((EntityBean)from, (EntityBean)to);
|
||||
customerDesc.merge((EntityBean) from, (EntityBean) to);
|
||||
|
||||
assertThat(to.getId()).isEqualTo(42);
|
||||
assertThat(to.getName()).isEqualTo("rob");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -44,10 +44,10 @@ public class BeanDescriptor_documentMappingTest extends BaseTestCase {
|
||||
class TDVisitor extends DocPropertyAdapter {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
@Override
|
||||
public void visitProperty(DocPropertyMapping property) {
|
||||
sb.append(property.getName()+",");
|
||||
sb.append(property.getName() + ",");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +63,7 @@ public class BeanDescriptor_documentMappingTest extends BaseTestCase {
|
||||
|
||||
@Override
|
||||
public void visitBeginObject(DocPropertyMapping property) {
|
||||
sb.append(" object{"+property.getName()+":");
|
||||
sb.append(" object{" + property.getName() + ":");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +73,7 @@ public class BeanDescriptor_documentMappingTest extends BaseTestCase {
|
||||
|
||||
@Override
|
||||
public void visitBeginList(DocPropertyMapping property) {
|
||||
sb.append(" nested{"+property.getName()+": [");
|
||||
sb.append(" nested{" + property.getName() + ": [");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,4 +82,4 @@ public class BeanDescriptor_documentMappingTest extends BaseTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+7
-10
@@ -9,10 +9,7 @@ import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.tests.model.basic.EBasic;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class BeanDescriptor_registerTest {
|
||||
|
||||
@@ -29,7 +26,7 @@ public class BeanDescriptor_registerTest {
|
||||
config.setDefaultServer(false);
|
||||
config.getClasses().add(EBasic.class);
|
||||
|
||||
SpiEbeanServer ebeanServer = (SpiEbeanServer)EbeanServerFactory.create(config);
|
||||
SpiEbeanServer ebeanServer = (SpiEbeanServer) EbeanServerFactory.create(config);
|
||||
BeanDescriptor<EBasic> desc = ebeanServer.getBeanDescriptor(EBasic.class);
|
||||
|
||||
persistListenerRegistrationTests(desc);
|
||||
@@ -50,10 +47,10 @@ public class BeanDescriptor_registerTest {
|
||||
assertEquals(2, ((ChainedBeanPersistController) desc.getPersistController()).size());
|
||||
|
||||
desc.deregister(controller1);
|
||||
assertEquals(1, ((ChainedBeanPersistController)desc.getPersistController()).size());
|
||||
assertEquals(1, ((ChainedBeanPersistController) desc.getPersistController()).size());
|
||||
|
||||
desc.deregister(controller2);
|
||||
assertEquals(0, ((ChainedBeanPersistController)desc.getPersistController()).size());
|
||||
assertEquals(0, ((ChainedBeanPersistController) desc.getPersistController()).size());
|
||||
}
|
||||
|
||||
private void persistListenerRegistrationTests(BeanDescriptor<EBasic> desc) {
|
||||
@@ -72,10 +69,10 @@ public class BeanDescriptor_registerTest {
|
||||
assertEquals(2, ((ChainedBeanPersistListener) persistListener).size());
|
||||
|
||||
desc.deregister(listener1);
|
||||
assertEquals(1, ((ChainedBeanPersistListener)desc.getPersistListener()).size());
|
||||
assertEquals(1, ((ChainedBeanPersistListener) desc.getPersistListener()).size());
|
||||
|
||||
desc.deregister(listener2);
|
||||
assertEquals(0, ((ChainedBeanPersistListener)desc.getPersistListener()).size());
|
||||
assertEquals(0, ((ChainedBeanPersistListener) desc.getPersistListener()).size());
|
||||
}
|
||||
|
||||
public static class Listener1 extends AbstractBeanPersistListener {
|
||||
@@ -111,4 +108,4 @@ public class BeanDescriptor_registerTest {
|
||||
return EBasic.class.isAssignableFrom(cls);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -17,19 +17,19 @@ public class BeanDescriptor_whenCreatedPropertyTest extends BaseTestCase {
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
SpiEbeanServer server = (SpiEbeanServer)Ebean.getDefaultServer();
|
||||
SpiEbeanServer server = (SpiEbeanServer) Ebean.getDefaultServer();
|
||||
|
||||
BeanDescriptor<Customer> desc = server.getBeanDescriptor(Customer.class);
|
||||
|
||||
BeanProperty whenCreatedProperty = desc.getWhenCreatedProperty();
|
||||
assertEquals("cretime",whenCreatedProperty.getDbColumn());
|
||||
assertEquals("cretime", whenCreatedProperty.getDbColumn());
|
||||
|
||||
BeanProperty whenModifiedProperty = desc.getWhenModifiedProperty();
|
||||
assertEquals("updtime",whenModifiedProperty.getDbColumn());
|
||||
assertEquals("updtime", whenModifiedProperty.getDbColumn());
|
||||
|
||||
|
||||
BeanDescriptor<EBasic> eBasicDesc = server.getBeanDescriptor(EBasic.class);
|
||||
assertNull(eBasicDesc.getWhenCreatedProperty());
|
||||
assertNull(eBasicDesc.getWhenModifiedProperty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.avaje.ebeaninternal.server.deploy;
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.bean.BeanCollection;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.tests.model.basic.Contact;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Test;
|
||||
@@ -12,9 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class BeanPropertyAssocManyTest extends BaseTestCase {
|
||||
@@ -22,7 +19,7 @@ public class BeanPropertyAssocManyTest extends BaseTestCase {
|
||||
BeanDescriptor<Customer> customerDesc = spiEbeanServer().getBeanDescriptor(Customer.class);
|
||||
|
||||
BeanPropertyAssocMany<Customer> contacts() {
|
||||
return (BeanPropertyAssocMany<Customer>)customerDesc.getBeanProperty("contacts");
|
||||
return (BeanPropertyAssocMany<Customer>) customerDesc.getBeanProperty("contacts");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,4 +60,4 @@ public class BeanPropertyAssocManyTest extends BaseTestCase {
|
||||
assertThat(contactIdsForOne).isNotEmpty();
|
||||
assertThat(contactIdsForMultiple).isNotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -1,25 +1,25 @@
|
||||
package com.avaje.ebeaninternal.server.deploy;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DeployPropertyParserMapTests {
|
||||
|
||||
@Test
|
||||
public void test_like_escape() {
|
||||
|
||||
|
||||
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("customer.name", "t1.name");
|
||||
map.put("id", "t0.id");
|
||||
|
||||
|
||||
DeployPropertyParserMap parser = new DeployPropertyParserMap(map);
|
||||
|
||||
|
||||
String output = parser.parse("(lower(customer.name) like ? escape'' or id > ?)");
|
||||
Assert.assertEquals("(lower(t1.name) like ? escape'' or t0.id > ?)", output);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+22
-25
@@ -15,52 +15,49 @@ import org.junit.Test;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TestBeanDescriptorHasIdProperty extends BaseTestCase {
|
||||
|
||||
SpiEbeanServer spiServer;
|
||||
|
||||
|
||||
public TestBeanDescriptorHasIdProperty() {
|
||||
EbeanServer server = Ebean.getServer(null);
|
||||
spiServer = (SpiEbeanServer)server;
|
||||
spiServer = (SpiEbeanServer) server;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHasId() {
|
||||
|
||||
|
||||
BeanDescriptor<Order> beanDescriptor = spiServer.getBeanDescriptor(Order.class);
|
||||
assertNotNull(beanDescriptor.getIdProperty());
|
||||
assertEquals("id", beanDescriptor.getIdProperty().getName());
|
||||
|
||||
|
||||
assertNotNull(beanDescriptor.getVersionProperty());
|
||||
assertEquals("updtime", beanDescriptor.getVersionProperty().getName());
|
||||
|
||||
|
||||
Order order = new Order();
|
||||
|
||||
|
||||
assertFalse(beanDescriptor.hasIdValue(entityBean(order)));
|
||||
assertFalse(beanDescriptor.hasVersionProperty(getIntercept(order)));
|
||||
|
||||
|
||||
order.setId(23);
|
||||
order.setUpdtime(new Timestamp(System.currentTimeMillis()));
|
||||
|
||||
assertTrue(beanDescriptor.hasIdValue(entityBean(order)));
|
||||
assertTrue(beanDescriptor.hasVersionProperty(getIntercept(order)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsReference() {
|
||||
|
||||
|
||||
BeanDescriptor<Customer> beanDescriptor = spiServer.getBeanDescriptor(Customer.class);
|
||||
|
||||
|
||||
Customer order = new Customer();
|
||||
EntityBeanIntercept ebi = getIntercept(order);
|
||||
assertFalse(beanDescriptor.hasIdPropertyOnly(ebi));
|
||||
|
||||
|
||||
order.setId(23);
|
||||
assertTrue(beanDescriptor.hasIdPropertyOnly(ebi));
|
||||
|
||||
@@ -91,23 +88,23 @@ public class TestBeanDescriptorHasIdProperty extends BaseTestCase {
|
||||
|
||||
BeanDescriptor<RCustomer> rcustDesc = spiServer.getBeanDescriptor(RCustomer.class);
|
||||
|
||||
Map<String,Object> idForJson = (Map<String,Object>)rcustDesc.getIdForJson(rCustomer);
|
||||
assertEquals("comp",idForJson.get("company"));
|
||||
assertEquals("fred",idForJson.get("name"));
|
||||
Map<String, Object> idForJson = (Map<String, Object>) rcustDesc.getIdForJson(rCustomer);
|
||||
assertEquals("comp", idForJson.get("company"));
|
||||
assertEquals("fred", idForJson.get("name"));
|
||||
assertEquals(2, idForJson.size());
|
||||
|
||||
RCustomerKey keyVal = (RCustomerKey)rcustDesc.convertIdFromJson(idForJson);
|
||||
assertEquals("comp",keyVal.getCompany());
|
||||
assertEquals("fred",keyVal.getName());
|
||||
RCustomerKey keyVal = (RCustomerKey) rcustDesc.convertIdFromJson(idForJson);
|
||||
assertEquals("comp", keyVal.getCompany());
|
||||
assertEquals("fred", keyVal.getName());
|
||||
|
||||
}
|
||||
|
||||
private EntityBean entityBean(Object bean) {
|
||||
return (EntityBean)bean;
|
||||
return (EntityBean) bean;
|
||||
}
|
||||
|
||||
private EntityBeanIntercept getIntercept(Object bean) {
|
||||
return ((EntityBean)bean)._ebean_getIntercept();
|
||||
return ((EntityBean) bean)._ebean_getIntercept();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+12
-13
@@ -1,10 +1,5 @@
|
||||
package com.avaje.ebeaninternal.server.deploy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.bean.BeanCollection;
|
||||
@@ -13,30 +8,34 @@ import com.avaje.ebean.bean.EntityBeanIntercept;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.tests.model.basic.Contact;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TestCollectionLoadedStatus extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
SpiEbeanServer server = (SpiEbeanServer)Ebean.getServer(null);
|
||||
|
||||
SpiEbeanServer server = (SpiEbeanServer) Ebean.getServer(null);
|
||||
BeanDescriptor<Customer> custDesc = server.getBeanDescriptor(Customer.class);
|
||||
|
||||
|
||||
Customer customer = new Customer();
|
||||
EntityBean eb = (EntityBean)customer;
|
||||
EntityBean eb = (EntityBean) customer;
|
||||
EntityBeanIntercept ebi = eb._ebean_getIntercept();
|
||||
|
||||
|
||||
BeanProperty contactsProperty = custDesc.getBeanProperty("contacts");
|
||||
Assert.assertFalse(ebi.isLoadedProperty(contactsProperty.getPropertyIndex()));
|
||||
|
||||
|
||||
Object contactsViaInternal = contactsProperty.getValue(eb);
|
||||
Assert.assertNull(contactsViaInternal);
|
||||
Assert.assertFalse(ebi.isLoadedProperty(contactsProperty.getPropertyIndex()));
|
||||
|
||||
|
||||
List<Contact> contacts = customer.getContacts();
|
||||
Assert.assertNotNull(contacts);
|
||||
Assert.assertTrue(contacts instanceof BeanCollection);
|
||||
Assert.assertTrue(ebi.isLoadedProperty(contactsProperty.getPropertyIndex()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,22 +19,22 @@ public class TestNotEnhancedMappedSuper extends BaseTestCase {
|
||||
|
||||
Ebean.save(bean);
|
||||
Assert.assertNotNull(bean.getId());
|
||||
|
||||
|
||||
bean.setName("junk mod");
|
||||
Ebean.save(bean);
|
||||
|
||||
|
||||
ASimpleBean fetched = Ebean.find(ASimpleBean.class, bean.getId());
|
||||
Assert.assertEquals("junk mod", fetched.getName());
|
||||
Assert.assertEquals(bean.getName(), fetched.getName());
|
||||
|
||||
|
||||
Ebean.delete(bean);
|
||||
ASimpleBean fetched2 = Ebean.find(ASimpleBean.class, bean.getId());
|
||||
Assert.assertNull(fetched2);
|
||||
|
||||
|
||||
NotEnhancedMappedSuper mappedSuper = new NotEnhancedMappedSuper();
|
||||
boolean enhanced = (mappedSuper instanceof EntityBean);
|
||||
Assert.assertFalse(enhanced);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+8
-9
@@ -1,15 +1,14 @@
|
||||
package com.avaje.ebeaninternal.server.deploy;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.BeanState;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class TestReferenceWithConstructorProperties extends BaseTestCase {
|
||||
|
||||
@@ -18,21 +17,21 @@ public class TestReferenceWithConstructorProperties extends BaseTestCase {
|
||||
*/
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
|
||||
ResetBasicData.reset();
|
||||
Order order = Ebean.getReference(Order.class, 1);
|
||||
|
||||
BeanState beanState = Ebean.getBeanState(order);
|
||||
Set<String> loadedProps = beanState.getLoadedProps();
|
||||
|
||||
|
||||
Assert.assertEquals(1, loadedProps.size());
|
||||
Assert.assertTrue(beanState.isReference());
|
||||
|
||||
// read the status invokes lazy loading
|
||||
order.getStatus();
|
||||
|
||||
|
||||
Assert.assertFalse(beanState.isReference());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class UpdateTimestampFactoryTest {
|
||||
|
||||
@@ -65,4 +65,4 @@ public class UpdateTimestampFactoryTest {
|
||||
Object value = generatedProperty.getInsertValue(null, null, System.currentTimeMillis());
|
||||
assertTrue(value instanceof java.util.Date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -95,24 +95,24 @@ public class AllEqualsExpressionTest {
|
||||
}
|
||||
|
||||
AllEqualsExpression exp(String key0, Object val1) {
|
||||
LinkedHashMap<String,Object> map = new LinkedHashMap<>();
|
||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||
map.put(key0, val1);
|
||||
return exp(map);
|
||||
}
|
||||
|
||||
|
||||
AllEqualsExpression exp(String key0, Object val1, String key2, Object val2) {
|
||||
LinkedHashMap<String,Object> map = new LinkedHashMap<>();
|
||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||
map.put(key0, val1);
|
||||
map.put(key2, val2);
|
||||
return exp(map);
|
||||
}
|
||||
|
||||
AllEqualsExpression exp(String key0, Object val1, String key2, Object val2, String key3, Object val3) {
|
||||
LinkedHashMap<String,Object> map = new LinkedHashMap<>();
|
||||
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
|
||||
map.put(key0, val1);
|
||||
map.put(key2, val2);
|
||||
map.put(key3, val3);
|
||||
return exp(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -33,19 +33,19 @@ public class DefaultExampleExpressionTest extends BaseTestCase {
|
||||
|
||||
DefaultExampleExpression exp() {
|
||||
Customer customer = customer();
|
||||
return new DefaultExampleExpression((EntityBean)customer, false, LikeType.EQUAL_TO);
|
||||
return new DefaultExampleExpression((EntityBean) customer, false, LikeType.EQUAL_TO);
|
||||
}
|
||||
|
||||
DefaultExampleExpression expExtra() {
|
||||
Customer customer = customer();
|
||||
customer.setSmallnote("smallNote");
|
||||
return new DefaultExampleExpression((EntityBean)customer, false, LikeType.EQUAL_TO);
|
||||
return new DefaultExampleExpression((EntityBean) customer, false, LikeType.EQUAL_TO);
|
||||
}
|
||||
|
||||
DefaultExampleExpression expDiffName() {
|
||||
Customer customer = customer();
|
||||
customer.setName("otherName");
|
||||
return new DefaultExampleExpression((EntityBean)customer, false, LikeType.EQUAL_TO);
|
||||
return new DefaultExampleExpression((EntityBean) customer, false, LikeType.EQUAL_TO);
|
||||
}
|
||||
|
||||
BeanDescriptor<Customer> customerBeanDescriptor() {
|
||||
@@ -54,7 +54,7 @@ public class DefaultExampleExpressionTest extends BaseTestCase {
|
||||
|
||||
DefaultExampleExpression prepare(DefaultExampleExpression expr) {
|
||||
|
||||
SpiQuery<Customer> query = (SpiQuery<Customer>)spiEbeanServer().find(Customer.class);
|
||||
SpiQuery<Customer> query = (SpiQuery<Customer>) spiEbeanServer().find(Customer.class);
|
||||
BeanQueryRequest<?> request = create(query);
|
||||
expr.containsMany(customerBeanDescriptor(), new ManyWhereJoins());
|
||||
expr.prepareExpression(request);
|
||||
@@ -83,8 +83,8 @@ public class DefaultExampleExpressionTest extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query1 = server().find(Customer.class)
|
||||
.where().exampleLike(customer)
|
||||
.query();
|
||||
.where().exampleLike(customer)
|
||||
.query();
|
||||
|
||||
query1.findList();
|
||||
|
||||
@@ -121,4 +121,4 @@ public class DefaultExampleExpressionTest extends BaseTestCase {
|
||||
assertThat(prepare(expExtra()).isSameByPlan(prepare(exp()))).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -14,56 +14,56 @@ public class DefaultExpressionListTest {
|
||||
}
|
||||
|
||||
DefaultExpressionList spi(ExpressionList list) {
|
||||
return (DefaultExpressionList)list;
|
||||
return (DefaultExpressionList) list;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_same() {
|
||||
|
||||
assertThat(spi(exp().eq("a", 10).eq("b", 20))
|
||||
.isSameByPlan(spi(exp().eq("a", 10).eq("b", 20)))).isTrue();
|
||||
.isSameByPlan(spi(exp().eq("a", 10).eq("b", 20)))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffExpressionType() {
|
||||
|
||||
assertThat(spi(exp().eq("a", 10).eq("b", 20))
|
||||
.isSameByPlan(new NoopExpression())).isFalse();
|
||||
.isSameByPlan(new NoopExpression())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_less() {
|
||||
|
||||
assertThat(spi(exp().eq("a", 10).eq("b", 20))
|
||||
.isSameByPlan(spi(exp().eq("a", 10)))).isFalse();
|
||||
.isSameByPlan(spi(exp().eq("a", 10)))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_lessEmptyLast() {
|
||||
|
||||
assertThat(spi(exp().eq("a", 10).eq("b", 20))
|
||||
.isSameByPlan(spi(exp()))).isFalse();
|
||||
.isSameByPlan(spi(exp()))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_lessEmptyFirst() {
|
||||
|
||||
assertThat(spi(exp())
|
||||
.isSameByPlan(spi(exp().eq("a", 10)))).isFalse();
|
||||
.isSameByPlan(spi(exp().eq("a", 10)))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_more() {
|
||||
|
||||
assertThat(spi(exp().eq("a", 10).eq("b", 20))
|
||||
.isSameByPlan(spi(exp().eq("a", 10).eq("b", 20).eq("c", 30)))).isFalse();
|
||||
.isSameByPlan(spi(exp().eq("a", 10).eq("b", 20).eq("c", 30)))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffProperties() {
|
||||
|
||||
assertThat(spi(exp().eq("a", 10).eq("b", 20))
|
||||
.isSameByPlan(spi(exp().eq("c", 10).eq("b", 20)))).isFalse();
|
||||
.isSameByPlan(spi(exp().eq("c", 10).eq("b", 20)))).isFalse();
|
||||
}
|
||||
|
||||
|
||||
@@ -71,28 +71,28 @@ public class DefaultExpressionListTest {
|
||||
public void isSameByBind_when_same() {
|
||||
|
||||
assertThat(spi(exp().eq("a", 10).eq("b", 20))
|
||||
.isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isTrue();
|
||||
.isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_diffValues() {
|
||||
|
||||
assertThat(spi(exp().eq("a", 10).eq("b", 20))
|
||||
.isSameByBind(spi(exp().eq("a", 10).eq("b", 30)))).isFalse();
|
||||
.isSameByBind(spi(exp().eq("a", 10).eq("b", 30)))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_less() {
|
||||
|
||||
assertThat(spi(exp().eq("a", 10))
|
||||
.isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isFalse();
|
||||
.isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_more() {
|
||||
|
||||
assertThat(spi(exp().eq("a", 10))
|
||||
.isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isFalse();
|
||||
.isSameByBind(spi(exp().eq("a", 10).eq("b", 20)))).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -19,67 +19,67 @@ public class ExistsQueryExpressionTest {
|
||||
@Test
|
||||
public void isSameByPlan_when_same() {
|
||||
|
||||
assertThat(exp(true,"a", 10).isSameByPlan(exp(true,"a", 10))).isTrue();
|
||||
assertThat(exp(true, "a", 10).isSameByPlan(exp(true, "a", 10))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffBind_same() {
|
||||
|
||||
assertThat(exp(true,"a", 10).isSameByPlan(exp(true,"a", 20))).isTrue();
|
||||
assertThat(exp(true, "a", 10).isSameByPlan(exp(true, "a", 20))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffNot() {
|
||||
|
||||
assertThat(exp(true,"a", 10).isSameByPlan(exp(false,"a", 10))).isFalse();
|
||||
assertThat(exp(true, "a", 10).isSameByPlan(exp(false, "a", 10))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffSql() {
|
||||
|
||||
assertThat(exp(true,"a", 10).isSameByPlan(exp(true,"b", 10))).isFalse();
|
||||
assertThat(exp(true, "a", 10).isSameByPlan(exp(true, "b", 10))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_sameBindValues() {
|
||||
|
||||
assertThat(exp(true,"a", 10).isSameByBind(exp(true,"a", 10))).isTrue();
|
||||
assertThat(exp(true, "a", 10).isSameByBind(exp(true, "a", 10))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_sameMultipleBindValues() {
|
||||
|
||||
assertThat(exp(true,"a", 10, "ABC", 20).isSameByBind(exp(true,"a", 10, "ABC", 20))).isTrue();
|
||||
assertThat(exp(true, "a", 10, "ABC", 20).isSameByBind(exp(true, "a", 10, "ABC", 20))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_diffMultipleBindValues() {
|
||||
|
||||
assertThat(exp(true,"a", 10, "ABC", 20).isSameByBind(exp(true,"a", 10, "ABC", 21))).isFalse();
|
||||
assertThat(exp(true, "a", 10, "ABC", 20).isSameByBind(exp(true, "a", 10, "ABC", 21))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_diffMultipleBindValuesByOrder() {
|
||||
|
||||
assertThat(exp(true,"a", 10, "ABC", 20).isSameByBind(exp(true,"a", 10, 20, "ABC"))).isFalse();
|
||||
assertThat(exp(true, "a", 10, "ABC", 20).isSameByBind(exp(true, "a", 10, 20, "ABC"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_diffBindValues() {
|
||||
|
||||
assertThat(exp(true,"a", 10).isSameByBind(exp(true,"a", 20))).isFalse();
|
||||
assertThat(exp(true, "a", 10).isSameByBind(exp(true, "a", 20))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_lessBindValues() {
|
||||
|
||||
assertThat(exp(true,"a", 10, 20).isSameByBind(exp(true,"a", 20))).isFalse();
|
||||
assertThat(exp(true, "a", 10, 20).isSameByBind(exp(true, "a", 20))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_moreBindValues() {
|
||||
|
||||
assertThat(exp(true,"a", 10).isSameByBind(exp(true,"a", 10, 20))).isFalse();
|
||||
assertThat(exp(true, "a", 10).isSameByBind(exp(true, "a", 10, 20))).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class IdInExpressionTest {
|
||||
@Test
|
||||
public void isSameByBind_when_mulitpleSameBindValues() {
|
||||
|
||||
assertThat(exp(10,"ABC", 20).isSameByBind(exp(10, "ABC", 20))).isTrue();
|
||||
assertThat(exp(10, "ABC", 20).isSameByBind(exp(10, "ABC", 20))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -54,14 +54,14 @@ public class IdInExpressionTest {
|
||||
@Test
|
||||
public void isSameByBind_when_lessBindValues() {
|
||||
|
||||
assertThat(exp(10,"ABC", 20).isSameByBind(exp(10, "ABC"))).isFalse();
|
||||
assertThat(exp(10, "ABC", 20).isSameByBind(exp(10, "ABC"))).isFalse();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_moreBindValues() {
|
||||
|
||||
assertThat(exp(10,"ABC").isSameByBind(exp(10, "ABC", 30))).isFalse();
|
||||
assertThat(exp(10, "ABC").isSameByBind(exp(10, "ABC", 30))).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -18,72 +18,72 @@ public class InQueryExpressionTest {
|
||||
@Test
|
||||
public void isSameByPlan_when_same() {
|
||||
|
||||
assertThat(exp("name",true,"sql", 10).isSameByPlan(exp("name",true,"sql", 10))).isTrue();
|
||||
assertThat(exp("name", true, "sql", 10).isSameByPlan(exp("name", true, "sql", 10))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffBind_same() {
|
||||
|
||||
assertThat(exp("name",true,"sql", 10).isSameByPlan(exp("name",true,"sql", 20))).isTrue();
|
||||
assertThat(exp("name", true, "sql", 10).isSameByPlan(exp("name", true, "sql", 20))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffNPropertyName() {
|
||||
|
||||
assertThat(exp("name",true,"sql", 10).isSameByPlan(exp("nameDiff",true,"sql", 10))).isFalse();
|
||||
assertThat(exp("name", true, "sql", 10).isSameByPlan(exp("nameDiff", true, "sql", 10))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffNot() {
|
||||
|
||||
assertThat(exp("name",true,"sql", 10).isSameByPlan(exp("name",false,"sql", 10))).isFalse();
|
||||
assertThat(exp("name", true, "sql", 10).isSameByPlan(exp("name", false, "sql", 10))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffSql() {
|
||||
|
||||
assertThat(exp("name",true,"sql", 10).isSameByPlan(exp("name",true,"sqlDiff", 10))).isFalse();
|
||||
assertThat(exp("name", true, "sql", 10).isSameByPlan(exp("name", true, "sqlDiff", 10))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_sameBindValues() {
|
||||
|
||||
assertThat(exp("name",true,"sql", 10).isSameByBind(exp("name",true,"sql", 10))).isTrue();
|
||||
assertThat(exp("name", true, "sql", 10).isSameByBind(exp("name", true, "sql", 10))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_sameMultipleBindValues() {
|
||||
|
||||
assertThat(exp("name",true,"sql", 10, "ABC", 20).isSameByBind(exp("name",true,"sql", 10, "ABC", 20))).isTrue();
|
||||
assertThat(exp("name", true, "sql", 10, "ABC", 20).isSameByBind(exp("name", true, "sql", 10, "ABC", 20))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_diffMultipleBindValues() {
|
||||
|
||||
assertThat(exp("name",true,"sql", 10, "ABC", 20).isSameByBind(exp("name",true,"sql", 10, "ABC", 21))).isFalse();
|
||||
assertThat(exp("name", true, "sql", 10, "ABC", 20).isSameByBind(exp("name", true, "sql", 10, "ABC", 21))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_diffMultipleBindValuesByOrder() {
|
||||
|
||||
assertThat(exp("name",true,"sql", 10, "ABC", 20).isSameByBind(exp("name",true,"sql", 10, 20, "ABC"))).isFalse();
|
||||
assertThat(exp("name", true, "sql", 10, "ABC", 20).isSameByBind(exp("name", true, "sql", 10, 20, "ABC"))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_diffBindValues() {
|
||||
|
||||
assertThat(exp("name",true,"sql", 10).isSameByBind(exp("name",true,"sql", 20))).isFalse();
|
||||
assertThat(exp("name", true, "sql", 10).isSameByBind(exp("name", true, "sql", 20))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_lessBindValues() {
|
||||
|
||||
assertThat(exp("name",true,"sql", 10, 20).isSameByBind(exp("name",true,"sql", 20))).isFalse();
|
||||
assertThat(exp("name", true, "sql", 10, 20).isSameByBind(exp("name", true, "sql", 20))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_moreBindValues() {
|
||||
|
||||
assertThat(exp("name",true,"sql", 10).isSameByBind(exp("name",true,"sql", 10, 20))).isFalse();
|
||||
assertThat(exp("name", true, "sql", 10).isSameByBind(exp("name", true, "sql", 10, 20))).isFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-22
@@ -18,9 +18,9 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = Ebean.find(Customer.class)
|
||||
.select("id")
|
||||
.where().isEmpty("contacts")
|
||||
.query();
|
||||
.select("id")
|
||||
.where().isEmpty("contacts")
|
||||
.query();
|
||||
|
||||
query.findList();
|
||||
assertThat(sqlOf(query)).contains("select t0.id from o_customer t0 where not exists (select 1 from contact where customer_id = t0.id");
|
||||
@@ -32,9 +32,9 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = Ebean.find(Customer.class)
|
||||
.select("id")
|
||||
.where().isNotEmpty("contacts")
|
||||
.query();
|
||||
.select("id")
|
||||
.where().isNotEmpty("contacts")
|
||||
.query();
|
||||
|
||||
query.findList();
|
||||
assertThat(sqlOf(query)).contains("select t0.id from o_customer t0 where exists (select 1 from contact where customer_id = t0.id");
|
||||
@@ -46,9 +46,9 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Contact> query = Ebean.find(Contact.class)
|
||||
.select("id")
|
||||
.where().isEmpty("notes")
|
||||
.query();
|
||||
.select("id")
|
||||
.where().isEmpty("notes")
|
||||
.query();
|
||||
|
||||
query.findList();
|
||||
assertThat(sqlOf(query)).contains("select t0.id from contact t0 where not exists (select 1 from contact_note where contact_id = t0.id");
|
||||
@@ -60,9 +60,9 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Contact> query = Ebean.find(Contact.class)
|
||||
.select("id")
|
||||
.where().isNotEmpty("notes")
|
||||
.query();
|
||||
.select("id")
|
||||
.where().isNotEmpty("notes")
|
||||
.query();
|
||||
|
||||
query.findList();
|
||||
assertThat(sqlOf(query)).contains("select t0.id from contact t0 where exists (select 1 from contact_note where contact_id = t0.id");
|
||||
@@ -75,9 +75,9 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Contact> query = Ebean.find(Contact.class)
|
||||
.select("id")
|
||||
.where().isEmpty("notes")
|
||||
.query();
|
||||
.select("id")
|
||||
.where().isEmpty("notes")
|
||||
.query();
|
||||
|
||||
query.findList();
|
||||
}
|
||||
@@ -89,9 +89,9 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = Ebean.find(Customer.class)
|
||||
.select("id")
|
||||
.where().isEmpty("contacts.notes")
|
||||
.query();
|
||||
.select("id")
|
||||
.where().isEmpty("contacts.notes")
|
||||
.query();
|
||||
|
||||
query.findList();
|
||||
assertThat(sqlOf(query)).contains("select distinct t0.id from o_customer t0 join contact u1 on u1.customer_id = t0.id where not exists (select 1 from contact_note where contact_id = u1.id)");
|
||||
@@ -103,12 +103,12 @@ public class IsEmptyExpressionQueryTest extends BaseTestCase {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = Ebean.find(Customer.class)
|
||||
.select("id")
|
||||
.where().isNotEmpty("contacts.notes")
|
||||
.query();
|
||||
.select("id")
|
||||
.where().isNotEmpty("contacts.notes")
|
||||
.query();
|
||||
|
||||
query.findList();
|
||||
assertThat(sqlOf(query)).contains("select distinct t0.id from o_customer t0 join contact u1 on u1.customer_id = t0.id where exists (select 1 from contact_note where contact_id = u1.id)");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,27 +35,27 @@ public class JunctionExpressionTest {
|
||||
public void isSameByPlan_when_same() {
|
||||
|
||||
assertThat(and(exp(eq("a", 10), eq("b", 10)))
|
||||
.isSameByPlan(and(exp(eq("a", 10), eq("b", 10))))).isTrue();
|
||||
.isSameByPlan(and(exp(eq("a", 10), eq("b", 10))))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void copyForPlanKey_isSameByPlan_when_same() {
|
||||
|
||||
assertThat(and(exp(eq("a", 10), eq("b", 10)).copyForPlanKey())
|
||||
.isSameByPlan(and(exp(eq("a", 10), eq("b", 10))))).isTrue();
|
||||
.isSameByPlan(and(exp(eq("a", 10), eq("b", 10))))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void copyForPlanKey_isSameByPlan_when_diff() {
|
||||
|
||||
assertThat(and(exp(eq("a", 10), eq("b", 10)).copyForPlanKey())
|
||||
.isSameByPlan(and(exp(eq("a", 10), eq("c", 10))))).isFalse();
|
||||
.isSameByPlan(and(exp(eq("a", 10), eq("c", 10))))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffType() {
|
||||
|
||||
assertThat(and(exp(eq("a", 10), eq("b", 10)))
|
||||
.isSameByPlan(or(exp(eq("a", 10), eq("b", 10))))).isFalse();
|
||||
.isSameByPlan(or(exp(eq("a", 10), eq("b", 10))))).isFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,35 +18,35 @@ public class LikeExpressionTest extends BaseExpressionTest {
|
||||
public void isSameByPlan_when_same() {
|
||||
|
||||
assertThat(exp("a", "rob", true, LikeType.STARTS_WITH)
|
||||
.isSameByPlan(exp("a", "rob", true, LikeType.STARTS_WITH))).isTrue();
|
||||
.isSameByPlan(exp("a", "rob", true, LikeType.STARTS_WITH))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffBind_then_stillSame() {
|
||||
|
||||
assertThat(exp("a", "rob", true, LikeType.STARTS_WITH)
|
||||
.isSameByPlan(exp("a", "bor", true, LikeType.STARTS_WITH))).isTrue();
|
||||
.isSameByPlan(exp("a", "bor", true, LikeType.STARTS_WITH))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffCaseInsensitive() {
|
||||
|
||||
assertThat(exp("a", "rob", true, LikeType.STARTS_WITH)
|
||||
.isSameByPlan(exp("a", "rob", false, LikeType.STARTS_WITH))).isFalse();
|
||||
.isSameByPlan(exp("a", "rob", false, LikeType.STARTS_WITH))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffLikeType() {
|
||||
|
||||
assertThat(exp("a", "rob", true, LikeType.STARTS_WITH)
|
||||
.isSameByPlan(exp("a", "rob", true, LikeType.ENDS_WITH))).isFalse();
|
||||
.isSameByPlan(exp("a", "rob", true, LikeType.ENDS_WITH))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffProperty() {
|
||||
|
||||
assertThat(exp("a", "rob", true, LikeType.STARTS_WITH)
|
||||
.isSameByPlan(exp("b", "rob", true, LikeType.STARTS_WITH))).isFalse();
|
||||
.isSameByPlan(exp("b", "rob", true, LikeType.STARTS_WITH))).isFalse();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,13 +54,13 @@ public class LikeExpressionTest extends BaseExpressionTest {
|
||||
public void isSameByBind_when_sameBindValues() {
|
||||
|
||||
assertThat(exp("a", "rob", true, LikeType.STARTS_WITH)
|
||||
.isSameByBind(exp("a", "rob", true, LikeType.STARTS_WITH))).isTrue();
|
||||
.isSameByBind(exp("a", "rob", true, LikeType.STARTS_WITH))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_diffBindValues() {
|
||||
|
||||
assertThat(exp("a", "rob", true, LikeType.STARTS_WITH)
|
||||
.isSameByBind(exp("a", "bor", true, LikeType.STARTS_WITH))).isFalse();
|
||||
.isSameByBind(exp("a", "bor", true, LikeType.STARTS_WITH))).isFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,56 +25,56 @@ public class LogicExpressionTest extends BaseExpressionTest {
|
||||
public void isSameByPlan_when_same() {
|
||||
|
||||
assertThat(and(eq("a", 10), eq("b", 10))
|
||||
.isSameByPlan(and(eq("a", 10), eq("b", 10)))).isTrue();
|
||||
.isSameByPlan(and(eq("a", 10), eq("b", 10)))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffBind_then_stillSame() {
|
||||
|
||||
assertThat(and(eq("a", 10), eq("b", 10))
|
||||
.isSameByPlan(and(eq("a", 20), eq("b", 20)))).isTrue();
|
||||
.isSameByPlan(and(eq("a", 20), eq("b", 20)))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffExp1_then_diff() {
|
||||
|
||||
assertThat(and(eq("a", 10), eq("b", 10))
|
||||
.isSameByPlan(and(eq("c", 10), eq("b", 10)))).isFalse();
|
||||
.isSameByPlan(and(eq("c", 10), eq("b", 10)))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffExp2_then_diff() {
|
||||
|
||||
assertThat(and(eq("a", 10), eq("b", 10))
|
||||
.isSameByPlan(and(eq("a", 10), eq("c", 10)))).isFalse();
|
||||
.isSameByPlan(and(eq("a", 10), eq("c", 10)))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffType_then_diff() {
|
||||
|
||||
assertThat(or(eq("a", 10), eq("b", 10))
|
||||
.isSameByPlan(and(eq("a", 10), eq("c", 10)))).isFalse();
|
||||
.isSameByPlan(and(eq("a", 10), eq("c", 10)))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_diffExpressionType() {
|
||||
|
||||
assertThat(or(eq("a", 10), eq("b", 10))
|
||||
.isSameByPlan(new NoopExpression())).isFalse();
|
||||
.isSameByPlan(new NoopExpression())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_sameBindValues() {
|
||||
|
||||
assertThat(and(eq("a", 10), eq("b", 10))
|
||||
.isSameByBind(and(eq("a", 10), eq("c", 10)))).isTrue();
|
||||
.isSameByBind(and(eq("a", 10), eq("c", 10)))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_diffBindValues() {
|
||||
|
||||
assertThat(and(eq("a", 10), eq("b", 10))
|
||||
.isSameByBind(and(eq("a", 10), eq("c", 20)))).isFalse();
|
||||
.isSameByBind(and(eq("a", 10), eq("c", 20)))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,9 +109,9 @@ public class LogicExpressionTest extends BaseExpressionTest {
|
||||
|
||||
assertThat(path).isNull();
|
||||
assertThat(and.expOne).isInstanceOf(NestedPathWrapperExpression.class);
|
||||
assertThat(((NestedPathWrapperExpression)and.expOne).nestedPath).isEqualTo("details");
|
||||
assertThat(((NestedPathWrapperExpression) and.expOne).nestedPath).isEqualTo("details");
|
||||
assertThat(and.expTwo).isInstanceOf(NestedPathWrapperExpression.class);
|
||||
assertThat(((NestedPathWrapperExpression)and.expTwo).nestedPath).isEqualTo("shipments");
|
||||
assertThat(((NestedPathWrapperExpression) and.expTwo).nestedPath).isEqualTo("shipments");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -123,7 +123,7 @@ public class LogicExpressionTest extends BaseExpressionTest {
|
||||
|
||||
assertThat(path).isNull();
|
||||
assertThat(and.expOne).isInstanceOf(NestedPathWrapperExpression.class);
|
||||
assertThat(((NestedPathWrapperExpression)and.expOne).nestedPath).isEqualTo("details");
|
||||
assertThat(((NestedPathWrapperExpression) and.expOne).nestedPath).isEqualTo("details");
|
||||
assertThat(and.expTwo).isInstanceOf(SimpleExpression.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ public class NoopExpressionTest extends BaseTestCase {
|
||||
public void test() {
|
||||
|
||||
Query<Customer> query = Ebean.find(Customer.class)
|
||||
.select("id")
|
||||
.where().add(NoopExpression.INSTANCE)
|
||||
.query();
|
||||
.select("id")
|
||||
.where().add(NoopExpression.INSTANCE)
|
||||
.query();
|
||||
|
||||
query.findList();
|
||||
String generatedSql = sqlOf(query);
|
||||
@@ -29,11 +29,11 @@ public class NoopExpressionTest extends BaseTestCase {
|
||||
public void test_withPreAndPost() {
|
||||
|
||||
Query<Customer> query = Ebean.find(Customer.class)
|
||||
.select("id")
|
||||
.where().eq("name", null)
|
||||
.add(NoopExpression.INSTANCE)
|
||||
.ne("status", null)
|
||||
.query();
|
||||
.select("id")
|
||||
.where().eq("name", null)
|
||||
.add(NoopExpression.INSTANCE)
|
||||
.ne("status", null)
|
||||
.query();
|
||||
|
||||
query.findList();
|
||||
String generatedSql = sqlOf(query);
|
||||
|
||||
@@ -18,41 +18,41 @@ public class NotExpressionTest {
|
||||
public void isSameByPlan_when_same() {
|
||||
|
||||
assertThat(not(eq("a", 10))
|
||||
.isSameByPlan(not(eq("a", 10)))).isTrue();
|
||||
.isSameByPlan(not(eq("a", 10)))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_sameByPlan() {
|
||||
|
||||
assertThat(not(eq("a", 10))
|
||||
.isSameByPlan(not(eq("a", 20)))).isTrue();
|
||||
.isSameByPlan(not(eq("a", 20)))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_different() {
|
||||
|
||||
assertThat(not(eq("a", 10))
|
||||
.isSameByPlan(not(eq("b", 10)))).isFalse();
|
||||
.isSameByPlan(not(eq("b", 10)))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_when_differentExpressionType() {
|
||||
|
||||
assertThat(not(eq("a", 10))
|
||||
.isSameByPlan(new NoopExpression())).isFalse();
|
||||
.isSameByPlan(new NoopExpression())).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_same() {
|
||||
|
||||
assertThat(not(eq("a", 10))
|
||||
.isSameByBind(not(eq("b", 10)))).isTrue();
|
||||
.isSameByBind(not(eq("b", 10)))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByBind_when_different() {
|
||||
|
||||
assertThat(not(eq("a", 10))
|
||||
.isSameByBind(not(eq("a", 20)))).isFalse();
|
||||
.isSameByBind(not(eq("a", 20)))).isFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,28 +68,28 @@ public class NullExpressionTest extends BaseExpressionTest {
|
||||
public void isSameByBind_true() throws Exception {
|
||||
|
||||
assertThat(nullExp("customer.name", false)
|
||||
.isSameByBind(nullExp("customer.name", false))).isTrue();
|
||||
.isSameByBind(nullExp("customer.name", false))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_true() throws Exception {
|
||||
|
||||
assertThat(nullExp("customer.name", false)
|
||||
.isSameByPlan(nullExp("customer.name", false))).isTrue();
|
||||
.isSameByPlan(nullExp("customer.name", false))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_false_when_notNullDiff() throws Exception {
|
||||
|
||||
assertThat(new NullExpression("customer.name", false)
|
||||
.isSameByPlan(new NullExpression("customer.name", true))).isFalse();
|
||||
.isSameByPlan(new NullExpression("customer.name", true))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameByPlan_false_when_propertyNameDiff() throws Exception {
|
||||
|
||||
assertThat(new NullExpression("customer.startDate", true)
|
||||
.isSameByPlan(new NullExpression("customer.name", true))).isFalse();
|
||||
.isSameByPlan(new NullExpression("customer.name", true))).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ public class PrepareDocNestedTest extends BaseTestCase {
|
||||
public void prepare() throws Exception {
|
||||
|
||||
ExpressionList<Order> where = Ebean.find(Order.class)
|
||||
.where()
|
||||
.gt("details.orderQty", 1)
|
||||
.query().where();
|
||||
.where()
|
||||
.gt("details.orderQty", 1)
|
||||
.query().where();
|
||||
|
||||
|
||||
DefaultExpressionList<?> exp = (DefaultExpressionList<?>)where;
|
||||
DefaultExpressionList<?> exp = (DefaultExpressionList<?>) where;
|
||||
PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class));
|
||||
|
||||
List<SpiExpression> underlyingList = exp.getUnderlyingList();
|
||||
@@ -34,13 +34,13 @@ public class PrepareDocNestedTest extends BaseTestCase {
|
||||
public void prepare_when_multipleOfSamePath() throws Exception {
|
||||
|
||||
ExpressionList<Order> where = Ebean.find(Order.class)
|
||||
.where()
|
||||
.gt("details.orderQty", 1)
|
||||
.gt("details.unitPrice", 1)
|
||||
.query().where();
|
||||
.where()
|
||||
.gt("details.orderQty", 1)
|
||||
.gt("details.unitPrice", 1)
|
||||
.query().where();
|
||||
|
||||
|
||||
DefaultExpressionList<?> exp = (DefaultExpressionList<?>)where;
|
||||
DefaultExpressionList<?> exp = (DefaultExpressionList<?>) where;
|
||||
PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class));
|
||||
|
||||
List<SpiExpression> underlyingList = exp.getUnderlyingList();
|
||||
@@ -52,21 +52,21 @@ public class PrepareDocNestedTest extends BaseTestCase {
|
||||
public void prepare_when_mixed() throws Exception {
|
||||
|
||||
ExpressionList<Order> where = Ebean.find(Order.class)
|
||||
.where()
|
||||
.gt("customer.id", 1)
|
||||
.gt("details.orderQty", 1)
|
||||
.gt("details.unitPrice", 1)
|
||||
.query().where();
|
||||
.where()
|
||||
.gt("customer.id", 1)
|
||||
.gt("details.orderQty", 1)
|
||||
.gt("details.unitPrice", 1)
|
||||
.query().where();
|
||||
|
||||
|
||||
DefaultExpressionList<?> exp = (DefaultExpressionList<?>)where;
|
||||
DefaultExpressionList<?> exp = (DefaultExpressionList<?>) where;
|
||||
PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class));
|
||||
|
||||
List<SpiExpression> underlyingList = exp.getUnderlyingList();
|
||||
assertEquals(underlyingList.size(), 2);
|
||||
assertNull(exp.allDocNestedPath);
|
||||
|
||||
DefaultExpressionList<?> second = (DefaultExpressionList<?>)underlyingList.get(1);
|
||||
DefaultExpressionList<?> second = (DefaultExpressionList<?>) underlyingList.get(1);
|
||||
assertEquals(second.allDocNestedPath, "details");
|
||||
}
|
||||
|
||||
@@ -74,23 +74,23 @@ public class PrepareDocNestedTest extends BaseTestCase {
|
||||
public void prepare_when_nestedJunction() throws Exception {
|
||||
|
||||
ExpressionList<Order> where = Ebean.find(Order.class)
|
||||
.where()
|
||||
.not()
|
||||
.gt("customer.id", 1)
|
||||
.gt("details.orderQty", 1)
|
||||
.gt("details.unitPrice", 1)
|
||||
.query().where();
|
||||
.where()
|
||||
.not()
|
||||
.gt("customer.id", 1)
|
||||
.gt("details.orderQty", 1)
|
||||
.gt("details.unitPrice", 1)
|
||||
.query().where();
|
||||
|
||||
DefaultExpressionList<?> exp = (DefaultExpressionList<?>)where;
|
||||
DefaultExpressionList<?> exp = (DefaultExpressionList<?>) where;
|
||||
PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class));
|
||||
|
||||
List<SpiExpression> underlyingList = exp.getUnderlyingList();
|
||||
assertEquals(underlyingList.size(), 1);
|
||||
assertNull(exp.allDocNestedPath);
|
||||
|
||||
JunctionExpression<?> junction = (JunctionExpression<?>)underlyingList.get(0);
|
||||
JunctionExpression<?> junction = (JunctionExpression<?>) underlyingList.get(0);
|
||||
List<SpiExpression> junctionUnderlying = junction.exprList.getUnderlyingList();
|
||||
JunctionExpression<?> nestedNestedPath = (JunctionExpression)junctionUnderlying.get(1);
|
||||
JunctionExpression<?> nestedNestedPath = (JunctionExpression) junctionUnderlying.get(1);
|
||||
assertEquals(nestedNestedPath.exprList.allDocNestedPath, "details");
|
||||
}
|
||||
|
||||
@@ -98,23 +98,23 @@ public class PrepareDocNestedTest extends BaseTestCase {
|
||||
public void prepare_when_nestedMultiple() throws Exception {
|
||||
|
||||
ExpressionList<Order> where = Ebean.find(Order.class)
|
||||
.where()
|
||||
.isNotNull("shipments.shipTime")
|
||||
.gt("details.orderQty", 1)
|
||||
.gt("details.unitPrice", 1)
|
||||
.query().where();
|
||||
.where()
|
||||
.isNotNull("shipments.shipTime")
|
||||
.gt("details.orderQty", 1)
|
||||
.gt("details.unitPrice", 1)
|
||||
.query().where();
|
||||
|
||||
DefaultExpressionList<?> exp = (DefaultExpressionList<?>)where;
|
||||
DefaultExpressionList<?> exp = (DefaultExpressionList<?>) where;
|
||||
PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class));
|
||||
|
||||
List<SpiExpression> underlyingList = exp.getUnderlyingList();
|
||||
assertEquals(underlyingList.size(), 2);
|
||||
assertNull(exp.allDocNestedPath);
|
||||
|
||||
DefaultExpressionList<?> shipExpr = (DefaultExpressionList<?>)underlyingList.get(0);
|
||||
DefaultExpressionList<?> shipExpr = (DefaultExpressionList<?>) underlyingList.get(0);
|
||||
assertEquals(shipExpr.allDocNestedPath, "shipments");
|
||||
|
||||
DefaultExpressionList<?> detailsExpr = (DefaultExpressionList<?>)underlyingList.get(1);
|
||||
DefaultExpressionList<?> detailsExpr = (DefaultExpressionList<?>) underlyingList.get(1);
|
||||
assertEquals(detailsExpr.allDocNestedPath, "details");
|
||||
}
|
||||
|
||||
@@ -123,26 +123,26 @@ public class PrepareDocNestedTest extends BaseTestCase {
|
||||
public void prepare_when_manyMixed() throws Exception {
|
||||
|
||||
ExpressionList<Order> where = Ebean.find(Order.class)
|
||||
.where()
|
||||
.gt("customer.id", 1) // 0
|
||||
.isNotNull("shipments.shipTime") // shipments 0
|
||||
.isNotNull("status") // 1
|
||||
.gt("details.orderQty", 1) // details 0
|
||||
.isNotNull("orderDate") // 2
|
||||
.gt("details.unitPrice", 1) // details 1
|
||||
.query().where();
|
||||
.where()
|
||||
.gt("customer.id", 1) // 0
|
||||
.isNotNull("shipments.shipTime") // shipments 0
|
||||
.isNotNull("status") // 1
|
||||
.gt("details.orderQty", 1) // details 0
|
||||
.isNotNull("orderDate") // 2
|
||||
.gt("details.unitPrice", 1) // details 1
|
||||
.query().where();
|
||||
|
||||
DefaultExpressionList<?> exp = (DefaultExpressionList<?>)where;
|
||||
DefaultExpressionList<?> exp = (DefaultExpressionList<?>) where;
|
||||
PrepareDocNested.prepare(exp, getBeanDescriptor(Order.class));
|
||||
|
||||
List<SpiExpression> underlyingList = exp.getUnderlyingList();
|
||||
assertEquals(underlyingList.size(), 5);
|
||||
assertNull(exp.allDocNestedPath);
|
||||
|
||||
DefaultExpressionList<?> shipExpr = (DefaultExpressionList<?>)underlyingList.get(3);
|
||||
DefaultExpressionList<?> shipExpr = (DefaultExpressionList<?>) underlyingList.get(3);
|
||||
assertEquals(shipExpr.allDocNestedPath, "shipments");
|
||||
|
||||
DefaultExpressionList<?> detailsExpr = (DefaultExpressionList<?>)underlyingList.get(4);
|
||||
DefaultExpressionList<?> detailsExpr = (DefaultExpressionList<?>) underlyingList.get(4);
|
||||
assertEquals(detailsExpr.allDocNestedPath, "details");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user