mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Fixing squid:S1155 - Collection.isEmpty() should be used to test for emptiness
This commit is contained in:
@@ -30,6 +30,6 @@ public class PrimaryServerTest {
|
||||
public void testLoadProperties() throws Exception {
|
||||
|
||||
Properties properties = PrimaryServer.getProperties();
|
||||
assertTrue(properties.size() > 0);
|
||||
assertTrue(!properties.isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,6 @@ public class TestFetchId extends BaseTestCase {
|
||||
List<Object> idList = futureIds.get();
|
||||
Assert.assertTrue("same instance", partial == idList);
|
||||
|
||||
Assert.assertTrue("sz > 0", ids.size() > 0);
|
||||
Assert.assertTrue("sz > 0", !ids.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class TestInheritRef extends BaseTestCase {
|
||||
.setAutoTune(false)
|
||||
.findList();
|
||||
|
||||
Assert.assertTrue(list.size() > 0);
|
||||
Assert.assertTrue(!list.isEmpty());
|
||||
|
||||
Truck foundTruck = null;
|
||||
int found = 0;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TestLazyLoadInCache extends BaseTestCase {
|
||||
.orderBy().asc("id")
|
||||
.findMap();
|
||||
|
||||
assertTrue(map.size() > 0);
|
||||
assertTrue(!map.isEmpty());
|
||||
|
||||
Object id = map.keySet().iterator().next();
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class TestLimitQuery extends BaseTestCase {
|
||||
|
||||
List<Order> list = query.findList();
|
||||
|
||||
Assert.assertTrue("sz > 0", list.size() > 0);
|
||||
Assert.assertTrue("sz > 0", !list.isEmpty());
|
||||
|
||||
String sql = query.getGeneratedSql();
|
||||
boolean hasDetailsJoin = sql.contains("join o_order_detail");
|
||||
|
||||
@@ -76,7 +76,7 @@ public class TestM2MVanilla extends BaseTestCase {
|
||||
Query<MUser> rolesQuery = Ebean.find(MUser.class).where().in("roles", roleList).query();
|
||||
|
||||
List<MUser> userInRolesList = rolesQuery.findList();
|
||||
Assert.assertTrue(userInRolesList.size() > 0);
|
||||
Assert.assertTrue(!userInRolesList.isEmpty());
|
||||
|
||||
List<MUser> list = Ebean.find(MUser.class)
|
||||
.where().in("roles", roleList)
|
||||
|
||||
@@ -24,7 +24,7 @@ public class TestManyLazyLoad extends BaseTestCase {
|
||||
awaitL2Cache();
|
||||
|
||||
List<Order> list = Ebean.find(Order.class).order().asc("id").findList();
|
||||
assertTrue(list.size() + " > 0", list.size() > 0);
|
||||
assertTrue(list.size() + " > 0", !list.isEmpty());
|
||||
|
||||
// just use the first one
|
||||
Order order = list.get(0);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class TestOrderByAnnotation extends BaseTestCase {
|
||||
Customer customer = Ebean.find(Customer.class, custTest.getId());
|
||||
List<Order> orders = customer.getOrders();
|
||||
|
||||
Assert.assertTrue(orders.size() > 0);
|
||||
Assert.assertTrue(!orders.isEmpty());
|
||||
|
||||
|
||||
Query<Order> q1 = Ebean.find(Order.class)
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TestReadOnlyPropagation extends BaseTestCase {
|
||||
Assert.assertTrue(!bc.isPopulated());
|
||||
|
||||
bc.size();
|
||||
Assert.assertTrue(bc.size() > 0);
|
||||
Assert.assertTrue(!bc.isEmpty());
|
||||
Assert.assertTrue(bc.isReadOnly());
|
||||
Assert.assertTrue(bc.isPopulated());
|
||||
try {
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TestSharedInstancePropagation extends BaseTestCase {
|
||||
bc.size();
|
||||
|
||||
assertTrue(bc.isPopulated());
|
||||
assertTrue(bc.size() > 0);
|
||||
assertTrue(!bc.isEmpty());
|
||||
OrderDetail detail = details.get(0);
|
||||
|
||||
assertTrue(Ebean.getBeanState(detail).isReadOnly());
|
||||
|
||||
@@ -23,7 +23,7 @@ public class TestWhereAnnotation extends BaseTestCase {
|
||||
Customer customer = Ebean.find(Customer.class, custTest.getId());
|
||||
List<Order> orders = customer.getOrders();
|
||||
|
||||
Assert.assertTrue(orders.size() > 0);
|
||||
Assert.assertTrue(!orders.isEmpty());
|
||||
|
||||
Query<Customer> q1 = Ebean.find(Customer.class).setUseCache(false).fetch("orders").where()
|
||||
.idEq(1).query();
|
||||
|
||||
@@ -48,7 +48,7 @@ public class TestBasicLazy extends BaseTestCase {
|
||||
// some contacts
|
||||
Customer c = Ebean.find(Customer.class).setId(1).findUnique();
|
||||
Assert.assertNotNull(c.getContacts());
|
||||
Assert.assertTrue("no contacts on test customer 1", c.getContacts().size() > 0);
|
||||
Assert.assertTrue("no contacts on test customer 1", !c.getContacts().isEmpty());
|
||||
|
||||
// start transaction so we have a "long running" persistence context
|
||||
Transaction tx = Ebean.beginTransaction();
|
||||
@@ -56,7 +56,7 @@ public class TestBasicLazy extends BaseTestCase {
|
||||
List<Order> order = Ebean.find(Order.class).where(Expr.eq("customer.id", 1)).findList();
|
||||
|
||||
Assert.assertNotNull(order);
|
||||
Assert.assertTrue(order.size() > 0);
|
||||
Assert.assertTrue(!order.isEmpty());
|
||||
|
||||
Customer customer = order.get(0).getCustomer();
|
||||
Assert.assertNotNull(customer);
|
||||
@@ -66,7 +66,7 @@ public class TestBasicLazy extends BaseTestCase {
|
||||
List<Contact> contacts = customer.getContacts();
|
||||
|
||||
Assert.assertNotNull(contacts);
|
||||
Assert.assertTrue("contacts not lazily fetched", contacts.size() > 0);
|
||||
Assert.assertTrue("contacts not lazily fetched", !contacts.isEmpty());
|
||||
} finally {
|
||||
tx.commit();
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public class TestBasicLazy extends BaseTestCase {
|
||||
MyTestDataSourcePoolListener.SLEEP_AFTER_BORROW = 0;
|
||||
}
|
||||
|
||||
if (exceptions.size() > 0) {
|
||||
if (!exceptions.isEmpty()) {
|
||||
System.err.println("Seen Exceptions:");
|
||||
for (Throwable exception : exceptions) {
|
||||
exception.printStackTrace();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TestLazyJoin2 extends BaseTestCase {
|
||||
Order o0 = l0.get(0);
|
||||
Customer c0 = o0.getCustomer();
|
||||
List<Contact> contacts = c0.getContacts();
|
||||
Assert.assertTrue(contacts.size() > 0);
|
||||
Assert.assertTrue(!contacts.isEmpty());
|
||||
|
||||
// query 1) find order (status, shipDate)
|
||||
// query 2) find orderDetail (quantity, price) join product (sku, name)
|
||||
|
||||
@@ -60,7 +60,7 @@ public class TestQueryJoin extends BaseTestCase {
|
||||
System.out.println(billingAddress);
|
||||
billingAddress.getLine1();
|
||||
|
||||
Assert.assertTrue(list.size() > 0);
|
||||
Assert.assertTrue(!list.isEmpty());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class TestSecondaryQueries extends BaseTestCase {
|
||||
spiQuery.setLogSecondaryQuery(true);
|
||||
|
||||
List<Order> list = query.findList();
|
||||
Assert.assertTrue(list.size() > 0);
|
||||
Assert.assertTrue(!list.isEmpty());
|
||||
for (Order order : list) {
|
||||
order.getCustomer().getStatus();
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class TestQueryCache extends BaseTestCase {
|
||||
BeanCollection<Customer> bc = (BeanCollection<Customer>) list;
|
||||
Assert.assertFalse(bc.isReadOnly());
|
||||
Assert.assertFalse(bc.isEmpty());
|
||||
Assert.assertTrue(list.size() > 0);
|
||||
Assert.assertTrue(!list.isEmpty());
|
||||
Assert.assertTrue(Ebean.getBeanState(list.get(0)).isReadOnly());
|
||||
|
||||
List<Customer> list2 = Ebean.find(Customer.class).setUseQueryCache(true).setReadOnly(true).where()
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TestQueryCacheCountry extends BaseTestCase {
|
||||
.findList();
|
||||
|
||||
assertEquals(1, queryCache.getStatistics(false).getSize());
|
||||
assertTrue(countryList0.size() > 0);
|
||||
assertTrue(!countryList0.isEmpty());
|
||||
|
||||
List<Country> countryList1 = Ebean.find(Country.class)
|
||||
.setUseQueryCache(true)
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TestInheritAbstract extends TestCase {
|
||||
.findList();
|
||||
|
||||
Assert.assertNotNull(list2);
|
||||
Assert.assertTrue(list2.size() > 0);
|
||||
Assert.assertTrue(!list2.isEmpty());
|
||||
|
||||
for (AbstractBar abstractBar : list2) {
|
||||
Foo foo = abstractBar.getFoo();
|
||||
|
||||
@@ -24,7 +24,7 @@ public class TestLimitQuery extends BaseTestCase {
|
||||
.findList();
|
||||
|
||||
// should at least find the "Cust NoAddress" customer
|
||||
Assert.assertTrue(customers.size() > 0);
|
||||
Assert.assertTrue(!customers.isEmpty());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class TestQueryFetchManyTwoDeep extends BaseTestCase {
|
||||
spiQuery.setLogSecondaryQuery(true);
|
||||
|
||||
List<Customer> list = query.findList();
|
||||
Assert.assertTrue("has rows", list.size() > 0);
|
||||
Assert.assertTrue("has rows", !list.isEmpty());
|
||||
Assert.assertTrue(query.getGeneratedSql().contains("from o_customer t0 "));
|
||||
Assert.assertTrue(query.getGeneratedSql().contains("left outer join o_order t1 on t1.kcustomer_id = t0.id"));
|
||||
Assert.assertTrue(query.getGeneratedSql().contains("left outer join o_customer t2 on t2.id = t1.kcustomer_id"));
|
||||
@@ -71,7 +71,7 @@ public class TestQueryFetchManyTwoDeep extends BaseTestCase {
|
||||
.fetch("order.details");
|
||||
|
||||
List<OrderShipment> shipList = shipQuery.findList();
|
||||
Assert.assertTrue("has rows", shipList.size() > 0);
|
||||
Assert.assertTrue("has rows", !shipList.isEmpty());
|
||||
|
||||
String generatedSql = shipQuery.getGeneratedSql();
|
||||
|
||||
@@ -112,7 +112,7 @@ public class TestQueryFetchManyTwoDeep extends BaseTestCase {
|
||||
.fetch("customer.orders");
|
||||
|
||||
List<Contact> shipList = query.findList();
|
||||
Assert.assertTrue("has rows", shipList.size() > 0);
|
||||
Assert.assertTrue("has rows", !shipList.isEmpty());
|
||||
|
||||
String generatedSql = query.getGeneratedSql();
|
||||
|
||||
@@ -144,7 +144,7 @@ public class TestQueryFetchManyTwoDeep extends BaseTestCase {
|
||||
.query();
|
||||
|
||||
List<Contact> list = query.findList();
|
||||
Assert.assertTrue("has rows", list.size() > 0);
|
||||
Assert.assertTrue("has rows", !list.isEmpty());
|
||||
|
||||
String generatedSql = query.getGeneratedSql();
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class TestQueryMultiManyOrder extends BaseTestCase {
|
||||
List<Order> list = q.findList();
|
||||
String sql = q.getGeneratedSql();
|
||||
|
||||
Assert.assertTrue(list.size() > 0);
|
||||
Assert.assertTrue(!list.isEmpty());
|
||||
Assert.assertTrue(sql.contains("join o_customer "));
|
||||
|
||||
Assert.assertFalse(sql.contains("left outer join contact "));
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TestQueryPlanCacheRowCount extends BaseTestCase {
|
||||
Assert.assertEquals(rc0, list1.size());
|
||||
|
||||
int idGt = 5;
|
||||
if (ids1.size() > 0) {
|
||||
if (!ids1.isEmpty()) {
|
||||
Object id = ids.get(0);
|
||||
idGt = Integer.valueOf("" + id);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class TestQueryJoinManyNonRoot extends BaseTestCase {
|
||||
List<Order> list = q.findList();
|
||||
String sql = q.getGeneratedSql();
|
||||
|
||||
assertTrue(list.size() > 0);
|
||||
assertTrue(!list.isEmpty());
|
||||
assertTrue(sql.contains("join o_customer t1 on t1.id "));
|
||||
assertTrue(sql.contains("left outer join contact t2 on"));
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TestQueryJoinManyNonRoot extends BaseTestCase {
|
||||
List<Order> list = q.findList();
|
||||
String sql = q.getGeneratedSql();
|
||||
|
||||
assertTrue(list.size() > 0);
|
||||
assertTrue(!list.isEmpty());
|
||||
assertTrue(sql.contains("join o_customer t1 on t1.id "));
|
||||
assertTrue(sql.contains("left outer join o_order_detail "));
|
||||
assertTrue(sql.contains("left outer join o_product "));
|
||||
@@ -105,7 +105,7 @@ public class TestQueryJoinManyNonRoot extends BaseTestCase {
|
||||
order.getCustomer().getContacts().size();
|
||||
}
|
||||
|
||||
assertTrue(list.size() > 0);
|
||||
assertTrue(!list.isEmpty());
|
||||
assertTrue(sql.contains("join o_customer t1 on t1.id "));
|
||||
assertTrue(sql.contains("left outer join contact "));
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TestQueryJoinQueryNonRoot extends BaseTestCase {
|
||||
.where().lt("id", 3).findList();
|
||||
|
||||
Assert.assertNotNull(list);
|
||||
Assert.assertTrue(list.size() > 0);
|
||||
Assert.assertTrue(!list.isEmpty());
|
||||
|
||||
for (Order order : list) {
|
||||
List<Contact> contacts = order.getCustomer().getContacts();
|
||||
|
||||
Reference in New Issue
Block a user