Fix warnings 2 (#1130)

* FIX: warnings (add generics, overrides, fix imports) - should be no effecive code change

* replaced deprecated methods by default methods

* FIX: more compiler warnings

* FIX more warnings - no code changes

* FIX: deprecated call to JsonParseException

* Remove unused code, check unused variables
This commit is contained in:
Roland Praml
2017-09-14 00:32:48 +12:00
committed by Rob Bygrave
parent ac6708e0d0
commit b66f18bfd6
17 changed files with 30 additions and 79 deletions
@@ -8,8 +8,6 @@ import io.ebean.Transaction;
import io.ebean.migration.ddl.DdlRunner;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.assertj.core.api.Assertions.assertThat;
@@ -24,9 +22,6 @@ import javax.persistence.PersistenceException;
public class DbMigrationTest extends BaseTestCase {
private static final Logger logger = LoggerFactory.getLogger(DbMigrationTest.class);
private int runScript(boolean expectErrors, String scriptName) throws IOException {
try (InputStream stream = getClass().getResourceAsStream("/dbmigration/migrationtest/" + server().getPluginApi().getDatabasePlatform().getName()+"/" + scriptName);
java.util.Scanner s = new java.util.Scanner(stream)) {
@@ -54,11 +54,11 @@ public class DocStoreBeanBaseAdapterTest extends BaseTestCase {
}
@Override
public void insert(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext txn) throws IOException {
public void insert(Object idValue, PersistRequestBean<T> persistRequest, DocStoreUpdateContext txn) throws IOException {
}
@Override
public void update(Object idValue, PersistRequestBean persistRequest, DocStoreUpdateContext txn) throws IOException {
public void update(Object idValue, PersistRequestBean<T> persistRequest, DocStoreUpdateContext txn) throws IOException {
}
@Override
@@ -53,8 +53,6 @@ public class TestEncrypt extends BaseTestCase {
Ebean.save(e);
Date earlyDob = new Date(System.currentTimeMillis() - 500000);
SqlQuery q = Ebean.createSqlQuery("select * from e_basicenc where id = :id");
q.setParameter("id", e.getId());
@@ -7,6 +7,7 @@ import io.ebean.Transaction;
import org.junit.Test;
import org.tests.model.basic.L2CachedLazyDirtFlagResetBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -32,6 +33,7 @@ public class TestL2DirtyFlagOnLazyLoad extends BaseTestCase {
Transaction tx1 = Ebean.beginTransaction();
// load (and dont touch any related entity)
L2CachedLazyDirtFlagResetBean bean1 = Ebean.find(L2CachedLazyDirtFlagResetBean.class, bean.getId());
assertThat(bean1).isNotNull();
tx1.commit();
@@ -13,6 +13,7 @@ import org.junit.Test;
import java.io.IOException;
import java.util.Currency;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.*;
public class TestDPersonEl {
@@ -21,7 +22,8 @@ public class TestDPersonEl {
public void test() throws IOException {
Currency NZD = Currency.getInstance("NZD");
assertThat(NZD).isNotNull();
DPerson p = new DPerson();
p.setFirstName("first");
p.setLastName("last");
@@ -1,44 +0,0 @@
package org.tests.lib;
import io.ebean.Ebean;
import io.ebean.EbeanServer;
import io.ebean.Transaction;
import io.ebean.Platform;
import io.ebeaninternal.api.SpiEbeanServer;
import junit.framework.TestCase;
import junit.framework.TestResult;
/**
* The base class for all Ebean test to get access to the Ebean server and do
* some cleanup stuff after a test has run
*/
public abstract class EbeanTestCase extends TestCase {
@Override
public void run(TestResult testResult) {
try {
super.run(testResult);
} finally {
Transaction tx = getServer().currentTransaction();
if (tx != null && tx.isActive()) {
// transaction left running after the test, rollback it to make
// the environment ready for the next test
tx.rollback();
}
}
}
public EbeanServer getServer() {
return Ebean.getServer(null);
}
/**
* MS SQL Server does not allow setting explicit values on identity columns
* so tests that do this need to be skipped for SQL Server.
*/
public boolean isMsSqlServer() {
SpiEbeanServer spi = (SpiEbeanServer) Ebean.getDefaultServer();
return spi.getDatabasePlatform().getPlatform() == Platform.SQLSERVER;
}
}
@@ -12,6 +12,8 @@ import org.tests.model.basic.Order;
import org.tests.model.basic.ResetBasicData;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
public class TestAutofetchTuneWithJoin extends BaseTestCase {
@@ -51,7 +53,7 @@ public class TestAutofetchTuneWithJoin extends BaseTestCase {
SpiQuery<?> sq = (SpiQuery<?>) q;
ObjectGraphNode parentNode = sq.getParentNode();
ObjectGraphOrigin origin = parentNode.getOriginQueryPoint();
assertThat(origin).isNotNull();
// MetaAutoFetchStatistic metaAutoFetchStatistic =
// ((DefaultOrmQuery<?>)q).getMetaAutoFetchStatistic();
// if (metaAutoFetchStatistic != null) {
@@ -10,6 +10,8 @@ import org.tests.model.embedded.EEmbDatePeriod;
import org.tests.model.embedded.EEmbInner;
import org.tests.model.embedded.EEmbOuter;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Date;
import java.util.List;
@@ -40,6 +42,8 @@ public class TestFilteringByEmbeddedInJoinedTable extends BaseTestCase {
EEmbOuter outer1 = createOuter("outer1", new Date(11111), new Date(12222));
// Unused outer2 just to populate the DB
EEmbOuter outer2 = createOuter("outer2", new Date(21111), new Date(22222));
assertThat(outer2).isNotNull();
EEmbOuter outer3 = createOuter("outer3", new Date(31111), new Date(32222));
@@ -334,6 +334,7 @@ public class TestQuerySingleAttribute extends BaseTestCase {
.orderBy().desc("customer.billingAddress.id");
List<Integer> ids = query.findSingleAttributeList();
assertThat(ids).isNotEmpty();
assertThat(sqlOf(query)).contains("select distinct t1.billing_address_id from contact t0 "
+ "join o_customer t1 on t1.id = t0.customer_id " // two spaces!
@@ -354,6 +355,7 @@ public class TestQuerySingleAttribute extends BaseTestCase {
.orderBy().desc("customer.billingAddress.id");
List<Short> ids = query.findSingleAttributeList();
assertThat(ids).isNotEmpty();
assertThat(sqlOf(query)).contains("select distinct t1.billing_address_id from contact t0 "
+ "join o_customer t1 on t1.id = t0.customer_id "
@@ -374,6 +376,7 @@ public class TestQuerySingleAttribute extends BaseTestCase {
.orderBy().desc("customer.billingAddress.id");
List<Integer> ids = query.findSingleAttributeList();
assertThat(ids).isNotEmpty();
assertThat(sqlOf(query)).contains("select distinct t1.billing_address_id from contact t0 "
+ "join o_customer t1 on t1.id = t0.customer_id "
@@ -394,6 +397,7 @@ public class TestQuerySingleAttribute extends BaseTestCase {
.orderBy().desc("customer.billingAddress.id");
List<Short> ids = query.findSingleAttributeList();
assertThat(ids).isNotEmpty();
assertThat(sqlOf(query)).contains("select distinct t1.billing_address_id from contact t0 "
+ "join o_customer t1 on t1.id = t0.customer_id "
@@ -7,6 +7,8 @@ import io.ebean.text.json.JsonContext;
import org.junit.Assert;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -37,7 +39,8 @@ public class TestJsonSimple extends BaseTestCase {
String jsonText = sb.toString();
Object el = EJson.parse(jsonText);
assertThat(el).isNotNull();
Map<String, Object> e2 = EJson.parseObject("{\"a\":12, \"name\":{\"first\":\"rob\", \"last\":\"byg\"}}");
Assert.assertEquals(12L, e2.get("a"));
@@ -70,6 +70,7 @@ public class TimezoneTests {
TimeZone.setDefault(TimeZone.getTimeZone(zone));
}
@SuppressWarnings("unused")
private void insert(String zone) throws SQLException {
String insert = "insert into tztest (zone, ts, tstz, ts1, tstz1) values (?,?,?,?,?)";
@@ -33,9 +33,6 @@ public class TestNested extends BaseTestCase {
private void willFail() {
Ebean.executeCall(() -> {
if (false) {
return 123;
}
throw new RuntimeException("test runnable rollback");
});
}
@@ -7,6 +7,8 @@ import org.tests.basic.encrypt.BasicEncryptKey;
import org.junit.Assert;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import java.sql.Timestamp;
public class TestSimpleEncryptor extends BaseTestCase {
@@ -23,6 +25,8 @@ public class TestSimpleEncryptor extends BaseTestCase {
byte[] ecData = e.encrypt(data, key);
byte[] deData = e.decrypt(ecData, key);
assertThat(data).containsExactly(deData);
Timestamp t = new Timestamp(System.currentTimeMillis());
byte[] ecTimestamp = e.encryptString(t.toString(), key);