mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Move some unit tests from ebean-test back to ebean-core
This commit is contained in:
@@ -6,10 +6,10 @@ import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.PFile;
|
||||
import org.tests.model.basic.PFileContent;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
public class TestDeleteImportedPartial extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -6,10 +6,10 @@ import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.PersistentFile;
|
||||
import org.tests.model.basic.PersistentFileContent;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
public class TestDeleteOneToOne extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -6,10 +6,10 @@ import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.PFile;
|
||||
import org.tests.model.basic.PFileContent;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
public class TestDeleteOneToOneMultiple extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -10,9 +10,7 @@ import javax.persistence.OptimisticLockException;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestIUDVanilla extends BaseTestCase {
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.tests.basic;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.test.LoggedSql;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.Country;
|
||||
import org.tests.model.basic.Customer;
|
||||
@@ -13,7 +12,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
class TestLoadBeanCache extends BaseTestCase {
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.PersistentFile;
|
||||
import org.tests.model.basic.PersistentFileContent;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
public class TestSaveDeleteOneToOne extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -6,10 +6,10 @@ import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.PFile;
|
||||
import org.tests.model.basic.PFileContent;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
public class TestSaveDeleteOneToOneMultiple extends BaseTestCase {
|
||||
|
||||
// public void testCreateDeletePFile() {
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
package org.tests.cache;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.OCachedBean;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Database;
|
||||
@@ -17,9 +9,16 @@ import io.ebean.config.CurrentTenantProvider;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.MdcBackgroundExecutorWrapper;
|
||||
import io.ebeaninternal.server.cache.DefaultServerCachePlugin;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.OCachedBean;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
/**
|
||||
* Test class testing async/background cache updates in a multi-tenant environment.
|
||||
* Test class testing async/background cache updates in a multi-tenant environment.
|
||||
*/
|
||||
public class TestBeanCacheAsync extends BaseTestCase {
|
||||
|
||||
@@ -63,7 +62,7 @@ public class TestBeanCacheAsync extends BaseTestCase {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void findById_with_tenant() throws InterruptedException {
|
||||
DatabaseConfig config = new DatabaseConfig();
|
||||
@@ -81,7 +80,7 @@ public class TestBeanCacheAsync extends BaseTestCase {
|
||||
config.setBackgroundExecutorWrapper(
|
||||
new MdcBackgroundExecutorWrapper().with(new TenantCopyBackgroundExecutorWrapper()));
|
||||
tenantId.set("4711");
|
||||
|
||||
|
||||
Database db = DatabaseFactory.create(config);
|
||||
try {
|
||||
OCachedBean bean = new OCachedBean();
|
||||
@@ -95,7 +94,7 @@ public class TestBeanCacheAsync extends BaseTestCase {
|
||||
db.save(bean0);
|
||||
|
||||
Thread.sleep(100); // TODO: can we block finds on that ID if a pending cache update is present?
|
||||
|
||||
|
||||
bean0 = db.find(OCachedBean.class, bean.getId());
|
||||
assertNotNull(bean0);
|
||||
assertThat(bean0.getName()).isEqualTo("findById2");
|
||||
|
||||
@@ -16,10 +16,7 @@ import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestQueryCache extends BaseTestCase {
|
||||
|
||||
|
||||
+2
-2
@@ -7,10 +7,10 @@ import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.PFile;
|
||||
import org.tests.model.basic.PFileContent;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class TestConstructorPutfieldReplacement extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
package org.tests.idkeys.db;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
public class GenKeySeqB {
|
||||
|
||||
public final static String SEQUENCE_NAME = "GEN_KEY_B_SEQ_NAME";
|
||||
|
||||
|
||||
private final static String SEQ_GEN_NAME = "SEQ_GEN_NAME";
|
||||
|
||||
/**
|
||||
* {@link GeneratedValue#generator()} links to {@link SequenceGenerator#name()}.
|
||||
* The name of the sequence is {@link SequenceGenerator#sequenceName()}.
|
||||
* The name of the sequence is {@link SequenceGenerator#sequenceName()}.
|
||||
*/
|
||||
@Id
|
||||
@SequenceGenerator(name = SEQ_GEN_NAME, sequenceName = GenKeySeqB.SEQUENCE_NAME)
|
||||
|
||||
@@ -7,7 +7,6 @@ import io.ebean.annotation.ForPlatform;
|
||||
import io.ebean.annotation.Platform;
|
||||
import io.ebean.test.LoggedSql;
|
||||
import io.ebean.text.json.EJson;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.json.EBasicJsonMap;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.tests.lazyforeignkeys;
|
||||
|
||||
import io.ebean.annotation.DbForeignKey;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
import org.tests.model.basic.Cat;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@@ -25,7 +23,7 @@ public class MainEntityRelation {
|
||||
@JoinColumn(name = "id2")
|
||||
@DbForeignKey(noConstraint = true)
|
||||
private MainEntity entity2;
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "cat_id")
|
||||
@DbForeignKey(noConstraint = true)
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package org.tests.model.basic.relates;
|
||||
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
import io.ebean.annotation.ChangeLog;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Relation entity
|
||||
*/
|
||||
@@ -60,5 +62,5 @@ public class Relation1 {
|
||||
public void setWithCascade(Relation2 withCascade) {
|
||||
this.withCascade = withCascade;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.tests.model.basic.relates;
|
||||
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
import io.ebean.annotation.ChangeLog;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Relation entity
|
||||
*/
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package org.tests.model.join;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
import io.ebean.annotation.DbForeignKey;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.UUID;
|
||||
|
||||
@Inheritance
|
||||
@Entity
|
||||
public abstract class HAccess {
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.tests.model.m2m;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.test.LoggedSql;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
package org.tests.model.onetoone;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Version;
|
||||
|
||||
import io.ebean.annotation.Where;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class OtoChildVersion {
|
||||
|
||||
@@ -25,12 +18,12 @@ public class OtoChildVersion {
|
||||
|
||||
@Version
|
||||
int version;
|
||||
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "ref_id")
|
||||
@Where(clause = "${mta}.type=1")
|
||||
List<OtoNotification> notifications;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -54,7 +47,7 @@ public class OtoChildVersion {
|
||||
public void setMaster(OtoMasterVersion master) {
|
||||
this.master = master;
|
||||
}
|
||||
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
package org.tests.model.onetoone;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Version;
|
||||
|
||||
import io.ebean.annotation.Where;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class OtoMasterVersion {
|
||||
|
||||
@@ -25,12 +18,12 @@ public class OtoMasterVersion {
|
||||
|
||||
@Version
|
||||
int version;
|
||||
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "ref_id")
|
||||
@Where(clause = "${mta}.type=0")
|
||||
List<OtoNotification> notifications;
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -62,5 +55,5 @@ public class OtoMasterVersion {
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.tests.model.onetoone;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Transaction;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -32,7 +31,7 @@ public class TestOneToOneCascadeSave extends BaseTestCase {
|
||||
OtoMaster master2 = child2.getMaster();
|
||||
assertNotNull(master2);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSaveCascadeWithOneToOne() {
|
||||
OtoMasterVersion master = new OtoMasterVersion();
|
||||
@@ -40,19 +39,19 @@ public class TestOneToOneCascadeSave extends BaseTestCase {
|
||||
|
||||
OtoChildVersion child = new OtoChildVersion();
|
||||
child.setName("c1");
|
||||
|
||||
|
||||
master.setChild(child);
|
||||
DB.save(master);
|
||||
|
||||
|
||||
assertThat(master.getVersion()).isEqualTo(1);
|
||||
assertThat(child.getVersion()).isEqualTo(1);
|
||||
|
||||
|
||||
child.setName("c2");
|
||||
DB.save(master);
|
||||
|
||||
|
||||
assertThat(master.getVersion()).isEqualTo(1);
|
||||
assertThat(child.getVersion()).isEqualTo(2);
|
||||
|
||||
|
||||
try (Transaction txn = DB.beginTransaction()) {
|
||||
master = DB.find(OtoMasterVersion.class).findOne();
|
||||
|
||||
@@ -61,10 +60,10 @@ public class TestOneToOneCascadeSave extends BaseTestCase {
|
||||
child = DB.find(OtoChildVersion.class).findOne();
|
||||
assertThat(child.getVersion()).isEqualTo(2);
|
||||
child.setName("c3");
|
||||
DB.save(child);
|
||||
|
||||
DB.save(child);
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import io.ebean.DB;
|
||||
import io.ebean.TransactionalTestCase;
|
||||
import io.ebean.text.csv.CsvReader;
|
||||
import io.ebean.util.IOUtils;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
@@ -37,7 +36,7 @@ public class TestCsvReader extends TransactionalTestCase {
|
||||
csvReader.addProperty("billingAddress.country.code");
|
||||
|
||||
csvReader.process(reader);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import io.ebean.TransactionalTestCase;
|
||||
import io.ebean.text.csv.CsvReader;
|
||||
import io.ebean.text.csv.DefaultCsvCallback;
|
||||
import io.ebean.util.IOUtils;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.tests.model.basic.Customer;
|
||||
|
||||
|
||||
@@ -5,10 +5,12 @@ import io.ebean.DB;
|
||||
import io.ebean.text.json.EJson;
|
||||
import io.ebean.text.json.JsonContext;
|
||||
import io.ebean.util.IOUtils;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.Reader;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@ import org.tests.model.basic.ResetBasicData;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class TestTextJsonReferenceBean extends BaseTestCase {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user