mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
Tidy tests only TestInsertSqlLogging and TestSqlUpdateExceptions
This commit is contained in:
1 parent
9846ebd65d
commit
cc637d56e1
2 files changed
+19
-21
No files matched your search
@@ -1,7 +1,7 @@
|
||||
package org.tests.rawsql;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.SqlUpdate;
|
||||
import io.ebean.Transaction;
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
@@ -17,12 +17,12 @@ public class TestInsertSqlLogging extends BaseTestCase {
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
Ebean.find(AuditLog.class).where().ge("id", 10000).delete();
|
||||
DB.find(AuditLog.class).where().ge("id", 10000).delete();
|
||||
|
||||
String sql = "insert into audit_log (id, description, modified_description) values (?,?,?)";
|
||||
SqlUpdate insert = Ebean.createSqlUpdate(sql);
|
||||
SqlUpdate insert = DB.sqlUpdate(sql);
|
||||
|
||||
try (Transaction txn = Ebean.beginTransaction()) {
|
||||
try (Transaction txn = DB.beginTransaction()) {
|
||||
txn.setBatchMode(true);
|
||||
txn.setBatchSize(2);
|
||||
|
||||
@@ -48,12 +48,12 @@ public class TestInsertSqlLogging extends BaseTestCase {
|
||||
@Test
|
||||
public void addBatch_executeBatch() {
|
||||
|
||||
Ebean.find(AuditLog.class).where().ge("id", 10000).delete();
|
||||
DB.find(AuditLog.class).where().ge("id", 10000).delete();
|
||||
|
||||
String sql = "insert into audit_log (id, description, modified_description) values (?,?,?)";
|
||||
SqlUpdate insert = Ebean.createSqlUpdate(sql);
|
||||
SqlUpdate insert = DB.sqlUpdate(sql);
|
||||
|
||||
try (Transaction txn = Ebean.beginTransaction()) {
|
||||
try (Transaction txn = DB.beginTransaction()) {
|
||||
|
||||
insert.setParameter(10000);
|
||||
insert.setParameter("hello");
|
||||
@@ -80,12 +80,12 @@ public class TestInsertSqlLogging extends BaseTestCase {
|
||||
@Test
|
||||
public void addBatch_namedParams() {
|
||||
|
||||
Ebean.find(AuditLog.class).where().ge("id", 10000).delete();
|
||||
DB.find(AuditLog.class).where().ge("id", 10000).delete();
|
||||
|
||||
String sql = "insert into audit_log (id, description, modified_description) values (:id, :desc, :modDesc)";
|
||||
SqlUpdate insert = Ebean.createSqlUpdate(sql);
|
||||
SqlUpdate insert = DB.sqlUpdate(sql);
|
||||
|
||||
try (Transaction txn = Ebean.beginTransaction()) {
|
||||
try (Transaction txn = DB.beginTransaction()) {
|
||||
|
||||
insert.setParameter("id", 20000);
|
||||
insert.setParameter("desc", "hello");
|
||||
@@ -112,10 +112,10 @@ public class TestInsertSqlLogging extends BaseTestCase {
|
||||
@Test
|
||||
public void test_trim_leadingSpaces_eventFound() {
|
||||
|
||||
Transaction transaction = Ebean.beginTransaction();
|
||||
Transaction transaction = DB.beginTransaction();
|
||||
try {
|
||||
String upd = " update audit_log set description='junk' where id = 10001";
|
||||
SqlUpdate update = Ebean.createSqlUpdate(upd);
|
||||
SqlUpdate update = DB.sqlUpdate(upd);
|
||||
update.execute();
|
||||
transaction.commit();
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.tests.update;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.DuplicateKeyException;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.SqlUpdate;
|
||||
import io.ebean.Transaction;
|
||||
import org.junit.Test;
|
||||
@@ -38,7 +37,7 @@ public class TestSqlUpdateExceptions extends BaseTestCase {
|
||||
|
||||
UUID id = UUID.randomUUID();
|
||||
|
||||
SqlUpdate sqlUpdate = Ebean.createSqlUpdate(sql);
|
||||
SqlUpdate sqlUpdate = DB.sqlUpdate(sql);
|
||||
sqlUpdate.setParameter(1, id);
|
||||
sqlUpdate.setParameter(2, "hi");
|
||||
sqlUpdate.setParameter(3, 1);
|
||||
@@ -53,10 +52,9 @@ public class TestSqlUpdateExceptions extends BaseTestCase {
|
||||
@Test(expected = DuplicateKeyException.class)
|
||||
public void duplicateKey_executeNow() {
|
||||
|
||||
|
||||
UUID id = UUID.randomUUID();
|
||||
|
||||
SqlUpdate sqlUpdate = Ebean.createSqlUpdate(sql);
|
||||
SqlUpdate sqlUpdate = DB.sqlUpdate(sql);
|
||||
sqlUpdate.setParameter(1, id);
|
||||
sqlUpdate.setParameter(2, "hi");
|
||||
sqlUpdate.setParameter(3, 1);
|
||||
@@ -73,9 +71,9 @@ public class TestSqlUpdateExceptions extends BaseTestCase {
|
||||
|
||||
UUID id = UUID.randomUUID();
|
||||
|
||||
try (Transaction transaction = Ebean.beginTransaction()) {
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
|
||||
SqlUpdate sqlUpdate = Ebean.createSqlUpdate(sql);
|
||||
SqlUpdate sqlUpdate = DB.sqlUpdate(sql);
|
||||
sqlUpdate.setParameter(1, id);
|
||||
sqlUpdate.setParameter(2, "hi in batch");
|
||||
sqlUpdate.setParameter(3, 1);
|
||||
@@ -95,9 +93,9 @@ public class TestSqlUpdateExceptions extends BaseTestCase {
|
||||
|
||||
UUID id = UUID.randomUUID();
|
||||
|
||||
try (Transaction transaction = Ebean.beginTransaction()) {
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
|
||||
SqlUpdate sqlUpdate = Ebean.createSqlUpdate(sql);
|
||||
SqlUpdate sqlUpdate = DB.sqlUpdate(sql);
|
||||
sqlUpdate.setParameter(1, id);
|
||||
sqlUpdate.setParameter(2, "hi in batch");
|
||||
sqlUpdate.setParameter(3, 1);
|
||||
@@ -107,8 +105,8 @@ public class TestSqlUpdateExceptions extends BaseTestCase {
|
||||
sqlUpdate.setParameter(2, "fail in batch");
|
||||
sqlUpdate.setParameter(3, 1);
|
||||
sqlUpdate.addBatch();
|
||||
int[] ints = sqlUpdate.executeBatch();
|
||||
|
||||
sqlUpdate.executeBatch();
|
||||
transaction.commit();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user