### Question:
Base { public static RowProcessor find(String query, Object ... params) { return new DB(DB.DEFAULT_NAME).find(query, params); } private  Base(); static DB open(); static DB open(String driver, String url, String user, String password); static DB open(String driver, String url, Properties props); static DB open(String jndiName); static DB open(String jndiName, Properties jndiProperties); static DB open(DataSource dataSource); static Connection connection(); static boolean hasConnection(); static void close(boolean suppressWarning); static void close(); static Long count(String table); static Long count(String table, String query, Object... params); static Object firstCell(String query, Object... params); static List<Map> findAll(String query, Object... params); static List firstColumn(String query, Object... params); static List<Map> findAll(String query); static RowProcessor find(String query, Object ... params); static RowProcessor find(RowProcessor.ResultSetType type, RowProcessor.ResultSetConcur concur, int fetchSize, String query, Object ... params); static void find(String sql, RowListener listener); static int exec(String query); static int exec(String query, Object ... params); static void openTransaction(); static void commitTransaction(); static void rollbackTransaction(); static PreparedStatement startBatch(String parametrizedStatement); static void addBatch(PreparedStatement ps, Object... parameters); static int[] executeBatch(PreparedStatement ps); static void closePreparedStatement(PreparedStatement ps); static void attach(Connection connection); static Connection detach(); static T withDb(String jndiName, Properties jndiProperties, Supplier<T> supplier); static T withDb(DataSource dataSource, Supplier<T> supplier); static T withDb(String jndiName, Supplier<T> supplier); static T withDb(String driver, String url, Properties properties, Supplier<T> supplier); static T withDb(String driver, String url, String user, String password, Supplier<T> supplier); static T withDb(Supplier<T> supplier);  }### Answer:
@Test public void testBaseFinder() { final List<Map> records = new ArrayList<>(); Base.find("select * from people order by id", new RowListenerAdapter() { @Override public void onNext(Map record) { records.add(record); } }); the(records.get(0).get("name")).shouldBeEqual("John"); the(records.get(3).get("name")).shouldBeEqual("Joe"); }
@Test public void testFindParametrized(){ Base.find("select * from people where id > ? and dob > ?", 1, getTimestamp(1935, 1, 1)).with(new RowListenerAdapter() { @Override public void onNext(Map<String, Object> row) { System.out.println(row); } }); }
@Test public void shouldReturnProperNulls(){ Person smith = Person.findFirst("last_name = ?", "Smith"); smith.set("graduation_date", null).saveIt(); List<Map> maps = new ArrayList<>(); Base.find("select * from people where last_name = ?", "Smith").with(new RowListenerAdapter() { @Override public void onNext(Map<String, Object> row) { Object object = row.get("GRADUATION_DATE"); the(object).shouldBeNull(); maps.add(new HashMap(row)); for (Map.Entry<String, Object> entry : row.entrySet()) { if(entry.getKey().equalsIgnoreCase("GRADUATION_DATE")){ the(entry.getValue()).shouldBeNull(); }else { the(entry.getValue()).shouldNotBeNull(); } } } }); for (Map result : maps) { Object object = result.get("GRADUATION_DATE"); the(object).shouldBeNull(); } }
@Test public void shouldUseResultSetParams(){ ArrayList<Map<String, Object>> list = new ArrayList<>(); Base.find(RowProcessor.ResultSetType.FORWARD_ONLY, RowProcessor.ResultSetConcur.READ_ONLY, 0, "select * from people").with(row -> { list.add(row); return true; }); the(list.size()).shouldEqual(4); }