mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#304 - ElasticSearch integration part 1 / doc store integration
This commit is contained in:
@@ -11,17 +11,17 @@ import com.avaje.tests.model.basic.ResetBasicData;
|
||||
public class TestFilterWithEnum extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
public void test() throws InterruptedException {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
|
||||
List<Order> allOrders = Ebean.find(Order.class).findList();
|
||||
|
||||
|
||||
Filter<Order> filter = Ebean.filter(Order.class);
|
||||
List<Order> newOrders = filter.eq("status", Order.Status.NEW).filter(allOrders);
|
||||
|
||||
|
||||
Assert.assertNotNull(newOrders);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.avaje.ebean.bean;
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.EBasic;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -11,6 +12,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -41,4 +43,37 @@ public class EntityBeanInterceptTest extends BaseTestCase {
|
||||
assertTrue(ebi.hasDirtyProperty(propertyNames));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPartial_when_new() {
|
||||
|
||||
EBasic basic = new EBasic();
|
||||
EntityBeanIntercept ebi = ((EntityBean) basic)._ebean_getIntercept();
|
||||
assertThat(ebi.isPartial()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPartial_when_partial() {
|
||||
|
||||
EBasic basic = new EBasic();
|
||||
basic.setId(42);
|
||||
basic.setName("some");
|
||||
EntityBeanIntercept ebi = ((EntityBean) basic)._ebean_getIntercept();
|
||||
assertThat(ebi.isPartial()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isPartial_when_full() {
|
||||
|
||||
EBasic basic = new EBasic();
|
||||
basic.setId(42);
|
||||
basic.setName("some");
|
||||
basic.setDescription("asd");
|
||||
basic.setSomeDate(null);
|
||||
basic.setStatus(EBasic.Status.ACTIVE);
|
||||
|
||||
EntityBeanIntercept ebi = ((EntityBean) basic)._ebean_getIntercept();
|
||||
assertThat(ebi.isPartial()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.avaje.ebean.config;
|
||||
|
||||
import com.avaje.ebean.annotation.DocStoreEvent;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class DocStoreConfigTest {
|
||||
|
||||
@Test
|
||||
public void testLoadSettings() throws Exception {
|
||||
|
||||
DocStoreConfig config = new DocStoreConfig();
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("ebean.docstore.active", "true");
|
||||
properties.setProperty("ebean.docstore.bulkBatchSize", "99");
|
||||
properties.setProperty("ebean.docstore.url", "http://foo:9800");
|
||||
properties.setProperty("ebean.docstore.persist", "IGNORE");
|
||||
|
||||
PropertiesWrapper wrapper = new PropertiesWrapper("ebean", null, properties);
|
||||
|
||||
config.loadSettings(wrapper);
|
||||
|
||||
assertTrue(config.isActive());
|
||||
assertEquals("http://foo:9800", config.getUrl());
|
||||
assertEquals(DocStoreEvent.IGNORE, config.getPersist());
|
||||
assertEquals(99, config.getBulkBatchSize());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package com.avaje.ebean.plugin;
|
||||
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.FetchPath;
|
||||
import com.avaje.ebean.text.PathProperties;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.querydefn.OrmQueryDetail;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import com.avaje.tests.model.basic.OrderDetail;
|
||||
import com.avaje.tests.model.basic.Person;
|
||||
import com.avaje.tests.model.basic.Product;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class BeanTypeTest {
|
||||
|
||||
static EbeanServer server = Ebean.getDefaultServer();
|
||||
|
||||
<T> BeanType<T> beanType(Class<T> cls) {
|
||||
return server.getPluginApi().getBeanType(cls);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBeanType() throws Exception {
|
||||
assertThat(beanType(Order.class).getBeanType()).isEqualTo(Order.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTypeAtPath_when_ManyToOne() throws Exception {
|
||||
BeanType<Order> orderType = beanType(Order.class);
|
||||
BeanType<?> customerType = orderType.getBeanTypeAtPath("customer");
|
||||
assertThat(customerType.getBeanType()).isEqualTo(Customer.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTypeAtPath_when_OneToMany() throws Exception {
|
||||
BeanType<Order> orderType = beanType(Order.class);
|
||||
BeanType<?> detailsType = orderType.getBeanTypeAtPath("details");
|
||||
assertThat(detailsType.getBeanType()).isEqualTo(OrderDetail.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTypeAtPath_when_nested() throws Exception {
|
||||
BeanType<Order> orderType = beanType(Order.class);
|
||||
BeanType<?> productType = orderType.getBeanTypeAtPath("details.product");
|
||||
assertThat(productType.getBeanType()).isEqualTo(Product.class);
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void getTypeAtPath_when_simpleType() throws Exception {
|
||||
|
||||
beanType(Order.class).getBeanTypeAtPath("status");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createBean() throws Exception {
|
||||
|
||||
assertThat(beanType(Order.class).createBean()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void property() throws Exception {
|
||||
|
||||
Order order = new Order();
|
||||
order.setStatus(Order.Status.APPROVED);
|
||||
Property statusProperty = beanType(Order.class).getProperty("status");
|
||||
|
||||
assertThat(statusProperty.getVal(order)).isEqualTo(order.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBaseTable() throws Exception {
|
||||
|
||||
assertThat(beanType(Order.class).getBaseTable()).isEqualTo("o_order");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beanId_and_getBeanId() throws Exception {
|
||||
|
||||
Order order = new Order();
|
||||
order.setId(42);
|
||||
|
||||
Object id1 = beanType(Order.class).beanId(order);
|
||||
Object id2 = beanType(Order.class).getBeanId(order);
|
||||
|
||||
assertThat(id1).isEqualTo(order.getId());
|
||||
assertThat(id2).isEqualTo(order.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setBeanId() throws Exception {
|
||||
|
||||
Order order = new Order();
|
||||
beanType(Order.class).setBeanId(order, 42);
|
||||
|
||||
assertThat(42).isEqualTo(order.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isDocStoreIndex() throws Exception {
|
||||
|
||||
assertThat(beanType(Order.class).isDocStoreMapped()).isFalse();
|
||||
assertThat(beanType(Person.class).isDocStoreMapped()).isFalse();
|
||||
|
||||
assertThat(beanType(Order.class).getDocMapping()).isNotNull();
|
||||
assertThat(beanType(Person.class).getDocMapping()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void docStore_getEmbedded() throws Exception {
|
||||
|
||||
BeanDocType<Order> orderDocType = beanType(Order.class).docStore();
|
||||
FetchPath customer = orderDocType.getEmbedded("customer");
|
||||
assertThat(customer).isNotNull();
|
||||
assertThat(customer.getProperties(null)).contains("id","name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void docStore_getEmbeddedManyRoot() throws Exception {
|
||||
|
||||
BeanDocType<Order> orderDocType = beanType(Order.class).docStore();
|
||||
|
||||
FetchPath detailsPath = orderDocType.getEmbedded("details");
|
||||
assertThat(detailsPath).isNotNull();
|
||||
|
||||
FetchPath detailsRoot = orderDocType.getEmbeddedManyRoot("details");
|
||||
assertThat(detailsRoot).isNotNull();
|
||||
assertThat(detailsRoot.getProperties(null)).containsExactly("id", "details");
|
||||
assertThat(detailsRoot.hasPath("details")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDocStoreQueueId() throws Exception {
|
||||
|
||||
assertThat(beanType(Order.class).getDocStoreQueueId()).isEqualTo("order");
|
||||
assertThat(beanType(Customer.class).getDocStoreQueueId()).isEqualTo("customer");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDocStoreIndexType() throws Exception {
|
||||
|
||||
assertThat(beanType(Order.class).docStore().getIndexType()).isEqualTo("order");
|
||||
assertThat(beanType(Customer.class).docStore().getIndexType()).isEqualTo("customer");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDocStoreIndexName() throws Exception {
|
||||
|
||||
assertThat(beanType(Order.class).docStore().getIndexType()).isEqualTo("order");
|
||||
assertThat(beanType(Customer.class).docStore().getIndexType()).isEqualTo("customer");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void docStoreNested() throws Exception {
|
||||
|
||||
FetchPath parse = PathProperties.parse("id,name");
|
||||
|
||||
FetchPath nestedCustomer = beanType(Order.class).docStore().getEmbedded("customer");
|
||||
assertThat(nestedCustomer.toString()).isEqualTo(parse.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void docStoreApplyPath() throws Exception {
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void docStoreIndex() throws Exception {
|
||||
beanType(Order.class).docStore().index(1, new Order(), null);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void docStoreDeleteById() throws Exception {
|
||||
beanType(Order.class).docStore().deleteById(1, null);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void docStoreUpdateEmbedded() throws Exception {
|
||||
beanType(Order.class).docStore().updateEmbedded(1, "customer", "someJson", null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.avaje.ebean.plugin;
|
||||
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class ExpressionPathTest {
|
||||
|
||||
static EbeanServer server = Ebean.getDefaultServer();
|
||||
|
||||
<T> BeanType<T> beanType(Class<T> cls) {
|
||||
return server.getPluginApi().getBeanType(cls);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsMany_when_many() throws Exception {
|
||||
|
||||
BeanType<Order> beanType = beanType(Order.class);
|
||||
assertThat(beanType.getExpressionPath("details").containsMany()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsMany_when_manyChild() throws Exception {
|
||||
|
||||
BeanType<Order> beanType = beanType(Order.class);
|
||||
assertThat(beanType.getExpressionPath("details.id").containsMany()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsMany_when_manyGrandChild() throws Exception {
|
||||
|
||||
BeanType<Order> beanType = beanType(Order.class);
|
||||
assertThat(beanType.getExpressionPath("details.product.sku").containsMany()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsMany_when_one() throws Exception {
|
||||
|
||||
BeanType<Order> beanType = beanType(Order.class);
|
||||
assertThat(beanType.getExpressionPath("customer.name").containsMany()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsMany_when_oneWithMany() throws Exception {
|
||||
|
||||
BeanType<Order> beanType = beanType(Order.class);
|
||||
assertThat(beanType.getExpressionPath("customer.contacts").containsMany()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsMany_when_oneWithManyChild() throws Exception {
|
||||
|
||||
BeanType<Order> beanType = beanType(Order.class);
|
||||
assertThat(beanType.getExpressionPath("customer.contacts.firstName").containsMany()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void set_when_basic() throws Exception {
|
||||
|
||||
BeanType<Order> beanType = beanType(Order.class);
|
||||
Order order = new Order();
|
||||
beanType.getExpressionPath("id").set(order, 42);
|
||||
assertThat(order.getId()).isEqualTo(42);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void set_when_nested() throws Exception {
|
||||
|
||||
BeanType<Order> beanType = beanType(Order.class);
|
||||
Order order = new Order();
|
||||
beanType.getExpressionPath("customer.name").set(order, "Rob");
|
||||
assertThat(order.getCustomer().getName()).isEqualTo("Rob");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.avaje.ebean.plugin;
|
||||
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.StrictAssertions.assertThat;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class PropertyTest {
|
||||
|
||||
static EbeanServer server = Ebean.getDefaultServer();
|
||||
|
||||
<T> BeanType<T> beanType(Class<T> cls) {
|
||||
return server.getPluginApi().getBeanType(cls);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getVal() throws Exception {
|
||||
|
||||
Customer customer = new Customer();
|
||||
|
||||
Order order = new Order();
|
||||
order.setCustomer(customer);
|
||||
order.setStatus(Order.Status.APPROVED);
|
||||
|
||||
Property statusProperty = beanType(Order.class).getProperty("status");
|
||||
assertThat(statusProperty.getVal(order)).isEqualTo(order.getStatus());
|
||||
|
||||
Property customerProperty = beanType(Order.class).getProperty("customer");
|
||||
assertThat(customerProperty.getVal(order)).isEqualTo(customer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isMany_when_not() {
|
||||
|
||||
assertThat(beanType(Order.class).getProperty("status").isMany()).isFalse();
|
||||
assertThat(beanType(Order.class).getProperty("customer").isMany()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isMany_when_true() {
|
||||
|
||||
assertThat(beanType(Order.class).getProperty("details").isMany()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void name() {
|
||||
assertThat(beanType(Order.class).getProperty("status").getName()).isEqualTo("status");
|
||||
assertThat(beanType(Order.class).getProperty("customer").getName()).isEqualTo("customer");
|
||||
assertThat(beanType(Order.class).getProperty("details").getName()).isEqualTo("details");
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,12 @@ import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
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;
|
||||
|
||||
|
||||
public class SpiServerTest {
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.avaje.ebean.text.json;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.bean.PersistenceContext;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class JsonBeanReaderTest extends BaseTestCase {
|
||||
|
||||
static JsonContext json = Ebean.json();
|
||||
|
||||
@Test
|
||||
public void read() throws Exception {
|
||||
|
||||
JsonParser parser = getParser();
|
||||
JsonBeanReader<Customer> beanReader = json.createBeanReader(Customer.class, parser, null);
|
||||
|
||||
Customer customer = beanReader.read();
|
||||
assertThat(customer.getId()).isEqualTo(42);
|
||||
assertThat(customer.getName()).isEqualTo("dummy");
|
||||
}
|
||||
|
||||
private JsonParser getParser() {
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.setId(42);
|
||||
customer.setName("dummy");
|
||||
|
||||
String rawJson = json.toJson(customer);
|
||||
StringReader reader = new StringReader(rawJson);
|
||||
|
||||
return json.createParser(reader);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void forJson() throws Exception {
|
||||
|
||||
JsonParser parser = getParser();
|
||||
JsonBeanReader<Customer> beanReader = json.createBeanReader(Customer.class, parser, null);
|
||||
beanReader.read();
|
||||
|
||||
JsonParser more = getParser();
|
||||
JsonBeanReader<Customer> moreReader = beanReader.forJson(more);
|
||||
|
||||
Customer customer = moreReader.read();
|
||||
assertThat(customer.getId()).isEqualTo(42);
|
||||
assertThat(customer.getName()).isEqualTo("dummy");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistenceContextPut_when_noPC() throws Exception {
|
||||
|
||||
JsonParser parser = getParser();
|
||||
JsonBeanReader<Customer> beanReader = json.createBeanReader(Customer.class, parser, null);
|
||||
beanReader.read();
|
||||
|
||||
Customer other = new Customer();
|
||||
other.setId(54);
|
||||
|
||||
beanReader.persistenceContextPut(54, other);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistenceContextPut_when_hasPC() throws Exception {
|
||||
|
||||
JsonReadOptions options = new JsonReadOptions().setEnableLazyLoading(true);
|
||||
|
||||
JsonParser parser = getParser();
|
||||
JsonBeanReader<Customer> beanReader = json.createBeanReader(Customer.class, parser, options);
|
||||
Customer customer = beanReader.read();
|
||||
|
||||
Customer other = new Customer();
|
||||
other.setId(54);
|
||||
|
||||
beanReader.persistenceContextPut(54, other);
|
||||
PersistenceContext pc = beanReader.getPersistenceContext();
|
||||
assertThat(pc.get(Customer.class, 54)).isSameAs(other);
|
||||
assertThat(pc.get(Customer.class, 42)).isSameAs(customer);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,15 +3,24 @@ package com.avaje.ebean.text.json;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.text.PathProperties;
|
||||
import com.avaje.tests.model.basic.Contact;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
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;
|
||||
|
||||
public class JsonContextTest {
|
||||
|
||||
@@ -25,6 +34,56 @@ public class JsonContextTest {
|
||||
assertFalse(json.isSupportedType(System.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_jsonWithPersistenceContext() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Order> orders = Ebean.find(Order.class)
|
||||
.fetch("customer", "id, name")
|
||||
.where().eq("customer.id", 1)
|
||||
.findList();
|
||||
|
||||
String json = Ebean.json().toJson(orders);
|
||||
|
||||
List<Order> orders1 = Ebean.json().toList(Order.class, json);
|
||||
|
||||
Customer customer = null;
|
||||
for (Order order : orders1) {
|
||||
Customer tempCustomer = order.getCustomer();
|
||||
if (customer == null) {
|
||||
customer = tempCustomer;
|
||||
} else {
|
||||
assertThat(tempCustomer).isSameAs(customer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_json_loadContext() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Order> orders = Ebean.find(Order.class)
|
||||
.select("status")
|
||||
.fetch("customer", "id, name")
|
||||
.findList();
|
||||
|
||||
String json = Ebean.json().toJson(orders);
|
||||
|
||||
JsonReadOptions options = new JsonReadOptions().setEnableLazyLoading(true);
|
||||
|
||||
List<Order> orders1 = Ebean.json().toList(Order.class, json, options);
|
||||
|
||||
for (Order order : orders1) {
|
||||
Customer customer = order.getCustomer();
|
||||
customer.getName();
|
||||
customer.getSmallnote();
|
||||
List<Contact> contacts = customer.getContacts();
|
||||
contacts.size();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_toObject() throws Exception {
|
||||
|
||||
@@ -91,7 +150,7 @@ public class JsonContextTest {
|
||||
assertSame(customer, custReadVisitor.bean);
|
||||
assertEquals("foo", custReadVisitor.unmapped.get("unknownProp"));
|
||||
assertEquals(2, custReadVisitor.unmapped.size());
|
||||
assertEquals("foobie", ((Map<String,Object>)custReadVisitor.unmapped.get("extraProp")).get("name"));
|
||||
assertEquals("foobie", ((Map<String, Object>) custReadVisitor.unmapped.get("extraProp")).get("name"));
|
||||
assertEquals("bo", ((Map<String, Object>) custReadVisitor.unmapped.get("extraProp")).get("sim"));
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.avaje.ebean.text.json;
|
||||
|
||||
import com.avaje.ebean.FetchPath;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -8,17 +8,14 @@ import com.avaje.ebean.bean.ObjectGraphNode;
|
||||
import com.avaje.ebean.cache.ServerCacheManager;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.dbmigration.DdlGenerator;
|
||||
import com.avaje.ebean.event.readaudit.ReadAuditLogger;
|
||||
import com.avaje.ebean.event.readaudit.ReadAuditPrepare;
|
||||
import com.avaje.ebean.meta.MetaInfoManager;
|
||||
import com.avaje.ebean.plugin.SpiServer;
|
||||
import com.avaje.ebean.text.csv.CsvReader;
|
||||
import com.avaje.ebean.text.json.JsonContext;
|
||||
import com.avaje.ebeaninternal.server.core.SpiOrmQueryRequest;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.query.CQuery;
|
||||
import com.avaje.ebeaninternal.server.query.CQueryEngine;
|
||||
import com.avaje.ebeaninternal.server.transaction.RemoteTransactionEvent;
|
||||
|
||||
import javax.persistence.OptimisticLockException;
|
||||
@@ -82,6 +79,11 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentStore docStore() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadAuditLogger getReadAuditLogger() {
|
||||
return null;
|
||||
@@ -97,6 +99,11 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeanDescriptor<?> getBeanDescriptorByQueueId(String queueId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BeanDescriptor<?>> getBeanDescriptors() {
|
||||
return null;
|
||||
|
||||
@@ -9,10 +9,11 @@ import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.tests.model.basic.EBasic;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class BeanDescriptorTest {
|
||||
|
||||
@Test
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package com.avaje.ebeaninternal.server.deploy;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebeanservice.docstore.api.mapping.DocPropertyAdapter;
|
||||
import com.avaje.ebeanservice.docstore.api.mapping.DocPropertyMapping;
|
||||
import com.avaje.ebeanservice.docstore.api.mapping.DocumentMapping;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class BeanDescriptor_documentMappingTest extends BaseTestCase {
|
||||
|
||||
|
||||
@Test
|
||||
public void docMapping() {
|
||||
|
||||
BeanDescriptor<Order> desc = getBeanDescriptor(Order.class);
|
||||
|
||||
DocumentMapping documentMapping = desc.getDocMapping();
|
||||
|
||||
DocPropertyMapping properties = documentMapping.getProperties();
|
||||
|
||||
assertThat(properties).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void docMapping_visitor() {
|
||||
|
||||
BeanDescriptor<Order> desc = getBeanDescriptor(Order.class);
|
||||
|
||||
DocumentMapping documentMapping = desc.getDocMapping();
|
||||
|
||||
DocPropertyMapping properties = documentMapping.getProperties();
|
||||
|
||||
assertThat(properties).isNotNull();
|
||||
|
||||
TDVisitor tdVisitor = new TDVisitor();
|
||||
documentMapping.visit(tdVisitor);
|
||||
|
||||
assertThat(tdVisitor.sb.toString()).isEqualTo("{status,orderDate,shipDate, object{customer:id,name,}customerName, nested{details: [id,orderQty,shipQty,unitPrice,cretime,updtime,]}cretime,updtime,}");
|
||||
}
|
||||
|
||||
class TDVisitor extends DocPropertyAdapter {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@Override
|
||||
public void visitProperty(DocPropertyMapping property) {
|
||||
sb.append(property.getName()+",");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBegin() {
|
||||
|
||||
sb.append("{");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEnd() {
|
||||
sb.append("}");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBeginObject(DocPropertyMapping property) {
|
||||
sb.append(" object{"+property.getName()+":");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEndObject(DocPropertyMapping property) {
|
||||
sb.append("}");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitBeginList(DocPropertyMapping property) {
|
||||
sb.append(" nested{"+property.getName()+": [");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitEndList(DocPropertyMapping property) {
|
||||
sb.append("]}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.avaje.ebeaninternal.server.deploy;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.plugin.Property;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class BeanDescriptor_propertiesTest extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void allProperties() {
|
||||
|
||||
BeanDescriptor<Order> desc = getBeanDescriptor(Order.class);
|
||||
Collection<? extends Property> props = desc.allProperties();
|
||||
|
||||
assertThat(props).extracting("name").contains("id", "status", "orderDate", "shipDate");
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -21,15 +21,15 @@ public class BeanDescriptor_whenCreatedPropertyTest extends BaseTestCase {
|
||||
|
||||
BeanDescriptor<Customer> desc = server.getBeanDescriptor(Customer.class);
|
||||
|
||||
BeanProperty whenCreatedProperty = desc.findWhenCreatedProperty();
|
||||
BeanProperty whenCreatedProperty = desc.getWhenCreatedProperty();
|
||||
assertEquals("cretime",whenCreatedProperty.getDbColumn());
|
||||
|
||||
BeanProperty whenModifiedProperty = desc.findWhenModifiedProperty();
|
||||
BeanProperty whenModifiedProperty = desc.getWhenModifiedProperty();
|
||||
assertEquals("updtime",whenModifiedProperty.getDbColumn());
|
||||
|
||||
|
||||
BeanDescriptor<EBasic> eBasicDesc = server.getBeanDescriptor(EBasic.class);
|
||||
assertNull(eBasicDesc.findWhenCreatedProperty());
|
||||
assertNull(eBasicDesc.findWhenModifiedProperty());
|
||||
assertNull(eBasicDesc.getWhenCreatedProperty());
|
||||
assertNull(eBasicDesc.getWhenModifiedProperty());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.avaje.ebeaninternal.server.expression;
|
||||
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import com.fasterxml.jackson.core.JsonFactory;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
|
||||
public abstract class BaseElasticTest extends BaseTestCase {
|
||||
|
||||
public static JsonFactory factory = new JsonFactory();
|
||||
|
||||
public ElasticExpressionContext context(StringWriter sb) throws IOException {
|
||||
|
||||
BeanDescriptor<Order> desc = getBeanDescriptor(Order.class);
|
||||
JsonGenerator gen = factory.createGenerator(sb);
|
||||
return new ElasticExpressionContext(gen, desc);
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -54,7 +54,7 @@ public class DefaultExampleExpressionTest extends BaseTestCase {
|
||||
DefaultExampleExpression prepare(DefaultExampleExpression expr) {
|
||||
|
||||
SpiQuery<Customer> query = (SpiQuery<Customer>)spiEbeanServer().find(Customer.class);
|
||||
BeanQueryRequest<?> request = create(query, customerBeanDescriptor());
|
||||
BeanQueryRequest<?> request = create(query);
|
||||
expr.prepareExpression(request);
|
||||
|
||||
return expr;
|
||||
@@ -92,8 +92,8 @@ public class DefaultExampleExpressionTest extends BaseTestCase {
|
||||
|
||||
}
|
||||
|
||||
private <T> OrmQueryRequest<T> create(SpiQuery<T> query, BeanDescriptor<T> desc) {
|
||||
return new OrmQueryRequest<T>(null, null, query, desc, null);
|
||||
private <T> OrmQueryRequest<T> create(SpiQuery<T> query) {
|
||||
return new OrmQueryRequest<T>(null, null, query, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-3
@@ -8,12 +8,12 @@ import java.util.Arrays;
|
||||
|
||||
import static org.assertj.core.api.StrictAssertions.assertThat;
|
||||
|
||||
public class ExistsExpressionTest {
|
||||
public class ExistsQueryExpressionTest {
|
||||
|
||||
|
||||
@NotNull
|
||||
private ExistsExpression exp(boolean not, String sql, Object... bindValues) {
|
||||
return new ExistsExpression(not, sql, Arrays.asList(bindValues));
|
||||
private ExistsQueryExpression exp(boolean not, String sql, Object... bindValues) {
|
||||
return new ExistsQueryExpression(not, sql, Arrays.asList(bindValues));
|
||||
}
|
||||
|
||||
@Test
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.avaje.ebeaninternal.server.expression;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.StringWriter;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class SimpleExpressionElasticTest extends BaseElasticTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void writeElastic() throws Exception {
|
||||
|
||||
SimpleExpression eqExp = new SimpleExpression("name", Op.EQ, "rob");
|
||||
|
||||
StringWriter sb = new StringWriter();
|
||||
ElasticExpressionContext context = context(sb);
|
||||
eqExp.writeElastic(context);
|
||||
context.json().flush();
|
||||
|
||||
String json = sb.toString();
|
||||
|
||||
assertThat(json).isEqualTo("{\"term\":{\"name\":\"rob\"}}");
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package com.avaje.ebeaninternal.server.querydefn;
|
||||
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.Query;
|
||||
import com.avaje.ebeaninternal.api.SpiExpressionList;
|
||||
import com.avaje.ebeaninternal.api.SpiQuery;
|
||||
import com.avaje.ebeaninternal.server.expression.BaseElasticTest;
|
||||
import com.avaje.ebeaninternal.server.expression.ElasticExpressionContext;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class DefaultOrmQueryElasticTest extends BaseElasticTest {
|
||||
|
||||
@Test
|
||||
public void writeElastic_on_SpiExpressionList() throws IOException {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.where().eq("customer.name", "Rob")
|
||||
.query();
|
||||
|
||||
SpiQuery<Order> spiQuery = (SpiQuery<Order>)query;
|
||||
|
||||
SpiExpressionList<Order> whereExpressions = spiQuery.getWhereExpressions();
|
||||
|
||||
StringWriter sb = new StringWriter();
|
||||
ElasticExpressionContext context = context(sb);
|
||||
JsonGenerator json = context.json();
|
||||
json.writeStartObject();
|
||||
json.writeFieldName("filter");
|
||||
|
||||
whereExpressions.writeElastic(context);
|
||||
|
||||
json.writeEndObject();
|
||||
context.flush();
|
||||
|
||||
assertThat(sb.toString()).isEqualTo("{\"filter\":{\"term\":{\"customer.name\":\"Rob\"}}}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void writeElastic() throws IOException {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class)
|
||||
.select("status, customer.name, details.product.id")
|
||||
.where().eq("customer.name", "Rob")
|
||||
.query();
|
||||
|
||||
SpiQuery<Order> spiQuery = (SpiQuery<Order>)query;
|
||||
|
||||
StringWriter sb = new StringWriter();
|
||||
ElasticExpressionContext context = context(sb);
|
||||
|
||||
spiQuery.writeElastic(context);
|
||||
context.flush();
|
||||
|
||||
assertThat(sb.toString()).isEqualTo("{\"fields\":[\"status\",\"customer.name\",\"details.product.id\"],\"query\":{\"filtered\":{\"filter\":{\"term\":{\"customer.name\":\"Rob\"}}}}}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asElasticQuery() throws IOException {
|
||||
|
||||
String elasticQuery = Ebean.find(Order.class)
|
||||
.select("status")
|
||||
.where().eq("customer.name", "Rob")
|
||||
.query().asElasticQuery();
|
||||
|
||||
|
||||
assertThat(elasticQuery).isEqualTo("{\"fields\":[\"status\"],\"query\":{\"filtered\":{\"filter\":{\"term\":{\"customer.name\":\"Rob\"}}}}}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void asElasticQuery_firstRowsMaxRows() throws IOException {
|
||||
|
||||
String elasticQuery = Ebean.find(Order.class)
|
||||
.select("status")
|
||||
.setFirstRow(3)
|
||||
.setMaxRows(100)
|
||||
.where().eq("customer.name", "Rob")
|
||||
.query().asElasticQuery();
|
||||
|
||||
assertThat(elasticQuery).isEqualTo("{\"from\":3,\"size\":100,\"fields\":[\"status\"],\"query\":{\"filtered\":{\"filter\":{\"term\":{\"customer.name\":\"Rob\"}}}}}");
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,8 @@ package com.avaje.ebeaninternal.server.querydefn;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.expression.DefaultExpressionFactory;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import org.junit.Assert;
|
||||
@@ -81,11 +82,13 @@ public class TestQueryLanguage extends BaseTestCase {
|
||||
|
||||
private DefaultOrmQuery<Order> check(String q) {
|
||||
|
||||
EbeanServer server = Ebean.getServer(null);
|
||||
SpiEbeanServer server = (SpiEbeanServer)Ebean.getServer(null);
|
||||
|
||||
OrmQueryDetailParser p = new OrmQueryDetailParser(q);
|
||||
p.parse();
|
||||
DefaultOrmQuery<Order> qry = new DefaultOrmQuery<Order>(Order.class, server,
|
||||
|
||||
BeanDescriptor<Order> desc = server.getBeanDescriptor(Order.class);
|
||||
DefaultOrmQuery<Order> qry = new DefaultOrmQuery<Order>(desc, server,
|
||||
new DefaultExpressionFactory(false), (String) null);
|
||||
p.assign(qry);
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.avaje.ebeaninternal.server.text.json;
|
||||
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
import com.fasterxml.jackson.core.JsonFactory;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.sql.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class WriteJsonDirtyTest {
|
||||
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
|
||||
ResetBasicData.reset();
|
||||
List<Customer> customers = Ebean.find(Customer.class).findList();
|
||||
|
||||
Customer customer = Ebean.find(Customer.class).setId(customers.get(0).getId())
|
||||
.setUseCache(false)
|
||||
.findUnique();
|
||||
|
||||
SpiEbeanServer server = (SpiEbeanServer)Ebean.getServer(null);
|
||||
BeanDescriptor<Customer> descriptor = server.getBeanDescriptor(Customer.class);
|
||||
|
||||
customer.setName("dirtyCustName");
|
||||
customer.setAnniversary(new Date(System.currentTimeMillis()));
|
||||
|
||||
EntityBean entityBean = (EntityBean)customer;
|
||||
boolean[] dirtyProperties = entityBean._ebean_getIntercept().getDirtyProperties();
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
JsonFactory jsonFactory = new JsonFactory();
|
||||
JsonGenerator generator = jsonFactory.createGenerator(writer);
|
||||
|
||||
WriteJson writeJson = new WriteJson(server, generator, null, null, null, null);
|
||||
descriptor.jsonWriteDirty(writeJson, entityBean, dirtyProperties);
|
||||
|
||||
generator.flush();
|
||||
generator.close();
|
||||
|
||||
String jsonContent = writer.toString();
|
||||
assertTrue(jsonContent.contains("\"name\":"));
|
||||
assertTrue(jsonContent.contains("\"anniversary\":"));
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.avaje.ebeaninternal.server.text.json;
|
||||
|
||||
import com.avaje.ebean.config.JsonConfig;
|
||||
import com.avaje.ebean.text.PathProperties;
|
||||
import com.avaje.ebean.FetchPath;
|
||||
import com.fasterxml.jackson.core.JsonFactory;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import org.junit.Test;
|
||||
@@ -19,8 +20,8 @@ public class WriteJsonTest {
|
||||
JsonFactory jsonFactory = new JsonFactory();
|
||||
JsonGenerator generator = jsonFactory.createGenerator(new StringWriter());
|
||||
|
||||
PathProperties pathProperties = PathProperties.parse("id,status,name,customer(id,name,address(street,city)),orders(qty,product(sku,prodName))");
|
||||
WriteJson writeJson = new WriteJson(null, generator, pathProperties, null, null, JsonConfig.Include.ALL);
|
||||
FetchPath fetchPath = PathProperties.parse("id,status,name,customer(id,name,address(street,city)),orders(qty,product(sku,prodName))");
|
||||
WriteJson writeJson = new WriteJson(null, generator, fetchPath, null, null, JsonConfig.Include.ALL);
|
||||
|
||||
WriteJson.WriteBean rootLevel = writeJson.createWriteBean(null, null);
|
||||
assertTrue(rootLevel.currentIncludeProps.contains("id"));
|
||||
|
||||
@@ -18,9 +18,9 @@ public class TestEnumToBeanType {
|
||||
OrdinalEnum ordinalEnum = new ScalarTypeEnumStandard.OrdinalEnum(Order.Status.class);
|
||||
|
||||
EnumToDbValueMap<?> beanDbMap = EnumToDbValueMap.create(false);
|
||||
beanDbMap.add(Customer.Status.ACTIVE, "A");
|
||||
beanDbMap.add(Customer.Status.NEW, "N");
|
||||
beanDbMap.add(Customer.Status.INACTIVE, "I");
|
||||
beanDbMap.add(Customer.Status.ACTIVE, "A", Customer.Status.ACTIVE.name());
|
||||
beanDbMap.add(Customer.Status.NEW, "N", Customer.Status.NEW.name());
|
||||
beanDbMap.add(Customer.Status.INACTIVE, "I", Customer.Status.INACTIVE.name());
|
||||
|
||||
ScalarTypeEnumWithMapping withMapping = new ScalarTypeEnumWithMapping(beanDbMap, Customer.Status.class, 1);
|
||||
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package com.avaje.ebeanservice.docstore.api.support;
|
||||
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Query;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.server.core.PersistRequestBean;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import com.avaje.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||
import com.avaje.ebeanservice.docstore.api.DocStoreUpdateContext;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class DocStoreBeanBaseAdapterTest extends BaseTestCase {
|
||||
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void test_basic_construction() throws Exception {
|
||||
|
||||
SpiEbeanServer server = spiEbeanServer();
|
||||
BeanDescriptor<Order> orderDesc = server.getBeanDescriptor(Order.class);
|
||||
|
||||
DeployBeanDescriptor<Order> deployDesc = (DeployBeanDescriptor<Order>)mock(DeployBeanDescriptor.class);
|
||||
|
||||
TDAdapter<Order> adapter = new TDAdapter<Order>(orderDesc, deployDesc);
|
||||
|
||||
assertThat(adapter.getIndexName()).isEqualTo("order");
|
||||
assertThat(adapter.getIndexType()).isEqualTo("order");
|
||||
assertThat(adapter.getQueueId()).isEqualTo("order");
|
||||
}
|
||||
|
||||
static class TDAdapter<T> extends DocStoreBeanBaseAdapter<T> {
|
||||
|
||||
TDAdapter(BeanDescriptor<T> desc, DeployBeanDescriptor<T> deploy) {
|
||||
super(desc, deploy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyPath(Query<T> query) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(Object idValue, DocStoreUpdateContext txn) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void index(Object idValue, Object entityBean, DocStoreUpdateContext txn) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext txn) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext txn) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEmbedded(Object idValue, String embeddedProperty, String embeddedRawContent, DocStoreUpdateContext txn) throws IOException {
|
||||
}
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.avaje.ebeanservice.docstore.api.support;
|
||||
|
||||
import com.avaje.ebean.DocStoreQueueEntry;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.plugin.BeanDocType;
|
||||
import com.avaje.ebean.plugin.BeanType;
|
||||
import com.avaje.ebeanservice.docstore.api.DocStoreUpdates;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import org.assertj.core.api.StrictAssertions;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class DocStoreDeleteEventTest {
|
||||
|
||||
static EbeanServer server = Ebean.getDefaultServer();
|
||||
|
||||
<T> BeanType<T> beanType(Class<T> cls) {
|
||||
return server.getPluginApi().getBeanType(cls);
|
||||
}
|
||||
|
||||
BeanType<Order> orderType() {
|
||||
return beanType(Order.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void docStoreUpdate() throws Exception {
|
||||
|
||||
BeanType<Order> mock = (BeanType<Order>) Mockito.mock(BeanType.class);
|
||||
BeanDocType<Order> mockDocType = (BeanDocType<Order>)Mockito.mock(BeanDocType.class);
|
||||
when(mock.docStore()).thenReturn(mockDocType);
|
||||
|
||||
DocStoreDeleteEvent event = new DocStoreDeleteEvent(mock, 42);
|
||||
event.docStoreUpdate(null);
|
||||
|
||||
verify(mock, times(1)).docStore();
|
||||
verify(mockDocType, times(1)).deleteById(42, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addToQueue() throws Exception {
|
||||
|
||||
DocStoreDeleteEvent event = new DocStoreDeleteEvent(orderType(), 42);
|
||||
|
||||
DocStoreUpdates updates = new DocStoreUpdates();
|
||||
event.addToQueue(updates);
|
||||
|
||||
List<DocStoreQueueEntry> queueEntries = updates.getQueueEntries();
|
||||
assertThat(queueEntries).hasSize(1);
|
||||
|
||||
DocStoreQueueEntry entry = queueEntries.get(0);
|
||||
StrictAssertions.assertThat(entry.getBeanId()).isEqualTo(42);
|
||||
StrictAssertions.assertThat(entry.getQueueId()).isEqualTo("order");
|
||||
StrictAssertions.assertThat(entry.getPath()).isNull();
|
||||
assertThat(entry.getType()).isEqualTo(DocStoreQueueEntry.Action.DELETE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.avaje.ebeanservice.docstore.api.support;
|
||||
|
||||
import com.avaje.ebean.DocStoreQueueEntry;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.ebean.plugin.BeanDocType;
|
||||
import com.avaje.ebean.plugin.BeanType;
|
||||
import com.avaje.ebeanservice.docstore.api.DocStoreUpdates;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class DocStoreIndexEventTest {
|
||||
|
||||
static EbeanServer server = Ebean.getDefaultServer();
|
||||
|
||||
<T> BeanType<T> beanType(Class<T> cls) {
|
||||
return server.getPluginApi().getBeanType(cls);
|
||||
}
|
||||
|
||||
BeanType<Order> orderType() {
|
||||
return beanType(Order.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void docStoreUpdate() throws Exception {
|
||||
|
||||
BeanType<Order> mock = (BeanType<Order>)Mockito.mock(BeanType.class);
|
||||
BeanDocType<Order> mockDocType = (BeanDocType<Order>)Mockito.mock(BeanDocType.class);
|
||||
when(mock.docStore()).thenReturn(mockDocType);
|
||||
|
||||
Order bean = new Order();
|
||||
DocStoreIndexEvent<Order> event = new DocStoreIndexEvent<Order>(mock, 42, bean);
|
||||
|
||||
event.docStoreUpdate(null);
|
||||
|
||||
verify(mock, times(1)).docStore();
|
||||
verify(mockDocType, times(1)).index(42, bean, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addToQueue() throws Exception {
|
||||
|
||||
Order bean = new Order();
|
||||
|
||||
DocStoreIndexEvent<Order> event = new DocStoreIndexEvent<Order>(orderType(), 42, bean);
|
||||
|
||||
DocStoreUpdates updates = new DocStoreUpdates();
|
||||
event.addToQueue(updates);
|
||||
|
||||
List<DocStoreQueueEntry> queueEntries = updates.getQueueEntries();
|
||||
assertThat(queueEntries).hasSize(1);
|
||||
|
||||
DocStoreQueueEntry entry = queueEntries.get(0);
|
||||
assertThat(entry.getBeanId()).isEqualTo(42);
|
||||
assertThat(entry.getQueueId()).isEqualTo("order");
|
||||
assertThat(entry.getPath()).isNull();
|
||||
assertThat(entry.getType()).isEqualTo(DocStoreQueueEntry.Action.INDEX);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package com.avaje.tests.batchload;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebean.bean.EntityBeanIntercept;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -35,6 +37,15 @@ public class TestLoadOnDirty extends BaseTestCase {
|
||||
Assert.assertTrue(beanState.getChangedProps().contains("name"));
|
||||
Assert.assertEquals(1, beanState.getChangedProps().size());
|
||||
|
||||
EntityBeanIntercept ebi = ((EntityBean) customer)._ebean_getIntercept();
|
||||
boolean[] dirtyProperties = ebi.getDirtyProperties();
|
||||
for (int i = 0; i < dirtyProperties.length; i++) {
|
||||
if (dirtyProperties[i]) {
|
||||
String dirtyPropertyName = ebi.getProperty(i);
|
||||
Assert.assertEquals("name", dirtyPropertyName);
|
||||
}
|
||||
}
|
||||
|
||||
customer.setStatus(Customer.Status.INACTIVE);
|
||||
|
||||
Assert.assertTrue(beanState.isDirty());
|
||||
|
||||
@@ -12,8 +12,11 @@ import javax.persistence.Version;
|
||||
import com.avaje.ebean.annotation.CacheStrategy;
|
||||
import com.avaje.ebean.annotation.ChangeLog;
|
||||
import com.avaje.ebean.annotation.CreatedTimestamp;
|
||||
import com.avaje.ebean.annotation.DocStoreEmbedded;
|
||||
import com.avaje.ebean.annotation.DocStore;
|
||||
import com.avaje.ebean.annotation.Index;
|
||||
|
||||
@DocStore
|
||||
@Index(columnNames = {"last_name","first_name"})
|
||||
@ChangeLog
|
||||
@Entity
|
||||
@@ -32,6 +35,7 @@ public class Contact {
|
||||
String mobile;
|
||||
String email;
|
||||
|
||||
@DocStoreEmbedded(doc="id,name")
|
||||
@ManyToOne(optional=false)
|
||||
Customer customer;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.avaje.ebean.annotation.CacheStrategy;
|
||||
import com.avaje.ebean.annotation.CacheTuning;
|
||||
import com.avaje.ebean.annotation.ChangeLog;
|
||||
import com.avaje.ebean.annotation.ChangeLogInsertMode;
|
||||
import com.avaje.ebean.annotation.DocStore;
|
||||
import com.avaje.ebean.annotation.ReadAudit;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
@@ -14,6 +15,7 @@ import javax.validation.constraints.Size;
|
||||
/**
|
||||
* Country entity bean.
|
||||
*/
|
||||
@DocStore
|
||||
@ReadAudit
|
||||
@ChangeLog(inserts = ChangeLogInsertMode.INCLUDE)
|
||||
@CacheStrategy(readOnly = true, warmingQuery = "order by name")
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.avaje.ebean.annotation.ChangeLog;
|
||||
import com.avaje.ebean.annotation.ChangeLogInsertMode;
|
||||
import com.avaje.ebean.annotation.DbComment;
|
||||
import com.avaje.ebean.annotation.DbEnumValue;
|
||||
import com.avaje.ebean.annotation.DocStoreEmbedded;
|
||||
import com.avaje.ebean.annotation.DocStore;
|
||||
import com.avaje.ebean.annotation.JsonIgnore;
|
||||
import com.avaje.ebean.annotation.Where;
|
||||
import com.avaje.tests.model.basic.finder.CustomerFinder;
|
||||
@@ -24,6 +26,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
/**
|
||||
* Customer entity bean.
|
||||
*/
|
||||
@DocStore
|
||||
@ChangeLog(inserts = ChangeLogInsertMode.EXCLUDE, updatesThatInclude = {"name","status"})
|
||||
@Entity
|
||||
@Table(name = "o_customer")
|
||||
@@ -77,9 +80,11 @@ public class Customer extends BasicDomain {
|
||||
@NotNull(groups = { ValidationGroupSomething.class })
|
||||
Date anniversary;
|
||||
|
||||
@DocStoreEmbedded(doc="*,country(*)")
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
Address billingAddress;
|
||||
|
||||
@DocStoreEmbedded(doc="*,country(*)")
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
Address shippingAddress;
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.avaje.tests.model.basic;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.avaje.ebean.annotation.ChangeLog;
|
||||
import com.avaje.ebean.annotation.DocStore;
|
||||
import com.avaje.ebean.annotation.DocStoreEmbedded;
|
||||
import com.avaje.ebean.annotation.Formula;
|
||||
import com.avaje.ebean.annotation.WhenCreated;
|
||||
import com.avaje.ebean.annotation.Where;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
@@ -20,16 +21,16 @@ import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
import javax.persistence.Version;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.avaje.ebean.annotation.ChangeLog;
|
||||
import com.avaje.ebean.annotation.Formula;
|
||||
import com.avaje.ebean.annotation.WhenCreated;
|
||||
import com.avaje.ebean.annotation.Where;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Order entity bean.
|
||||
*/
|
||||
@DocStore
|
||||
@ChangeLog
|
||||
@Entity
|
||||
@Table(name = "o_order")
|
||||
@@ -37,7 +38,6 @@ public class Order implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@XmlType(name = "status")
|
||||
public enum Status {
|
||||
NEW,
|
||||
APPROVED,
|
||||
@@ -86,9 +86,9 @@ public class Order implements Serializable {
|
||||
@NotNull
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "kcustomer_id")
|
||||
@DocStoreEmbedded(doc = "id,name")
|
||||
Customer customer;
|
||||
|
||||
//@Basic(fetch=FetchType.LAZY)
|
||||
@Column(name = "name", table = "o_customer")
|
||||
String customerName;
|
||||
|
||||
@@ -101,6 +101,7 @@ public class Order implements Serializable {
|
||||
@Where(clause = "${ta}.id > 0")
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order")
|
||||
@OrderBy("id asc, orderQty asc, cretime desc")
|
||||
@DocStoreEmbedded
|
||||
List<OrderDetail> details;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order")
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.avaje.tests.model.basic;
|
||||
|
||||
import com.avaje.ebean.annotation.DocStoreEmbedded;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@@ -31,6 +33,7 @@ public class OrderDetail implements Serializable {
|
||||
Double unitPrice;
|
||||
|
||||
@ManyToOne
|
||||
@DocStoreEmbedded(doc = "id,name,sku")
|
||||
Product product;
|
||||
|
||||
Timestamp cretime;
|
||||
|
||||
@@ -11,99 +11,101 @@ import javax.validation.constraints.Size;
|
||||
|
||||
import com.avaje.ebean.annotation.CacheStrategy;
|
||||
import com.avaje.ebean.annotation.CreatedTimestamp;
|
||||
import com.avaje.ebean.annotation.DocStore;
|
||||
|
||||
/**
|
||||
* Product entity bean.
|
||||
*/
|
||||
@CacheStrategy(warmingQuery="order by name")
|
||||
@DocStore
|
||||
@CacheStrategy(warmingQuery = "order by name")
|
||||
@Entity
|
||||
@Table(name="o_product")
|
||||
@Table(name = "o_product")
|
||||
public class Product implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@Size(max=20)
|
||||
String sku;
|
||||
@Size(max = 20)
|
||||
String sku;
|
||||
|
||||
String name;
|
||||
String name;
|
||||
|
||||
@CreatedTimestamp
|
||||
Timestamp cretime;
|
||||
@CreatedTimestamp
|
||||
Timestamp cretime;
|
||||
|
||||
@Version
|
||||
Timestamp updtime;
|
||||
@Version
|
||||
Timestamp updtime;
|
||||
|
||||
/**
|
||||
* Return id.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
* Return id.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id.
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
/**
|
||||
* Set id.
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return sku.
|
||||
*/
|
||||
public String getSku() {
|
||||
return sku;
|
||||
}
|
||||
/**
|
||||
* Return sku.
|
||||
*/
|
||||
public String getSku() {
|
||||
return sku;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sku.
|
||||
*/
|
||||
public void setSku(String sku) {
|
||||
this.sku = sku;
|
||||
}
|
||||
/**
|
||||
* Set sku.
|
||||
*/
|
||||
public void setSku(String sku) {
|
||||
this.sku = sku;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* Return name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
/**
|
||||
* Set name.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cretime.
|
||||
*/
|
||||
public Timestamp getCretime() {
|
||||
return cretime;
|
||||
}
|
||||
/**
|
||||
* Return cretime.
|
||||
*/
|
||||
public Timestamp getCretime() {
|
||||
return cretime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cretime.
|
||||
*/
|
||||
public void setCretime(Timestamp cretime) {
|
||||
this.cretime = cretime;
|
||||
}
|
||||
/**
|
||||
* Set cretime.
|
||||
*/
|
||||
public void setCretime(Timestamp cretime) {
|
||||
this.cretime = cretime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return updtime.
|
||||
*/
|
||||
public Timestamp getUpdtime() {
|
||||
return updtime;
|
||||
}
|
||||
/**
|
||||
* Return updtime.
|
||||
*/
|
||||
public Timestamp getUpdtime() {
|
||||
return updtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set updtime.
|
||||
*/
|
||||
public void setUpdtime(Timestamp updtime) {
|
||||
this.updtime = updtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set updtime.
|
||||
*/
|
||||
public void setUpdtime(Timestamp updtime) {
|
||||
this.updtime = updtime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class TestOrderByWithMany extends BaseTestCase {
|
||||
|
||||
String lazyLoadSql = loggedSql.get(1);
|
||||
// contains the foreign key back to the parent bean (t0.order_id)
|
||||
Assert.assertTrue(lazyLoadSql.contains("select t0.order_id c0, t0.id"));
|
||||
Assert.assertTrue(lazyLoadSql, lazyLoadSql.contains("select t0.order_id c0, t0.id"));
|
||||
Assert.assertTrue(lazyLoadSql.contains("order by t0.order_id, t0.id, t0.order_qty, t0.cretime desc"));
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class TestManyLazyLoadingQuery extends BaseTestCase {
|
||||
|
||||
query0.setLazyLoadForParents(beanProperty);
|
||||
|
||||
beanProperty.addWhereParentIdIn(query0, parentIds);
|
||||
beanProperty.addWhereParentIdIn(query0, parentIds, false);
|
||||
|
||||
query0.findList();
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TestJsonBeanDescriptorParse extends BaseTestCase {
|
||||
StringReader reader = new StringReader("{\"id\":123,\"name\":\"Hello rob\"}");
|
||||
JsonParser parser = server.json().createParser(reader);
|
||||
|
||||
ReadJson readJson = new ReadJson(parser, null, null);
|
||||
ReadJson readJson = new ReadJson(descriptor, parser, null, null);
|
||||
|
||||
Customer customer = descriptor.jsonRead(readJson, null);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.junit.Test;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -100,9 +101,9 @@ public class TestUpdateAllLoadedProperties extends BaseTestCase {
|
||||
|
||||
List<String> loggedSql = LoggedSqlCollector.stop();
|
||||
|
||||
assertEquals(2, loggedSql.size());
|
||||
assertTrue(loggedSql.get(0), loggedSql.get(0).contains("update e_basicver set name=?, other=?, last_update=? where id=?; --bind("));
|
||||
assertTrue(loggedSql.get(1), loggedSql.get(1).contains("update e_basicver set name=?, other=?, last_update=? where id=?; --bind("));
|
||||
assertThat(loggedSql).hasSize(2);
|
||||
assertThat(loggedSql.get(0)).contains("update e_basicver set name=?, other=?, last_update=? where id=?; --bind(");
|
||||
assertThat(loggedSql.get(1)).contains("update e_basicver set name=?, other=?, last_update=? where id=?; --bind(");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user