Package io.ebean.test
Class LoggedSql
- java.lang.Object
-
- io.ebean.test.LoggedSql
-
public class LoggedSql extends Object
Provides access to the messages logged toio.ebean.SQL.This is here to allow easy access to the SQL that was executed during testing and if desired we can use that to perform asserts in tests.
// start capturing SQL log messages LoggedSql.start(); List<Customer> customers = Customer.find.where() .name.ilike("rob%") .findList(); assertNotNull(customers); // perform an insert new Product("ad", "asd").save() // return the captured SQL log messages // since LoggedSql.start() List<String> sql = LoggedSql.stop(); assertThat(sql).hasSize(2); assertThat(sql.get(0)).contains("from customer"); assertThat(sql.get(1)).contains("into product");
-
-
Constructor Summary
Constructors Constructor Description LoggedSql()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<String>collect()Collect and return the messages/sql that was captured since the call to start() or collect().static List<String>start()Start the capture of theio.ebean.SQLmessages.static List<String>stop()Stop the capture of theio.ebean.SQLmessages and return the messages/sql that was captured since the call to start().
-