mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#963 - NullPointerException on no version provided (when setVersion(null) is used)
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
package io.ebeaninternal.server.deploy.generatedproperty;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.bean.EntityBean;
|
||||
import io.ebeaninternal.server.deploy.BeanProperty;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.Customer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
public class GeneratedCounterLongTest extends BaseTestCase {
|
||||
|
||||
private GeneratedCounterLong counter = new GeneratedCounterLong();
|
||||
|
||||
private BeanProperty version = getBeanDescriptor(Customer.class).getBeanProperty("version");
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void when_null_expect_IllegalStateException() throws Exception {
|
||||
|
||||
Customer customer = new Customer();
|
||||
counter.getUpdateValue(version, (EntityBean)customer, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void when_set_expect_incremented() throws Exception {
|
||||
|
||||
Customer customer = new Customer();
|
||||
customer.setVersion(7L);
|
||||
Object value = counter.getUpdateValue(version, (EntityBean) customer, System.currentTimeMillis());
|
||||
|
||||
assertThat(value).isEqualTo(8L);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user