Binder { static void bind(SQLiteStmt stmt, int index, Object value) { if (value == null) { stmt.bindNull(index); } else if (value instanceof Integer || value instanceof Long || value instanceof Short) { stmt.bindLong(index, ((Number) value).longValue()); } else if (value instanceof Number) { stmt.bindDouble(index, ((Number) value).doubleValue()); } else if (value instanceof String) { stmt.bindString(index, (String) value); } else if (value instanceof byte[]) { stmt.bindBlob(index, (byte[]) value); } else { throw new AlchemyException("Unsupported SQLite type"); } }    }
@Test public void bindShort() throws Exception { Binder.bind(mStmt, 1, (short) 10); Mockito.verify(mStmt).bindLong(1, 10L); }
@Test public void bindInteger() throws Exception { Binder.bind(mStmt, 2, 100); Mockito.verify(mStmt).bindLong(2, 100L); }
@Test public void bindLong() throws Exception { Binder.bind(mStmt, 3, 1000L); Mockito.verify(mStmt).bindLong(3, 1000L); }
@Test public void bindFloat() throws Exception { Binder.bind(mStmt, 4, 1.23f); Mockito.verify(mStmt).bindDouble(4, 1.23f); }
@Test public void bindDouble() throws Exception { Binder.bind(mStmt, 5, 4.56); Mockito.verify(mStmt).bindDouble(5, 4.56); }
@Test public void bindString() throws Exception { Binder.bind(mStmt, 6, "test"); Mockito.verify(mStmt).bindString(6, "test"); }
@Test public void bindBlob() throws Exception { Binder.bind(mStmt, 7, new byte[]{1, 2, 3}); Mockito.verify(mStmt).bindBlob(7, new byte[]{1, 2, 3}); }
@Test(expected = AlchemyException.class) public void unexpectedType() throws Exception { Binder.bind(mStmt, 8, new Date()); }