mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
No effective change - modify TestHistoryInsert for more wait time and logging (PG test failing sometimes in CI)
This commit is contained in:
@@ -5,9 +5,10 @@ import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.SqlQuery;
|
||||
import com.avaje.ebean.SqlRow;
|
||||
import com.avaje.ebean.Version;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.tests.model.converstation.User;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
@@ -16,6 +17,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestHistoryInsert extends BaseTestCase {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(TestHistoryInsert.class);
|
||||
|
||||
@Test
|
||||
public void test() throws InterruptedException {
|
||||
|
||||
@@ -29,6 +32,7 @@ public class TestHistoryInsert extends BaseTestCase {
|
||||
user.setPasswordHash("someHash");
|
||||
|
||||
Ebean.save(user);
|
||||
logger.info("-- initial save");
|
||||
|
||||
Timestamp afterInsert = new Timestamp(System.currentTimeMillis());
|
||||
|
||||
@@ -40,7 +44,8 @@ public class TestHistoryInsert extends BaseTestCase {
|
||||
|
||||
user.setName("Jim v2");
|
||||
user.setPasswordHash("anotherHash");
|
||||
Thread.sleep(10); // wait, to ensure that whenModified differs
|
||||
Thread.sleep(50); // wait, to ensure that whenModified differs
|
||||
logger.info("-- update v2");
|
||||
Ebean.save(user);
|
||||
|
||||
history = fetchHistory(user);
|
||||
@@ -53,7 +58,9 @@ public class TestHistoryInsert extends BaseTestCase {
|
||||
|
||||
user.setName("Jim v3");
|
||||
user.setEmail("three@email.com");
|
||||
Thread.sleep(10); // otherwise the timestamp of "whenModified" may not change
|
||||
Thread.sleep(50); // otherwise the timestamp of "whenModified" may not change
|
||||
|
||||
logger.info("-- update v3");
|
||||
Ebean.save(user);
|
||||
|
||||
history = fetchHistory(user);
|
||||
@@ -65,6 +72,7 @@ public class TestHistoryInsert extends BaseTestCase {
|
||||
assertThat(versions).hasSize(3);
|
||||
assertThat(versions.get(0).getDiff()).containsKeys("name", "email", "version", "whenModified");
|
||||
|
||||
logger.info("-- delete");
|
||||
Ebean.delete(user);
|
||||
|
||||
User earlyVersion = Ebean.find(User.class).setId(user.getId()).asOf(afterInsert).findUnique();
|
||||
@@ -73,6 +81,7 @@ public class TestHistoryInsert extends BaseTestCase {
|
||||
|
||||
Ebean.find(User.class).setId(user.getId()).asOf(afterInsert).findUnique();
|
||||
|
||||
logger.info("-- last fetchHistory");
|
||||
|
||||
history = fetchHistory(user);
|
||||
assertThat(history).hasSize(3);
|
||||
|
||||
Reference in New Issue
Block a user