mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
#2357 - Update tests to move away from deprecated methods
This commit is contained in:
1 parent
e95442d8ec
commit
66143280fa
19 files changed
+57
-66
No files matched your search
@@ -158,7 +158,7 @@ public abstract class BaseTestCase {
|
||||
}
|
||||
|
||||
public boolean isPlatformCaseSensitive() {
|
||||
return spiEbeanServer().getDatabasePlatform().isCaseSensitiveCollation();
|
||||
return spiEbeanServer().databasePlatform().isCaseSensitiveCollation();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,7 +206,7 @@ public abstract class BaseTestCase {
|
||||
}
|
||||
|
||||
public boolean isPlatformBooleanNative() {
|
||||
return Types.BOOLEAN == spiEbeanServer().getDatabasePlatform().getBooleanDbType();
|
||||
return Types.BOOLEAN == spiEbeanServer().databasePlatform().getBooleanDbType();
|
||||
}
|
||||
|
||||
public boolean isPlatformOrderNullsSupport() {
|
||||
@@ -214,11 +214,11 @@ public abstract class BaseTestCase {
|
||||
}
|
||||
|
||||
public boolean isPlatformSupportsDeleteTableAlias() {
|
||||
return spiEbeanServer().getDatabasePlatform().isSupportsDeleteTableAlias();
|
||||
return spiEbeanServer().databasePlatform().isSupportsDeleteTableAlias();
|
||||
}
|
||||
|
||||
public boolean isPersistBatchOnCascade() {
|
||||
return spiEbeanServer().getDatabasePlatform().getPersistBatchOnCascade() != PersistBatch.NONE;
|
||||
return spiEbeanServer().databasePlatform().getPersistBatchOnCascade() != PersistBatch.NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,19 +237,19 @@ public abstract class BaseTestCase {
|
||||
}
|
||||
|
||||
protected Platform platform() {
|
||||
return spiEbeanServer().getDatabasePlatform().getPlatform().base();
|
||||
return spiEbeanServer().databasePlatform().getPlatform().base();
|
||||
}
|
||||
|
||||
protected IdType idType() {
|
||||
return spiEbeanServer().getDatabasePlatform().getDbIdentity().getIdType();
|
||||
return spiEbeanServer().databasePlatform().getDbIdentity().getIdType();
|
||||
}
|
||||
|
||||
protected SpiEbeanServer spiEbeanServer() {
|
||||
return (SpiEbeanServer) DB.getDefault();
|
||||
}
|
||||
|
||||
protected EbeanServer server() {
|
||||
return Ebean.getDefaultServer();
|
||||
protected Database server() {
|
||||
return DB.getDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,7 +283,7 @@ public abstract class BaseTestCase {
|
||||
}
|
||||
|
||||
protected String concat(String property0, String separator, String property1, String suffix) {
|
||||
DbExpressionHandler dbExpressionHandler = DbExpressionHandlerFactory.from(spiEbeanServer().getDatabasePlatform());
|
||||
DbExpressionHandler dbExpressionHandler = DbExpressionHandlerFactory.from(spiEbeanServer().databasePlatform());
|
||||
return dbExpressionHandler.concat(property0, separator, property1, suffix);
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -1,8 +1,8 @@
|
||||
package io.ebeaninternal.dbmigration.ddlgeneration;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebean.config.dbplatform.hana.HanaPlatform;
|
||||
@@ -18,7 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class BaseDdlHandlerTest extends BaseTestCase {
|
||||
|
||||
private ServerConfig serverConfig = new ServerConfig();
|
||||
private final DatabaseConfig serverConfig = new DatabaseConfig();
|
||||
|
||||
private DdlHandler handler(DatabasePlatform platform) {
|
||||
return PlatformDdlBuilder.create(platform).createDdlHandler(serverConfig);
|
||||
@@ -227,7 +227,7 @@ public class BaseDdlHandlerTest extends BaseTestCase {
|
||||
@Test
|
||||
public void generateChangeSetFromModel() throws Exception {
|
||||
|
||||
SpiEbeanServer defaultServer = (SpiEbeanServer) Ebean.getDefaultServer();
|
||||
SpiEbeanServer defaultServer = (SpiEbeanServer) DB.getDefault();
|
||||
|
||||
ChangeSet createChangeSet = new CurrentModel(defaultServer).getChangeSet();
|
||||
|
||||
@@ -246,8 +246,7 @@ public class BaseDdlHandlerTest extends BaseTestCase {
|
||||
@Disabled
|
||||
@Test
|
||||
public void generateChangeSetFromModel_given_postgresTypes() throws Exception {
|
||||
|
||||
SpiEbeanServer defaultServer = (SpiEbeanServer) Ebean.getDefaultServer();
|
||||
SpiEbeanServer defaultServer = (SpiEbeanServer) DB.getDefault();
|
||||
|
||||
ChangeSet createChangeSet = new CurrentModel(defaultServer).getChangeSet();
|
||||
|
||||
|
||||
+4
-6
@@ -1,18 +1,18 @@
|
||||
package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
||||
|
||||
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.dbplatform.clickhouse.ClickHousePlatform;
|
||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
|
||||
import io.ebean.config.dbplatform.oracle.OraclePlatform;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.Helper;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.PlatformDdlBuilder;
|
||||
import io.ebeaninternal.dbmigration.migration.AddTableComment;
|
||||
import io.ebeaninternal.dbmigration.migration.AlterColumn;
|
||||
import io.ebeaninternal.dbmigration.migration.Column;
|
||||
import io.ebeaninternal.dbmigration.migration.CreateTable;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.PlatformDdlBuilder;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -24,13 +24,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class BaseTableDdlTest {
|
||||
|
||||
private ServerConfig serverConfig = new ServerConfig();
|
||||
|
||||
private PlatformDdl h2ddl = PlatformDdlBuilder.create(new H2Platform());
|
||||
private final DatabaseConfig serverConfig = new DatabaseConfig();
|
||||
private final PlatformDdl h2ddl = PlatformDdlBuilder.create(new H2Platform());
|
||||
|
||||
@Test
|
||||
public void testAlterColumn() throws IOException {
|
||||
|
||||
BaseTableDdl ddlGen = new BaseTableDdl(serverConfig, h2ddl);
|
||||
|
||||
DdlWrite write = new DdlWrite();
|
||||
|
||||
+5
-5
@@ -1,14 +1,14 @@
|
||||
package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
||||
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.DdlOptions;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.PlatformDdlBuilder;
|
||||
import io.ebeaninternal.dbmigration.model.CurrentModel;
|
||||
import io.ebeaninternal.dbmigration.model.MConfiguration;
|
||||
import io.ebeaninternal.dbmigration.model.ModelContainer;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.dbmigration.ddlgeneration.PlatformDdlBuilder;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -19,7 +19,7 @@ public class H2HistoryDdlTest {
|
||||
@Test
|
||||
public void testRegenerateHistoryTriggers() throws Exception {
|
||||
|
||||
SpiEbeanServer ebeanServer = (SpiEbeanServer) Ebean.getDefaultServer();
|
||||
SpiEbeanServer ebeanServer = (SpiEbeanServer) DB.getDefault();
|
||||
|
||||
HistoryTableUpdate update = new HistoryTableUpdate("c_user");
|
||||
update.add(HistoryTableUpdate.Change.ADD, "one");
|
||||
@@ -32,7 +32,7 @@ public class H2HistoryDdlTest {
|
||||
|
||||
H2Platform h2Platform = new H2Platform();
|
||||
PlatformDdl h2Ddl = PlatformDdlBuilder.create(h2Platform);
|
||||
h2Ddl.configure(ebeanServer.getServerConfig());
|
||||
h2Ddl.configure(ebeanServer.config());
|
||||
h2Ddl.regenerateHistoryTriggers(write, update);
|
||||
|
||||
assertThat(write.applyHistoryView().isEmpty()).isFalse();
|
||||
|
||||
+9
-9
@@ -1,6 +1,6 @@
|
||||
package io.ebeaninternal.dbmigration.ddlgeneration.platform;
|
||||
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.dbplatform.h2.H2Platform;
|
||||
import io.ebean.config.dbplatform.hana.HanaPlatform;
|
||||
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
|
||||
@@ -14,12 +14,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class PlatformDdl_dropUniqueConstraintTest {
|
||||
|
||||
private PlatformDdl h2Ddl = PlatformDdlBuilder.create(new H2Platform());
|
||||
private PlatformDdl pgDdl = PlatformDdlBuilder.create(new PostgresPlatform());
|
||||
private PlatformDdl mysqlDdl = PlatformDdlBuilder.create(new MySqlPlatform());
|
||||
private PlatformDdl oraDdl = PlatformDdlBuilder.create(new OraclePlatform());
|
||||
private PlatformDdl sqlServerDdl = PlatformDdlBuilder.create(new SqlServer17Platform());
|
||||
private PlatformDdl hanaDdl = PlatformDdlBuilder.create(new HanaPlatform());
|
||||
private final PlatformDdl h2Ddl = PlatformDdlBuilder.create(new H2Platform());
|
||||
private final PlatformDdl pgDdl = PlatformDdlBuilder.create(new PostgresPlatform());
|
||||
private final PlatformDdl mysqlDdl = PlatformDdlBuilder.create(new MySqlPlatform());
|
||||
private final PlatformDdl oraDdl = PlatformDdlBuilder.create(new OraclePlatform());
|
||||
private final PlatformDdl sqlServerDdl = PlatformDdlBuilder.create(new SqlServer17Platform());
|
||||
private final PlatformDdl hanaDdl = PlatformDdlBuilder.create(new HanaPlatform());
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
@@ -39,8 +39,8 @@ public class PlatformDdl_dropUniqueConstraintTest {
|
||||
sql = mysqlDdl.alterTableDropUniqueConstraint("mytab", "uq_name");
|
||||
assertEquals("alter table mytab drop index uq_name", sql);
|
||||
|
||||
ServerConfig serverConfig = new ServerConfig();
|
||||
hanaDdl.configure(serverConfig);
|
||||
DatabaseConfig config = new DatabaseConfig();
|
||||
hanaDdl.configure(config);
|
||||
sql = hanaDdl.alterTableDropUniqueConstraint("mytab", "uq_name");
|
||||
assertEquals("delimiter $$\n" +
|
||||
"do\n" +
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class ModelBuildBeanVisitorTest extends BaseTestCase {
|
||||
|
||||
ModelContainer model = new ModelContainer();
|
||||
|
||||
DbConstraintNaming constraintNaming = defaultServer.getServerConfig().getConstraintNaming();
|
||||
DbConstraintNaming constraintNaming = defaultServer.config().getConstraintNaming();
|
||||
constraintNaming.setMaxLength(new DefaultConstraintMaxLength(60));
|
||||
ModelBuildContext ctx = new ModelBuildContext(model, new H2Platform(), constraintNaming, true);
|
||||
|
||||
|
||||
+3
-4
@@ -1,7 +1,7 @@
|
||||
package org.tests.inheritance.company.domain;
|
||||
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.EbeanServer;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.Database;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
@@ -13,8 +13,7 @@ public class TestInheritAbstract {
|
||||
|
||||
@Test
|
||||
public void testMe() {
|
||||
|
||||
EbeanServer server = Ebean.getServer(null);
|
||||
Database server = DB.getDefault();
|
||||
|
||||
List<AbstractBar> list0 = server.find(AbstractBar.class)
|
||||
.findList();
|
||||
|
||||
Reference in new issue
Block a user