mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#919 - io.ebean package initial
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package org.tests.unitinternal;
|
||||
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.EbeanServerFactory;
|
||||
import io.ebean.config.ServerConfig;
|
||||
import org.tests.model.basic.TOne;
|
||||
import org.avaje.agentloader.AgentLoader;
|
||||
import org.avaje.datasource.DataSourceConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class HelloMain {
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(HelloMain.class);
|
||||
|
||||
static {
|
||||
logger.debug("... preStart");
|
||||
if (!AgentLoader.loadAgentFromClasspath("avaje-ebeanorm-agent", "debug=1;packages=com.avaje.tests.**")) {
|
||||
logger.info("avaje-ebeanorm-agent not found in classpath - not dynamically loaded");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// ### Configuration Objects ###
|
||||
ServerConfig serverConfig = new ServerConfig();
|
||||
DataSourceConfig dataSourceConfig = new DataSourceConfig();
|
||||
|
||||
// ### Configuration Settings ###
|
||||
// -> data source
|
||||
dataSourceConfig.setDriver("org.h2.Driver");
|
||||
dataSourceConfig.setUsername("howtouser");
|
||||
dataSourceConfig.setPassword("");
|
||||
dataSourceConfig.setUrl("jdbc:h2:~/db/howto1");
|
||||
|
||||
// -> server
|
||||
serverConfig.setName("default");
|
||||
serverConfig.setDataSourceConfig(dataSourceConfig);
|
||||
|
||||
// auto create db if it does not exist
|
||||
if (!(new File("db/howto1.data.db")).exists()) {
|
||||
serverConfig.setDdlGenerate(true);
|
||||
serverConfig.setDdlRun(true);
|
||||
serverConfig.addClass(TOne.class);
|
||||
}
|
||||
|
||||
EbeanServer eServer = EbeanServerFactory.createWithContextClassLoader(serverConfig, HelloMain.class.getClassLoader());
|
||||
|
||||
long id = 1;
|
||||
TOne data = eServer.find(TOne.class, id);
|
||||
if (data == null) {
|
||||
TOne tone = new TOne();
|
||||
tone.setName("banan");
|
||||
eServer.save(tone);// new TOne()id, "Hello World!"));
|
||||
} else {
|
||||
System.out.println(String.format("############\n%s############", data.getName()));
|
||||
}
|
||||
|
||||
EbeanServerFactory.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.tests.unitinternal;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class TestBasics {
|
||||
|
||||
|
||||
private String parentPath(String path) {
|
||||
|
||||
int pos = path.lastIndexOf('.');
|
||||
if (pos == -1) {
|
||||
return null;
|
||||
} else {
|
||||
return path.substring(0, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParentPath() {
|
||||
|
||||
Assert.assertTrue((parentPath("banana") == null));
|
||||
Assert.assertTrue((parentPath("banana.apple").equals("banana")));
|
||||
Assert.assertTrue((parentPath("banana.apple.o").equals("banana.apple")));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.tests.unitinternal;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.Order;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestEqualsOnEnhanced extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
Customer c = new Customer();
|
||||
if (c instanceof EntityBean) {
|
||||
Order o = new Order();
|
||||
if (o instanceof EntityBean) {
|
||||
|
||||
c.setId(1);
|
||||
|
||||
o.setId(1);
|
||||
|
||||
Assert.assertFalse(c.equals(o));
|
||||
Assert.assertFalse(c.equals(null));
|
||||
Assert.assertTrue(c.equals(c));
|
||||
|
||||
Customer c2 = new Customer();
|
||||
c2.setId(1);
|
||||
Assert.assertTrue(c.equals(c2));
|
||||
|
||||
Customer c3 = new Customer();
|
||||
// c2.setId(1);
|
||||
Assert.assertFalse(c.equals(c3));
|
||||
|
||||
Customer c4 = new Customer();
|
||||
c4.setId(2);
|
||||
Assert.assertFalse(c.equals(c4));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.tests.unitinternal;
|
||||
|
||||
import io.ebeaninternal.server.type.ScalarTypeLocale;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class TestLocaleParse {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
// Examples: "en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr__MAC"
|
||||
|
||||
Locale l = parse("en");
|
||||
Assert.assertEquals("en", l.getLanguage());
|
||||
|
||||
l = parse("de_DE");
|
||||
Assert.assertEquals("de", l.getLanguage());
|
||||
Assert.assertEquals("DE", l.getCountry());
|
||||
|
||||
l = parse("en_US_WIN");
|
||||
Assert.assertEquals("en", l.getLanguage());
|
||||
Assert.assertEquals("US", l.getCountry());
|
||||
Assert.assertEquals("WIN", l.getVariant());
|
||||
|
||||
l = parse("_GB");
|
||||
Assert.assertEquals("", l.getLanguage());
|
||||
Assert.assertEquals("GB", l.getCountry());
|
||||
Assert.assertEquals("", l.getVariant());
|
||||
|
||||
l = parse("fr__MAC");
|
||||
Assert.assertEquals("fr", l.getLanguage());
|
||||
Assert.assertEquals("", l.getCountry());
|
||||
Assert.assertEquals("MAC", l.getVariant());
|
||||
|
||||
l = parse("de__POSIX");
|
||||
Assert.assertEquals("de", l.getLanguage());
|
||||
Assert.assertEquals("", l.getCountry());
|
||||
Assert.assertEquals("POSIX", l.getVariant());
|
||||
}
|
||||
|
||||
private Locale parse(String value) {
|
||||
|
||||
ScalarTypeLocale st = new ScalarTypeLocale();
|
||||
return (Locale) st.parse(value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.tests.unitinternal;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class TestNamingConvention extends TestCase {
|
||||
|
||||
/**
|
||||
* Test dummy method to allow rest to be commented out.
|
||||
*/
|
||||
public void testDummy() {
|
||||
|
||||
}
|
||||
|
||||
// Comment out for now so the entities do not get registered
|
||||
// Run this manually as needed.
|
||||
|
||||
// @Entity
|
||||
// @Table(name = "table1", schema = "annotationschema")
|
||||
// public class FooBar1 {
|
||||
// }
|
||||
//
|
||||
// @Entity
|
||||
// @Table(name = "table2")
|
||||
// public class FooBar2 {
|
||||
// }
|
||||
//
|
||||
// @Entity
|
||||
// public class FooBar3 {
|
||||
// }
|
||||
//
|
||||
// public AbstractNamingConvention namingConvention;
|
||||
//
|
||||
// public void setUp() {
|
||||
// namingConvention = new UnderscoreNamingConvention();
|
||||
// namingConvention.setDatabasePlatform(new DatabasePlatform());
|
||||
// namingConvention.setSchema("conventionschema");
|
||||
// }
|
||||
//
|
||||
// public void test_table_name_and_schema_name_from_annotation() {
|
||||
// Assert.assertNotNull(FooBar1.class.getAnnotation(Table.class));
|
||||
// Assert.assertEquals("annotationschema.table1", namingConvention.getTableName(FooBar1.class).getQualifiedName());
|
||||
// }
|
||||
//
|
||||
// public void test_table_name_from_annotation_and_schema_name_by_convention() {
|
||||
// Assert.assertNotNull(FooBar2.class.getAnnotation(Table.class));
|
||||
// Assert.assertEquals("conventionschema.table2", namingConvention.getTableName(FooBar2.class).getQualifiedName());
|
||||
// }
|
||||
//
|
||||
// public void test_table_name_and_schema_name_by_convention() {
|
||||
// Assert.assertNull(FooBar3.class.getAnnotation(Table.class));
|
||||
// Assert.assertEquals("conventionschema.foo_bar3", namingConvention.getTableName(FooBar3.class)
|
||||
// .getQualifiedName());
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.tests.unitinternal;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.bean.BeanCollection;
|
||||
import org.tests.model.basic.ENullCollection;
|
||||
import org.tests.model.basic.ENullCollectionDetail;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TestNullCollectionSet extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
ENullCollection c = new ENullCollection();
|
||||
|
||||
Ebean.save(c);
|
||||
|
||||
ENullCollection c2 = Ebean.find(ENullCollection.class, c.getId());
|
||||
|
||||
Assert.assertNotNull(c2);
|
||||
|
||||
List<ENullCollectionDetail> details = c2.getDetails();
|
||||
Assert.assertNotNull(details);
|
||||
|
||||
Assert.assertTrue("Is BeanCollection", details instanceof BeanCollection<?>);
|
||||
|
||||
BeanCollection<?> bc = (BeanCollection<?>) details;
|
||||
Assert.assertTrue(!bc.isPopulated());
|
||||
Assert.assertNotNull(bc.getOwnerBean());
|
||||
Assert.assertNotNull(bc.getPropertyName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package org.tests.unitinternal;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.OrderBy;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test the OrderBy object and especially its parsing.
|
||||
*/
|
||||
public class TestOrderByParse extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void testParsingOne() {
|
||||
|
||||
OrderBy<Object> o1 = new OrderBy<>("id");
|
||||
assertTrue(o1.getProperties().size() == 1);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.toStringFormat().equals("id"));
|
||||
|
||||
o1 = new OrderBy<>("id asc");
|
||||
assertTrue(o1.getProperties().size() == 1);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.toStringFormat().equals("id"));
|
||||
|
||||
o1 = new OrderBy<>("id desc");
|
||||
assertTrue(o1.getProperties().size() == 1);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(!o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.toStringFormat().equals("id desc"));
|
||||
|
||||
o1 = new OrderBy<>(" id asc ");
|
||||
assertTrue(o1.getProperties().size() == 1);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.toStringFormat().equals("id"));
|
||||
|
||||
assertTrue(o1.containsProperty("id"));
|
||||
assertFalse(o1.containsProperty("junk"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseNullsHigh() {
|
||||
|
||||
OrderBy<Object> o1 = new OrderBy<>("id desc nulls high");
|
||||
assertTrue(o1.getProperties().size() == 1);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(!o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.toStringFormat().equals("id desc nulls high"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void add_parse() {
|
||||
|
||||
OrderBy<Object> o1 = new OrderBy<>();
|
||||
o1.add("id desc nulls high");
|
||||
assertTrue(o1.getProperties().size() == 1);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(!o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.toStringFormat().equals("id desc nulls high"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseNullsHigh_with_second() {
|
||||
|
||||
OrderBy<Object> o1 = new OrderBy<>("id desc nulls high, name");
|
||||
assertTrue(o1.getProperties().size() == 2);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(!o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.toStringFormat().equals("id desc nulls high, name"));
|
||||
assertTrue(o1.getProperties().get(1).getProperty().equals("name"));
|
||||
assertTrue(o1.getProperties().get(1).isAscending());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsingTwo() {
|
||||
|
||||
OrderBy<?> o1 = new OrderBy<>("id,name");
|
||||
assertTrue(o1.getProperties().size() == 2);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.getProperties().get(1).getProperty().equals("name"));
|
||||
assertTrue(o1.getProperties().get(1).isAscending());
|
||||
assertEquals("id, name", o1.toStringFormat());
|
||||
|
||||
o1 = new OrderBy<>(" id , name ");
|
||||
assertTrue(o1.getProperties().size() == 2);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.getProperties().get(1).getProperty().equals("name"));
|
||||
assertTrue(o1.getProperties().get(1).isAscending());
|
||||
assertEquals("id, name", o1.toStringFormat());
|
||||
|
||||
o1 = new OrderBy<>(" id desc , name desc ");
|
||||
assertTrue(o1.getProperties().size() == 2);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(!o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.getProperties().get(1).getProperty().equals("name"));
|
||||
assertTrue(!o1.getProperties().get(1).isAscending());
|
||||
assertEquals("id desc, name desc", o1.toStringFormat());
|
||||
|
||||
o1 = new OrderBy<>(" id ascending, name asc");
|
||||
assertTrue(o1.getProperties().size() == 2);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.getProperties().get(1).getProperty().equals("name"));
|
||||
assertTrue(o1.getProperties().get(1).isAscending());
|
||||
assertEquals("id, name", o1.toStringFormat());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddMethods() {
|
||||
|
||||
OrderBy<?> o1 = new OrderBy<>();
|
||||
o1.asc("id");
|
||||
o1.asc("name");
|
||||
assertTrue(o1.getProperties().size() == 2);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.getProperties().get(1).getProperty().equals("name"));
|
||||
assertTrue(o1.getProperties().get(1).isAscending());
|
||||
assertEquals("id, name", o1.toStringFormat());
|
||||
|
||||
o1 = new OrderBy<>();
|
||||
o1.desc("id");
|
||||
o1.desc("name");
|
||||
assertTrue(o1.getProperties().size() == 2);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(!o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.getProperties().get(1).getProperty().equals("name"));
|
||||
assertTrue(!o1.getProperties().get(1).isAscending());
|
||||
assertEquals("id desc, name desc", o1.toStringFormat());
|
||||
|
||||
o1.reverse();
|
||||
assertTrue(o1.getProperties().size() == 2);
|
||||
assertTrue(o1.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(o1.getProperties().get(0).isAscending());
|
||||
assertTrue(o1.getProperties().get(1).getProperty().equals("name"));
|
||||
assertTrue(o1.getProperties().get(1).isAscending());
|
||||
assertEquals("id, name", o1.toStringFormat());
|
||||
|
||||
OrderBy<?> copy = o1.copy();
|
||||
assertTrue(copy != o1);
|
||||
assertTrue(copy.getProperties().size() == 2);
|
||||
assertTrue(copy.getProperties().get(0).getProperty().equals("id"));
|
||||
assertTrue(copy.getProperties().get(0).isAscending());
|
||||
assertTrue(copy.getProperties().get(1).getProperty().equals("name"));
|
||||
assertTrue(copy.getProperties().get(1).isAscending());
|
||||
assertEquals("id, name", copy.toStringFormat());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.tests.unitinternal;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.bean.CallStack;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestOriginIntEncoding extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
Assert.assertEquals("A", CallStack.enc(0));
|
||||
Assert.assertEquals("B", CallStack.enc(1));
|
||||
Assert.assertEquals("Z", CallStack.enc(25));
|
||||
Assert.assertEquals("a", CallStack.enc(26));
|
||||
Assert.assertEquals("z", CallStack.enc(51));
|
||||
Assert.assertEquals("0", CallStack.enc(52));
|
||||
Assert.assertEquals("9", CallStack.enc(61));
|
||||
Assert.assertEquals("-", CallStack.enc(62));
|
||||
Assert.assertEquals("_", CallStack.enc(63));
|
||||
Assert.assertEquals("BA", CallStack.enc(64));
|
||||
Assert.assertEquals("Bk", CallStack.enc(100));
|
||||
Assert.assertEquals("B9", CallStack.enc(125));
|
||||
Assert.assertEquals("B-", CallStack.enc(126));
|
||||
Assert.assertEquals("B_", CallStack.enc(127));
|
||||
Assert.assertEquals("CA", CallStack.enc(128));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.tests.unitinternal;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.config.EncryptKey;
|
||||
import io.ebeaninternal.server.type.SimpleAesEncryptor;
|
||||
import org.tests.basic.encrypt.BasicEncryptKey;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class TestSimpleEncryptor extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
SimpleAesEncryptor e = new SimpleAesEncryptor();
|
||||
|
||||
EncryptKey key = new BasicEncryptKey("hello");
|
||||
|
||||
byte[] data = "test123".getBytes();
|
||||
|
||||
byte[] ecData = e.encrypt(data, key);
|
||||
|
||||
byte[] deData = e.decrypt(ecData, key);
|
||||
|
||||
Timestamp t = new Timestamp(System.currentTimeMillis());
|
||||
byte[] ecTimestamp = e.encryptString(t.toString(), key);
|
||||
|
||||
String tsFormat = e.decryptString(ecTimestamp, key);
|
||||
Timestamp t1 = Timestamp.valueOf(tsFormat);
|
||||
Assert.assertEquals(t, t1);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.tests.unitinternal;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Transaction;
|
||||
import org.tests.model.basic.EBasicVer;
|
||||
import org.tests.model.basic.xtra.DummyDao;
|
||||
import org.tests.model.basic.xtra.OptimisticLockExceptionThrowingDao;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.OptimisticLockException;
|
||||
|
||||
public class TestTxTypeOnTransactional extends BaseTestCase {
|
||||
|
||||
Logger logger = LoggerFactory.getLogger(TestTxTypeOnTransactional.class);
|
||||
|
||||
@Test
|
||||
public void testBatchOptionsAreSet() {
|
||||
|
||||
logger.info("-- test pre doOuterWithBatchOptionsSet");
|
||||
DummyDao dao = new DummyDao();
|
||||
dao.doOuterWithBatchOptionsSet();
|
||||
logger.info("-- test post doOuterWithBatchOptionsSet");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
logger.info("-- test pre dao.doSomething");
|
||||
DummyDao dao = new DummyDao();
|
||||
dao.doSomething();
|
||||
logger.info("-- test post dao.doSomething");
|
||||
}
|
||||
|
||||
public void testOptimisticException() {
|
||||
|
||||
logger.info("-- testOptimisticException");
|
||||
EBasicVer v = new EBasicVer("occ");
|
||||
v.setDescription("blah");
|
||||
Ebean.save(v);
|
||||
|
||||
logger.info("-- OptimisticLockExceptionThrowingDao");
|
||||
OptimisticLockExceptionThrowingDao dao = new OptimisticLockExceptionThrowingDao();
|
||||
try {
|
||||
dao.doSomething(v);
|
||||
// never get here
|
||||
Assert.assertTrue(false);
|
||||
} catch (OptimisticLockException e) {
|
||||
Transaction inMethodTransaction = dao.getInMethodTransaction();
|
||||
boolean active = inMethodTransaction.isActive();
|
||||
Assert.assertFalse(active);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.tests.unitinternal;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.bean.BeanCollection;
|
||||
import org.tests.model.basic.EVanillaCollection;
|
||||
import org.tests.model.basic.EVanillaCollectionDetail;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TestVanillaCollectionSet extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
EVanillaCollection c = new EVanillaCollection();
|
||||
|
||||
Ebean.save(c);
|
||||
|
||||
EVanillaCollection c2 = Ebean.find(EVanillaCollection.class, c.getId());
|
||||
|
||||
Assert.assertNotNull(c2);
|
||||
|
||||
List<EVanillaCollectionDetail> details = c2.getDetails();
|
||||
Assert.assertNotNull(details);
|
||||
|
||||
Assert.assertTrue("Is BeanCollection", details instanceof BeanCollection<?>);
|
||||
|
||||
BeanCollection<?> bc = (BeanCollection<?>) details;
|
||||
Assert.assertTrue(!bc.isPopulated());
|
||||
Assert.assertNotNull(bc.getOwnerBean());
|
||||
Assert.assertNotNull(bc.getPropertyName());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user