Refactor tests, move changelog tests

This commit is contained in:
Rob Bygrave
2022-03-25 18:44:24 +13:00
parent 88acd8190a
commit 88005dbe09
20 changed files with 1476 additions and 37 deletions
@@ -1,6 +1,5 @@
package io.ebeaninternal.server.changelog;
import io.ebean.xtest.BaseTestCase;
import io.ebean.event.changelog.BeanChange;
import io.ebean.event.changelog.ChangeSet;
import org.junit.jupiter.api.Test;
@@ -11,12 +10,12 @@ import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class ChangeJsonBuilderTest extends BaseTestCase {
class ChangeJsonBuilderTest {
Helper helper = new Helper();
@Test
public void testToJson() throws Exception {
void testToJson() throws Exception {
ChangeJsonBuilder builder = new ChangeJsonBuilder();
@@ -1,6 +1,5 @@
package io.ebeaninternal.server.changelog;
import io.ebean.xtest.BaseTestCase;
import io.ebean.event.changelog.ChangeLogFilter;
import org.junit.jupiter.api.Test;
import org.tests.inheritance.model.ProductConfiguration;
@@ -12,11 +11,10 @@ import org.tests.model.basic.Customer;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
public class DefaultChangeLogRegisterTest extends BaseTestCase {
class DefaultChangeLogRegisterTest {
@Test
public void test_defaultInsertTrue() {
void test_defaultInsertTrue() {
DefaultChangeLogRegister register = new DefaultChangeLogRegister(true);
@@ -39,7 +37,7 @@ public class DefaultChangeLogRegisterTest extends BaseTestCase {
}
@Test
public void test_defaultInsertFalse() {
void test_defaultInsertFalse() {
DefaultChangeLogRegister register = new DefaultChangeLogRegister(false);
@@ -62,8 +60,7 @@ public class DefaultChangeLogRegisterTest extends BaseTestCase {
}
@Test
public void test_inheritance() {
void test_inheritance() {
DefaultChangeLogRegister register = new DefaultChangeLogRegister(true);
ChangeLogFilter changeFilter = register.getChangeFilter(ProductConfiguration.class);
assertNotNull(changeFilter);
@@ -0,0 +1,16 @@
package org.tests.inheritance.model;
import javax.persistence.MappedSuperclass;
@MappedSuperclass
public class AbstractBaseClass {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,51 @@
package org.tests.inheritance.model;
import javax.persistence.*;
@Entity
public class CalculationResult {
@Id
@Column(name = "id")
private Integer id;
private double charge;
@ManyToOne(cascade = CascadeType.PERSIST)
private ProductConfiguration productConfiguration;
@ManyToOne(cascade = CascadeType.PERSIST)
private GroupConfiguration groupConfiguration;
public double getCharge() {
return charge;
}
public void setCharge(double charge) {
this.charge = charge;
}
public ProductConfiguration getProductConfiguration() {
return productConfiguration;
}
public void setProductConfiguration(ProductConfiguration productConfiguration) {
this.productConfiguration = productConfiguration;
}
public GroupConfiguration getGroupConfiguration() {
return groupConfiguration;
}
public void setGroupConfiguration(GroupConfiguration groupConfiguration) {
this.groupConfiguration = groupConfiguration;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
@@ -0,0 +1,43 @@
package org.tests.inheritance.model;
import io.ebean.annotation.Cache;
import io.ebean.annotation.ChangeLog;
import javax.persistence.*;
@ChangeLog
@Entity
@Cache(enableQueryCache = true)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING, columnDefinition = "varchar(21)")
public class Configuration extends AbstractBaseClass {
@Id
@Column(name = "id")
private Integer id;
@ManyToOne
private Configurations configurations;
public Configuration() {
super();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Configurations getConfigurations() {
return configurations;
}
public void setConfigurations(Configurations configurations) {
this.configurations = configurations;
}
}
@@ -0,0 +1,64 @@
package org.tests.inheritance.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import java.util.List;
@Entity
public class Configurations {
@Id
@Column(name = "id")
private Integer id;
private String name;
@OneToMany
private List<GroupConfiguration> groupConfigurations;
@OneToMany
private List<ProductConfiguration> productConfigurations;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<GroupConfiguration> getGroupConfigurations() {
return groupConfigurations;
}
public void setGroupConfigurations(List<GroupConfiguration> groupConfigurations) {
this.groupConfigurations = groupConfigurations;
}
public void addGroupConfiguration(GroupConfiguration groupConfiguration) {
groupConfiguration.setConfigurations(this);
groupConfigurations.add(groupConfiguration);
}
public List<ProductConfiguration> getProductConfigurations() {
return productConfigurations;
}
public void setProductConfigurations(List<ProductConfiguration> productConfigurations) {
this.productConfigurations = productConfigurations;
}
public void addProductConfiguration(ProductConfiguration productConfiguration) {
productConfiguration.setConfigurations(this);
productConfigurations.add(productConfiguration);
}
}
@@ -0,0 +1,40 @@
package org.tests.inheritance.model;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import java.util.List;
@Entity
@DiscriminatorValue("2")
public class GroupConfiguration extends Configuration {
private String groupName;
@OneToMany(mappedBy = "groupConfiguration")
private List<CalculationResult> results;
public GroupConfiguration() {
super();
}
public GroupConfiguration(String name) {
super();
this.groupName = name;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public List<CalculationResult> getResults() {
return results;
}
public void setResults(List<CalculationResult> results) {
this.results = results;
}
}
@@ -0,0 +1,35 @@
package org.tests.inheritance.model;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import java.util.List;
@Entity
@DiscriminatorValue("1")
public class ProductConfiguration extends Configuration {
private String productName;
@OneToMany(mappedBy = "productConfiguration")
private List<CalculationResult> results;
public ProductConfiguration() {
super();
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public List<CalculationResult> getResults() {
return results;
}
public void setResults(List<CalculationResult> results) {
this.results = results;
}
}
@@ -0,0 +1,147 @@
package org.tests.model.basic;
import io.ebean.annotation.InvalidateQueryCache;
import javax.persistence.*;
import javax.validation.constraints.Size;
import java.sql.Timestamp;
/**
* Address entity bean.
*/
// Address is not L2 cached directly but it is joined to queries that are cached
// What InvalidateQueryCache means is that we propagate a table modification event
// when address is changed ... and cached queries that join to address will be
// invalidated accordingly.
@InvalidateQueryCache
@Entity
@Table(name = "o_address")
public class Address {
@Id
Integer id;
@Size(max = 100)
@Column(name = "line_1")
String line1;
//@SizeMedium
@Column(name = "line_2")
String line2;
//@SizeMedium
String city;
Timestamp cretime;
@Version
Timestamp updtime;
@ManyToOne
Country country;
@Override
public String toString() {
return id + " " + line1 + " " + line2 + " " + city + " " + country;
}
/**
* Return id.
*/
public Integer getId() {
return id;
}
/**
* Set id.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* Return line 1.
*/
public String getLine1() {
return line1;
}
/**
* Set line 1.
*/
public void setLine1(String line1) {
this.line1 = line1;
}
/**
* Return line 2.
*/
public String getLine2() {
return line2;
}
/**
* Set line 2.
*/
public void setLine2(String line2) {
this.line2 = line2;
}
/**
* Return city.
*/
public String getCity() {
return city;
}
/**
* Set city.
*/
public void setCity(String city) {
this.city = city;
}
/**
* Return cretime.
*/
public Timestamp getCretime() {
return cretime;
}
/**
* Set cretime.
*/
public void setCretime(Timestamp cretime) {
this.cretime = cretime;
}
/**
* Return updtime.
*/
public Timestamp getUpdtime() {
return updtime;
}
/**
* Set updtime.
*/
public void setUpdtime(Timestamp updtime) {
this.updtime = updtime;
}
/**
* Return country.
*/
public Country getCountry() {
return country;
}
/**
* Set country.
*/
public void setCountry(Country country) {
this.country = country;
}
}
@@ -0,0 +1,60 @@
package org.tests.model.basic;
import io.ebean.annotation.WhenCreated;
import io.ebean.annotation.WhenModified;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import java.io.Serializable;
import java.sql.Timestamp;
@MappedSuperclass
public class BasicDomain implements Serializable {
private static final long serialVersionUID = 5569496199004449769L;
@Id
Integer id;
@WhenCreated
Timestamp cretime;
@WhenModified
Timestamp updtime;
@Version
Long version;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Timestamp getUpdtime() {
return updtime;
}
public void setUpdtime(Timestamp updtime) {
this.updtime = updtime;
}
public Timestamp getCretime() {
return cretime;
}
public void setCretime(Timestamp cretime) {
this.cretime = cretime;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
}
@@ -1,4 +1,155 @@
package org.tests.model.basic;
import io.ebean.annotation.Index;
import io.ebean.annotation.*;
import javax.persistence.*;
import javax.validation.constraints.Size;
import java.sql.Timestamp;
import java.util.List;
@DocStore
@Index(columnNames = {"last_name", "first_name"})
@ChangeLog
@Entity
@Cache(naturalKey = "email")
public class Contact {
@Id @GeneratedValue
int id;
@Size(max=127)
String firstName;
@Size(max=127)
String lastName;
String phone;
String mobile;
String email;
boolean isMember;
@DocEmbedded(doc = "id,name")
@ManyToOne(optional = false)
Customer customer;
@ManyToOne(optional = true)
ContactGroup group;
@OneToMany(cascade = CascadeType.ALL)
List<ContactNote> notes;
@CreatedTimestamp
Timestamp cretime;
@Version
Timestamp updtime;
public Contact(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public Contact() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Timestamp getUpdtime() {
return updtime;
}
public void setUpdtime(Timestamp updtime) {
this.updtime = updtime;
}
public Timestamp getCretime() {
return cretime;
}
public void setCretime(Timestamp cretime) {
this.cretime = cretime;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public boolean isMember() {
return isMember;
}
public void setMember(boolean member) {
isMember = member;
}
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public ContactGroup getGroup() {
return group;
}
public void setGroup(ContactGroup group) {
this.group = group;
}
public List<ContactNote> getNotes() {
return notes;
}
public void setNotes(List<ContactNote> notes) {
this.notes = notes;
}
}
@@ -0,0 +1,20 @@
package org.tests.model.basic;
import javax.persistence.Entity;
@Entity
public class ContactGroup extends BasicDomain {
private static final long serialVersionUID = -5447111032760796085L;
String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,51 @@
package org.tests.model.basic;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.validation.constraints.Size;
@Entity
public class ContactNote extends BasicDomain {
private static final long serialVersionUID = 7949702621226333278L;
@ManyToOne
Contact contact;
String title;
@Size(max = 2000)
@Lob
String note;
public ContactNote(String title, String note) {
this.title = title;
this.note = note;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public Contact getContact() {
return contact;
}
public void setContact(Contact contact) {
this.contact = contact;
}
}
@@ -0,0 +1,63 @@
package org.tests.model.basic;
import io.ebean.annotation.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Size;
/**
* Country entity bean.
*/
@DocStore
@ReadAudit
@ChangeLog(inserts = ChangeLogInsertMode.INCLUDE)
@Cache(readOnly = true, enableQueryCache = true)
@CacheBeanTuning(maxSize = 500)
@Entity
@Table(name = "o_country")
public class Country {
@Id
@Size(max = 2)
String code;
@Size(max = 60)
String name;
@Override
public String toString() {
return code;
}
/**
* Return code.
*/
public String getCode() {
return code;
}
/**
* Set code.
*/
public void setCode(String code) {
this.code = code;
}
/**
* Return name.
*/
public String getName() {
return name;
}
/**
* Set name.
*/
public void setName(String name) {
this.name = name;
}
}
@@ -1,4 +1,211 @@
package org.tests.model.basic;
public class Customer {
import io.ebean.annotation.*;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
/**
* Customer entity bean.
*/
@NamedQueries(
value = {
@NamedQuery(name = "name", query = "select(name) order by name"),
@NamedQuery(name = "withStatus", query = "select(name,status) order by name")
}
)
@NamedQuery(name = "withContacts", query = "fetch contacts (firstName, lastName) where id = :id")
@Cache(enableQueryCache = true)
@DocStore
@ChangeLog(inserts = ChangeLogInsertMode.EXCLUDE, updatesThatInclude = {"name", "status"})
@Entity
@Table(name = "o_customer")
@DbComment("Holds external customers")
public class Customer extends BasicDomain {
private static final long serialVersionUID = 1L;
//public static final CustomerFinder find = new CustomerFinder();
/**
* EnumValue is an Ebean specific mapping for enums.
*/
public enum Status {
NEW("N"),
ACTIVE("A"),
INACTIVE("I");
String dbValue;
Status(String dbValue) {
this.dbValue = dbValue;
}
@DbEnumValue
public String getValue() {
return dbValue;
}
}
@Transient
Boolean selected;
@JsonIgnore
//@Expose(deserialize = false, serialize = false)
@Transient
ReentrantLock lock = new ReentrantLock();
@DbComment("status of the customer")
Status status;
@NotNull
@Size(max = 40)
String name;
@DbComment("Short notes regarding the customer")
@Size(max = 100)
String smallnote;
@DbComment("Join date of the customer")
@NotNull//(groups = {ValidationGroupSomething.class})
Date anniversary;
@DocEmbedded(doc = "*,country(*)")
@ManyToOne(cascade = CascadeType.ALL)
Address billingAddress;
@DocEmbedded(doc = "*,country(*)")
@ManyToOne(cascade = CascadeType.ALL)
Address shippingAddress;
@OneToMany(mappedBy = "customer")
@Where(clause = "${ta}.order_date is not null")
List<Order> orders;
@OneToMany(mappedBy = "customer", cascade = CascadeType.ALL)
List<Contact> contacts;
@Override
public String toString() {
return id + " " + status + " " + name;
}
/**
* Return name.
*/
public String getName() {
return name;
}
/**
* Set name.
*/
public void setName(String name) {
this.name = name;
}
/**
* Return billing address.
*/
public Address getBillingAddress() {
return billingAddress;
}
/**
* Set billing address.
*/
public void setBillingAddress(Address billingAddress) {
this.billingAddress = billingAddress;
}
/**
* Return status.
*/
public Status getStatus() {
return status;
}
/**
* Set status.
*/
public void setStatus(Status status) {
this.status = status;
}
/**
* Return shipping address.
*/
public Address getShippingAddress() {
return shippingAddress;
}
/**
* Set shipping address.
*/
public void setShippingAddress(Address shippingAddress) {
this.shippingAddress = shippingAddress;
}
/**
* Return orders.
*/
public List<Order> getOrders() {
return orders;
}
/**
* Set orders.
*/
public void setOrders(List<Order> orders) {
this.orders = orders;
}
public Boolean getSelected() {
return selected;
}
public void setSelected(Boolean selected) {
this.selected = selected;
}
public ReentrantLock getLock() {
return lock;
}
public String getSmallnote() {
return smallnote;
}
public void setSmallnote(String smallnote) {
this.smallnote = smallnote;
}
public Date getAnniversary() {
return anniversary;
}
public void setAnniversary(Date anniversary) {
this.anniversary = anniversary;
}
public List<Contact> getContacts() {
return contacts;
}
public void setContacts(List<Contact> contacts) {
this.contacts = contacts;
}
public void addContact(Contact contact) {
if (contacts == null) {
contacts = new ArrayList<>();
}
contacts.add(contact);
}
}
@@ -0,0 +1,252 @@
package org.tests.model.basic;
import io.ebean.annotation.*;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
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")
public class Order implements Serializable {
private static final long serialVersionUID = 1L;
public enum Status {
NEW,
APPROVED,
SHIPPED,
COMPLETE
}
@Id
Integer id;
/**
* Derived total amount from the order details. Needs to be explicitly included in query as Transient.
* Removing the Transient would mean by default it would be included in a order query.
* <p>
* NOTE: The join clause for totalAmount and totalItems is the same. If your query includes both
* totalAmount and totalItems only the one join is added to the query.
* </p>
*/
@Transient
@Formula(
select = "z_b${ta}.total_amount",
join = "join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_b${ta} on z_b${ta}.order_id = ${ta}.id")
Double totalAmount;
/**
* Derived total item count from the order details. Needs to be explicitly included in query as Transient.
*/
@Transient
@Formula(
select = "z_b${ta}.total_items",
join = "join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_b${ta} on z_b${ta}.order_id = ${ta}.id")
Integer totalItems;
@Enumerated(value = EnumType.ORDINAL)
Status status = Status.NEW;
Date orderDate = new Date(System.currentTimeMillis());
Date shipDate;
@NotNull
@ManyToOne(cascade = CascadeType.PERSIST)
@JoinColumn(name = "kcustomer_id")
@DocEmbedded(doc = "id,name")
Customer customer;
@Column(name = "name", table = "o_customer")
String customerName;
@WhenCreated
Timestamp cretime;
@Version
Timestamp updtime;
@Where(clause = "${ta}.id > 0")
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order")
@OrderBy("id asc, orderQty asc, cretime desc")
@DocEmbedded
List<OrderDetail> details;
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "order", orphanRemoval = true)
// List<OrderShipment> shipments;
@Override
public String toString() {
return id + " totalAmount:" + totalAmount + " totalItems:" + totalItems;
}
/**
* Return id.
*/
public Integer getId() {
return id;
}
/**
* Set id.
*/
public void setId(Integer id) {
this.id = id;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public Double getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(Double totalAmount) {
this.totalAmount = totalAmount;
}
public Integer getTotalItems() {
return totalItems;
}
public void setTotalItems(Integer totalItems) {
this.totalItems = totalItems;
}
/**
* Return order date.
*/
public Date getOrderDate() {
return orderDate;
}
/**
* Set order date.
*/
public void setOrderDate(Date orderDate) {
this.orderDate = orderDate;
}
/**
* Return ship date.
*/
public Date getShipDate() {
return shipDate;
}
/**
* Set ship date.
*/
public void setShipDate(Date shipDate) {
this.shipDate = shipDate;
}
/**
* Return cretime.
*/
public Timestamp getCretime() {
return cretime;
}
/**
* Set cretime.
*/
public void setCretime(Timestamp cretime) {
this.cretime = cretime;
}
/**
* Return updtime.
*/
public Timestamp getUpdtime() {
return updtime;
}
/**
* Set updtime.
*/
public void setUpdtime(Timestamp updtime) {
this.updtime = updtime;
}
/**
* Return status.
*/
public Status getStatus() {
return status;
}
/**
* Set status.
*/
public void setStatus(Status status) {
this.status = status;
}
/**
* Return customer.
*/
public Customer getCustomer() {
return customer;
}
/**
* Set customer.
*/
public void setCustomer(Customer customer) {
this.customer = customer;
}
/**
* Return details.
*/
public List<OrderDetail> getDetails() {
return details;
}
/**
* Set details.
*/
public void setDetails(List<OrderDetail> details) {
this.details = details;
}
public void addDetail(OrderDetail detail) {
if (details == null) {
details = new ArrayList<>();
}
details.add(detail);
}
// public List<OrderShipment> getShipments() {
// return shipments;
// }
//
// public void setShipments(List<OrderShipment> shipments) {
// this.shipments = shipments;
// }
//
// public void addShipment(OrderShipment shipment) {
//
// if (shipments == null) {
// shipments = new ArrayList<>();
// }
// shipments.add(shipment);
// }
}
@@ -0,0 +1,157 @@
package org.tests.model.basic;
import io.ebean.annotation.Cache;
import io.ebean.annotation.DocEmbedded;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
/**
* Order Detail entity bean.
*/
@Cache
@Entity
@Table(name = "o_order_detail")
public class OrderDetail implements Serializable {
private static final long serialVersionUID = 1L;
@Id
Integer id;
@ManyToOne(optional = false)
Order order;
Integer orderQty;
Integer shipQty;
BigDecimal unitPrice;
@ManyToOne
@DocEmbedded(doc = "id,name,sku")
Product product;
Timestamp cretime;
@Version
Timestamp updtime;
public OrderDetail() {
}
public OrderDetail(Product product, Integer orderQty, BigDecimal unitPrice) {
this.product = product;
this.orderQty = orderQty;
this.unitPrice = unitPrice;
}
/**
* Return id.
*/
public Integer getId() {
return id;
}
/**
* Set id.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* Return order qty.
*/
public Integer getOrderQty() {
return orderQty;
}
/**
* Set order qty.
*/
public void setOrderQty(Integer orderQty) {
this.orderQty = orderQty;
}
/**
* Return ship qty.
*/
public Integer getShipQty() {
return shipQty;
}
/**
* Set ship qty.
*/
public void setShipQty(Integer shipQty) {
this.shipQty = shipQty;
}
public BigDecimal getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(BigDecimal unitPrice) {
this.unitPrice = unitPrice;
}
/**
* Return cretime.
*/
public Timestamp getCretime() {
return cretime;
}
/**
* Set cretime.
*/
public void setCretime(Timestamp cretime) {
this.cretime = cretime;
}
/**
* Return updtime.
*/
public Timestamp getUpdtime() {
return updtime;
}
/**
* Set updtime.
*/
public void setUpdtime(Timestamp updtime) {
this.updtime = updtime;
}
/**
* Return order.
*/
public Order getOrder() {
return order;
}
/**
* Set order.
*/
public void setOrder(Order order) {
this.order = order;
}
/**
* Return product.
*/
public Product getProduct() {
return product;
}
/**
* Set product.
*/
public void setProduct(Product product) {
this.product = product;
}
}
@@ -0,0 +1,112 @@
package org.tests.model.basic;
import io.ebean.annotation.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.sql.Timestamp;
import static io.ebean.annotation.IdentityGenerated.BY_DEFAULT;
/**
* Product entity bean.
*/
@Identity(generated = BY_DEFAULT)
@DocStore
@Cache
@CacheQueryTuning(maxSecsToLive = 15)
@Entity
@Table(name = "o_product")
public class Product implements Serializable {
private static final long serialVersionUID = 1L;
@Id
Integer id;
@Size(max = 20)
String sku;
String name;
@CreatedTimestamp
Timestamp cretime;
@Version
Timestamp updtime;
/**
* Return id.
*/
public Integer getId() {
return id;
}
/**
* Set id.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* Return sku.
*/
public String getSku() {
return sku;
}
/**
* Set sku.
*/
public void setSku(String sku) {
this.sku = sku;
}
/**
* Return name.
*/
public String getName() {
return name;
}
/**
* Set name.
*/
public void setName(String name) {
this.name = name;
}
/**
* Return cretime.
*/
public Timestamp getCretime() {
return cretime;
}
/**
* Set cretime.
*/
public void setCretime(Timestamp cretime) {
this.cretime = cretime;
}
/**
* Return updtime.
*/
public Timestamp getUpdtime() {
return updtime;
}
/**
* Set updtime.
*/
public void setUpdtime(Timestamp updtime) {
this.updtime = updtime;
}
}
@@ -1,26 +0,0 @@
package io.ebeaninternal.server.changelog;
import io.ebean.xtest.BaseTestCase;
import io.ebean.DB;
import io.ebean.Database;
import io.ebean.event.changelog.ChangeSet;
import org.junit.jupiter.api.Test;
public class DefaultChangeLogListenerTest extends BaseTestCase {
Helper helper = new Helper();
@Test
public void test() {
DefaultChangeLogListener changeLogListener = new DefaultChangeLogListener();
Database defaultServer = DB.getDefault();
changeLogListener.configure(defaultServer.pluginApi());
ChangeSet changeSet = helper.createChangeSet("INT-001", 13);
changeLogListener.log(changeSet);
}
}