mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
Refactor move tests from ebean-core to ebean-test
This commit is contained in:
1 parent
0b00a14fd3
commit
eab56d323b
1650 files changed
+185
-147
No files matched your search
@@ -0,0 +1,66 @@
|
||||
package org.tests.ddd.iud;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TestDExhEntityEl {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
// GlobalProperties.put("classes", DExhEntity.class.toString());
|
||||
|
||||
// Currency NZD = Currency.getInstance("NZD");
|
||||
//
|
||||
// CMoney cm = new CMoney(new Money("12"), NZD);
|
||||
//
|
||||
// Rate rate = new Rate(0.1);
|
||||
// ExhangeCMoneyRate exh = new ExhangeCMoneyRate(rate, cm);
|
||||
//
|
||||
// DExhEntity p = new DExhEntity();
|
||||
// p.setExhange(exh);
|
||||
//
|
||||
// SpiEbeanServer server = (SpiEbeanServer)DB.getDefault();
|
||||
//
|
||||
// BeanDescriptor<DExhEntity> descriptor = server.getBeanDescriptor(DExhEntity.class);
|
||||
//
|
||||
// ElPropertyValue elExh = descriptor.getElGetValue("exhange");
|
||||
// ElPropertyValue elExhRate = descriptor.getElGetValue("exhange.rate");
|
||||
// ElPropertyValue elExhCMoney = descriptor.getElGetValue("exhange.cmoney");
|
||||
// ElPropertyValue elExhCMoneyCur = descriptor.getElGetValue("exhange.cmoney.currency");
|
||||
// ElPropertyValue elExhCMoneyAmt = descriptor.getElGetValue("exhange.cmoney.amount");
|
||||
//
|
||||
// EntityBean entityBean = (EntityBean)p;
|
||||
// Object e = elExh.elGetValue(entityBean);
|
||||
// Object er = elExhRate.elGetValue(entityBean);
|
||||
// Object ecm = elExhCMoney.elGetValue(entityBean);
|
||||
// Object ecmCurr = elExhCMoneyCur.elGetValue(entityBean);
|
||||
// Object ecmAmt = elExhCMoneyAmt.elGetValue(entityBean);
|
||||
//
|
||||
// Assert.assertNotNull(e);
|
||||
// Assert.assertNotNull(er);
|
||||
// Assert.assertNotNull(ecm);
|
||||
//
|
||||
// Assert.assertEquals(new Rate("0.1"), er);
|
||||
// Assert.assertEquals(NZD, ecmCurr);
|
||||
// Assert.assertEquals(new Money("12"), ecmAmt);
|
||||
//
|
||||
// p.setExhange(null);
|
||||
// Assert.assertNull(p.getExhange());
|
||||
//
|
||||
// // won't trigger CMoney build as not all properties
|
||||
// // have been set yet...
|
||||
// elExhCMoneyAmt.elSetValue(entityBean, new Money("13"), true, false);
|
||||
// Assert.assertNull(p.getExhange());
|
||||
//
|
||||
// elExhCMoneyCur.elSetValue(entityBean, NZD, true, false);
|
||||
// Assert.assertNull(p.getExhange());
|
||||
//
|
||||
// elExhRate.elSetValue(entityBean, new Rate(.2), true, false);
|
||||
//
|
||||
// // this time not null as all required properties for
|
||||
// // the compound object have been collected
|
||||
// Assert.assertNotNull(p.getExhange());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.tests.ddd.iud;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebean.plugin.BeanType;
|
||||
import io.ebean.plugin.ExpressionPath;
|
||||
import io.ebean.plugin.SpiServer;
|
||||
import io.ebean.text.json.JsonContext;
|
||||
import org.tests.model.ddd.DPerson;
|
||||
import org.tests.model.ivo.Money;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Currency;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestDPersonEl {
|
||||
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
|
||||
Currency NZD = Currency.getInstance("NZD");
|
||||
assertThat(NZD).isNotNull();
|
||||
|
||||
DPerson p = new DPerson();
|
||||
p.setFirstName("first");
|
||||
p.setLastName("last");
|
||||
p.setSalary(new Money("12200"));
|
||||
|
||||
DB.save(p);
|
||||
|
||||
SpiServer server = DB.getDefault().pluginApi();
|
||||
|
||||
BeanType<DPerson> descriptor = server.beanType(DPerson.class);
|
||||
|
||||
|
||||
JsonContext jsonContext = server.json();
|
||||
String json = jsonContext.toJson(p);
|
||||
|
||||
DPerson bean = jsonContext.toBean(DPerson.class, json);
|
||||
assertEquals("first", bean.getFirstName());
|
||||
assertEquals(new Money("12200"), bean.getSalary());
|
||||
|
||||
|
||||
EntityBean entityBean = (EntityBean) p;
|
||||
|
||||
ExpressionPath elSalary = descriptor.expressionPath("salary");
|
||||
|
||||
Object money = elSalary.pathGet(entityBean);
|
||||
|
||||
assertNotNull(money);
|
||||
assertEquals(new Money("12200"), money);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.tests.ddd.iud;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class TestDPersonIUD {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
// GlobalProperties.put("classes", DPerson.class.toString());
|
||||
|
||||
// Currency NZD = Currency.getInstance("NZD");
|
||||
//
|
||||
// DPerson p = new DPerson();
|
||||
// p.setFirstName("first");
|
||||
// p.setLastName("last");
|
||||
// p.setSalary(new Money("12200"));
|
||||
// p.setCmoney(new CMoney(new Money("12"), NZD));
|
||||
//
|
||||
// p.setInterval(new Interval(System.currentTimeMillis()-20000, System.currentTimeMillis()));
|
||||
//
|
||||
// DB.save(p);
|
||||
//
|
||||
// Oid<DPerson> id = p.getId();
|
||||
// Assert.assertNotNull(id);
|
||||
//
|
||||
// DPerson p2 = DB.find(DPerson.class)
|
||||
// .setAutoTune(false)
|
||||
// .where().idEq(id)
|
||||
// .findOne();
|
||||
//
|
||||
// Assert.assertNotNull(p2);
|
||||
// System.out.println(p2);
|
||||
// Assert.assertEquals(new Money(12200d), p2.getSalary());
|
||||
// Assert.assertNotNull(p2.getCmoney());
|
||||
// Assert.assertEquals(new Money("12"), p2.getCmoney().getAmount());
|
||||
// Assert.assertEquals(NZD, p2.getCmoney().getCurrency());
|
||||
//
|
||||
//
|
||||
// Query<DPerson> query = DB.find(DPerson.class)
|
||||
// .setAutoTune(false)
|
||||
// .where().gt("cmoney.amount",1)
|
||||
// .query();
|
||||
//
|
||||
// List<DPerson> list = query.findList();
|
||||
// Assert.assertTrue(list.size() >= 1);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user