src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
BaseSqliteDatabaseType extends BaseDatabaseType { @Override public FieldConverter getFieldConverter(DataPersister dataPersister, FieldType fieldType) { switch (dataPersister.getSqlType()) { case BOOLEAN : return booleanConverter; case BIG_DECIMAL : return BigDecimalStringType.getSingleton(); default : return super.getF...
@Test public void testGetFieldConverter() throws Exception { OurSqliteDatabaseType dbType = new OurSqliteDatabaseType(); assertEquals(Byte.valueOf((byte) 1), dbType.getFieldConverter(DataType.BOOLEAN.getDataPersister(), null) .parseDefaultString(null, "true")); } @Test public void testDefaultFieldConverter() { OurSqlit...
DatabaseFieldConfig { public static DatabaseFieldConfig fromField(DatabaseType databaseType, String tableName, Field field) throws SQLException { DatabaseField databaseField = field.getAnnotation(DatabaseField.class); if (databaseField != null) { if (databaseField.persisted()) { return fromDatabaseField(databaseType, t...
@Test(expected = IllegalArgumentException.class) public void testUnknownEnumVal() throws Exception { Field[] fields = BadUnknownVal.class.getDeclaredFields(); assertTrue(fields.length >= 1); DatabaseFieldConfig.fromField(databaseType, "foo", fields[0]); } @Test public void testNotPersisted() throws Exception { Database...
FieldType { public FieldType(ConnectionSource connectionSource, String tableName, Field field, DatabaseFieldConfig fieldConfig, Class<?> parentClass) throws SQLException { this.connectionSource = connectionSource; this.tableName = tableName; DatabaseType databaseType = connectionSource.getDatabaseType(); this.field = f...
@Test public void testFieldType() throws Exception { Field[] fields = LocalFoo.class.getDeclaredFields(); assertTrue(fields.length >= 4); Field nameField = fields[0]; Field rankField = fields[1]; Field serialField = fields[2]; Field intLongField = fields[3]; FieldType fieldType = FieldType.createFieldType(connectionSou...
FieldType { public static FieldType createFieldType(ConnectionSource connectionSource, String tableName, Field field, Class<?> parentClass) throws SQLException { DatabaseType databaseType = connectionSource.getDatabaseType(); DatabaseFieldConfig fieldConfig = DatabaseFieldConfig.fromField(databaseType, tableName, field...
@Test(expected = IllegalArgumentException.class) public void testUnknownFieldType() throws Exception { Field[] fields = UnknownFieldType.class.getDeclaredFields(); assertTrue(fields.length >= 1); FieldType.createFieldType(connectionSource, UnknownFieldType.class.getSimpleName(), fields[0], UnknownFieldType.class); } @T...
FieldType { @Override public boolean equals(Object arg) { if (arg == null || arg.getClass() != this.getClass()) { return false; } FieldType other = (FieldType) arg; return field.equals(other.field) && (parentClass == null ? other.parentClass == null : parentClass.equals(other.parentClass)); } FieldType(ConnectionSource...
@Test public void testEquals() throws Exception { Field field1 = DefaultTypes.class.getDeclaredField("booleanField"); FieldType fieldType1 = FieldType.createFieldType(connectionSource, DefaultTypes.class.getSimpleName(), field1, DefaultTypes.class); FieldType fieldType2 = FieldType.createFieldType(connectionSource, Def...
DatabaseFieldConfigLoader { public static DatabaseFieldConfig fromReader(BufferedReader reader) throws SQLException { DatabaseFieldConfig config = new DatabaseFieldConfig(); boolean anything = false; while (true) { String line; try { line = reader.readLine(); } catch (IOException e) { throw SqlExceptionUtil.create("Cou...
@Test public void testEmptyFile() throws Exception { String value = ""; assertNull(DatabaseFieldConfigLoader.fromReader(new BufferedReader(new StringReader(value)))); } @Test(expected = SQLException.class) public void testBadLine() throws Exception { String value = "not a good line"; DatabaseFieldConfigLoader.fromReade...
DateLongType extends BaseDateType { @Override public Object parseDefaultString(FieldType fieldType, String defaultStr) throws SQLException { try { return Long.parseLong(defaultStr); } catch (NumberFormatException e) { throw SqlExceptionUtil.create("Problems with field " + fieldType + " parsing default date-long value: ...
@Test(expected = SQLException.class) public void testDateLongParseInvalid() throws Exception { FieldType fieldType = FieldType.createFieldType(connectionSource, TABLE_NAME, LocalDateLong.class.getDeclaredField(DATE_COLUMN), LocalDateLong.class); DataType.DATE_LONG.getDataPersister().parseDefaultString(fieldType, "not v...
SerializableType extends BaseDataType { @Override public Object parseDefaultString(FieldType fieldType, String defaultStr) throws SQLException { throw new SQLException("Default values for serializable types are not supported"); } private SerializableType(); protected SerializableType(SqlType sqlType, Class<?>[] class...
@Test(expected = SQLException.class) public void testSerializableParseDefault() throws Exception { DataType.SERIALIZABLE.getDataPersister().parseDefaultString(null, null); }
DateTimeType extends BaseDataType { @Override public Object javaToSqlArg(FieldType fieldType, Object javaObject) throws SQLException { return extractMillis(javaObject); } private DateTimeType(); protected DateTimeType(SqlType sqlType, Class<?>[] classes); static DateTimeType getSingleton(); @Override String[] getAsso...
@Test(expected = SQLException.class) public void testJavaToSqlArg() throws Exception { DateTimeType.getSingleton().javaToSqlArg(null, new Object()); }
DateTimeType extends BaseDataType { @Override public Object parseDefaultString(FieldType fieldType, String defaultStr) throws SQLException { try { return Long.parseLong(defaultStr); } catch (NumberFormatException e) { throw SqlExceptionUtil.create("Problems with field " + fieldType + " parsing default DateTime value: "...
@Test public void testParseDefaultString() throws SQLException { Long value = 423424234234L; assertEquals(value, DateTimeType.getSingleton().parseDefaultString(null, value.toString())); }
DateTimeType extends BaseDataType { @Override public Object resultToSqlArg(FieldType fieldType, DatabaseResults results, int columnPos) throws SQLException { return results.getLong(columnPos); } private DateTimeType(); protected DateTimeType(SqlType sqlType, Class<?>[] classes); static DateTimeType getSingleton(); @O...
@Test(expected = SQLException.class) public void testResultToSqlArg() throws Exception { DatabaseResults results = createMock(DatabaseResults.class); int col = 21; long value = 2094234324L; expect(results.getLong(col)).andReturn(value); replay(results); DateTimeType.getSingleton().resultToJava(null, results, col); }
DateType extends BaseDateType { @Override public Object parseDefaultString(FieldType fieldType, String defaultStr) throws SQLException { DateStringFormatConfig dateFormatConfig = convertDateStringConfig(fieldType, getDefaultDateFormatConfig()); try { return new Timestamp(parseDateString(dateFormatConfig, defaultStr).ge...
@Test(expected = SQLException.class) public void testDateParseInvalid() throws Exception { FieldType fieldType = FieldType.createFieldType(connectionSource, TABLE_NAME, LocalDate.class.getDeclaredField(DATE_COLUMN), LocalDate.class); DataType.DATE.getDataPersister().parseDefaultString(fieldType, "not valid date string"...
BaseDaoImpl implements Dao<T, ID> { public void initialize() throws SQLException { if (initialized) { return; } if (connectionSource == null) { throw new IllegalStateException("connectionSource was never set on " + getClass().getSimpleName()); } databaseType = connectionSource.getDatabaseType(); if (databaseType == nul...
@Test public void testDoubleInitialize() throws Exception { BaseDaoImpl<Foo, Integer> dao = new BaseDaoImpl<Foo, Integer>(connectionSource, Foo.class) { }; dao.initialize(); dao.initialize(); } @Test(expected = IllegalStateException.class) public void testInitNoConnectionSource() throws Exception { BaseDaoImpl<Foo, Int...
BaseDaoImpl implements Dao<T, ID> { @Override public int create(T data) throws SQLException { checkForInitialized(); if (data == null) { return 0; } if (data instanceof BaseDaoEnabled) { @SuppressWarnings("unchecked") BaseDaoEnabled<T, ID> daoEnabled = (BaseDaoEnabled<T, ID>) data; daoEnabled.setDao(this); } DatabaseCo...
@Test public void testCreate() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo = new Foo(); int equal = 21313; foo.equal = equal; assertEquals(1, dao.create(foo)); Foo result = dao.queryForId(foo.id); assertNotNull(result); assertEquals(equal, result.equal); }
BaseDaoImpl implements Dao<T, ID> { @Override public int update(T data) throws SQLException { checkForInitialized(); if (data == null) { return 0; } if (data instanceof BaseDaoEnabled) { @SuppressWarnings("unchecked") BaseDaoEnabled<T, ID> daoEnabled = (BaseDaoEnabled<T, ID>) data; daoEnabled.setDao(this); } DatabaseCo...
@Test public void testUpdate() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo = new Foo(); assertEquals(1, dao.create(foo)); foo.equal = 1; assertEquals(1, dao.update(foo)); }
BaseDaoImpl implements Dao<T, ID> { @Override public int updateId(T data, ID newId) throws SQLException { checkForInitialized(); if (data == null) { return 0; } else { DatabaseConnection connection = connectionSource.getReadWriteConnection(tableInfo.getTableName()); try { return statementExecutor.updateId(connection, d...
@Test public void testUpdateId() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo = new Foo(); assertEquals(1, dao.create(foo)); int id = foo.id; assertNotNull(dao.queryForId(id)); assertNull(dao.queryForId(id + 1)); assertEquals(1, dao.updateId(foo, id + 1)); assertNull(dao.queryForId(id)...
BaseDaoImpl implements Dao<T, ID> { @Override public int delete(T data) throws SQLException { checkForInitialized(); if (data == null) { return 0; } else { DatabaseConnection connection = connectionSource.getReadWriteConnection(tableInfo.getTableName()); try { return statementExecutor.delete(connection, data, objectCac...
@Test public void testDelete() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo = new Foo(); assertEquals(1, dao.create(foo)); assertNotNull(dao.queryForId(foo.id)); assertEquals(1, dao.delete(foo)); assertNull(dao.queryForId(foo.id)); assertEquals(0, dao.queryForAll().size()); }
BaseDaoImpl implements Dao<T, ID> { @Override public int deleteById(ID id) throws SQLException { checkForInitialized(); if (id == null) { return 0; } else { DatabaseConnection connection = connectionSource.getReadWriteConnection(tableInfo.getTableName()); try { return statementExecutor.deleteById(connection, id, object...
@Test public void testDeleteById() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo = new Foo(); assertEquals(1, dao.create(foo)); assertNotNull(dao.queryForId(foo.id)); assertEquals(1, dao.deleteById(foo.id)); assertNull(dao.queryForId(foo.id)); assertEquals(0, dao.queryForAll().size()); ...
BaseDaoImpl implements Dao<T, ID> { @Override public int deleteIds(Collection<ID> ids) throws SQLException { checkForInitialized(); if (ids == null || ids.isEmpty()) { return 0; } else { DatabaseConnection connection = connectionSource.getReadWriteConnection(tableInfo.getTableName()); try { return statementExecutor.del...
@Test public void testDeleteIds() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo1 = new Foo(); assertEquals(1, dao.create(foo1)); Foo foo2 = new Foo(); assertEquals(1, dao.create(foo2)); assertNotNull(dao.queryForId(foo1.id)); assertNotNull(dao.queryForId(foo2.id)); List<Integer> ids = n...
BaseDaoImpl implements Dao<T, ID> { @Override public int refresh(T data) throws SQLException { checkForInitialized(); if (data == null) { return 0; } if (data instanceof BaseDaoEnabled) { @SuppressWarnings("unchecked") BaseDaoEnabled<T, ID> daoEnabled = (BaseDaoEnabled<T, ID>) data; daoEnabled.setDao(this); } DatabaseC...
@Test public void testRefresh() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo = new Foo(); int equal1 = 11312331; foo.equal = equal1; assertEquals(1, dao.create(foo)); int equal2 = 312312; assertNotNull(dao.queryForId(foo.id)); UpdateBuilder<Foo, Integer> updateBuilder = dao.updateBuild...
BindingParameter { public String getFullName() { return Strings.getFullName(parameterName, propertyPath); } BindingParameter(String parameterName, String propertyPath, JdbcType jdbcType); static BindingParameter create(String parameterName, String propertyPath, JdbcType jdbcType); BindingParameter rightShift(); String ...
@Test public void testGetFullName() throws Exception { BindingParameter bp = BindingParameter.create("a", "b", null); assertThat(bp.getFullName(), equalTo(":a.b")); bp = BindingParameter.create("a", "", null); assertThat(bp.getFullName(), equalTo(":a")); }
BaseDaoImpl implements Dao<T, ID> { @Override public T queryForId(ID id) throws SQLException { checkForInitialized(); DatabaseConnection connection = connectionSource.getReadOnlyConnection(tableInfo.getTableName()); try { return statementExecutor.queryForId(connection, id, objectCache); } finally { connectionSource.rel...
@Test(expected = IllegalStateException.class) public void testQueryForIdNoInit() throws Exception { BaseDaoImpl<Foo, Integer> dao = new BaseDaoImpl<Foo, Integer>(Foo.class) { }; dao.queryForId(1); }
BaseDaoImpl implements Dao<T, ID> { @Override public T queryForFirst(PreparedQuery<T> preparedQuery) throws SQLException { checkForInitialized(); DatabaseConnection connection = connectionSource.getReadOnlyConnection(tableInfo.getTableName()); try { return statementExecutor.queryForFirst(connection, preparedQuery, obje...
@Test public void testQueryForFirst() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo1 = new Foo(); assertEquals(1, dao.create(foo1)); Foo foo2 = new Foo(); assertEquals(1, dao.create(foo2)); assertNotNull(dao.queryForId(foo1.id)); assertNotNull(dao.queryForId(foo2.id)); assertEquals(2, d...
BaseDaoImpl implements Dao<T, ID> { @Override public QueryBuilder<T, ID> queryBuilder() { checkForInitialized(); return new QueryBuilder<T, ID>(databaseType, tableInfo, this); } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protected BaseDaoI...
@Test(expected = IllegalStateException.class) public void testStatementBuilderNoInit() throws Exception { BaseDaoImpl<Foo, Integer> dao = new BaseDaoImpl<Foo, Integer>(Foo.class) { }; dao.queryBuilder(); }
BaseDaoImpl implements Dao<T, ID> { @Override public List<T> query(PreparedQuery<T> preparedQuery) throws SQLException { checkForInitialized(); return statementExecutor.query(connectionSource, preparedQuery, objectCache); } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSo...
@Test(expected = IllegalStateException.class) public void testQueryForPreparedNoInit() throws Exception { BaseDaoImpl<Foo, Integer> dao = new BaseDaoImpl<Foo, Integer>(Foo.class) { }; dao.query((PreparedQuery<Foo>) null); }
BaseDaoImpl implements Dao<T, ID> { @Override public String objectToString(T data) { checkForInitialized(); return tableInfo.objectToString(data); } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connecti...
@Test public void testObjectToString() throws Exception { BaseDaoImpl<Foo, Integer> dao = new BaseDaoImpl<Foo, Integer>(connectionSource, Foo.class) { }; dao.initialize(); Foo foo = new Foo(); String objStr = dao.objectToString(foo); assertTrue(objStr.contains("id=" + foo.id)); }
BaseDaoImpl implements Dao<T, ID> { @Override public boolean objectsEqual(T data1, T data2) throws SQLException { checkForInitialized(); for (FieldType fieldType : tableInfo.getFieldTypes()) { Object fieldObj1 = fieldType.extractJavaFieldValue(data1); Object fieldObj2 = fieldType.extractJavaFieldValue(data2); if (!fiel...
@Test public void testObjectsEqual() throws Exception { BaseDaoImpl<Foo, Integer> dao = new BaseDaoImpl<Foo, Integer>(connectionSource, Foo.class) { }; dao.initialize(); Foo foo = new Foo(); foo.id = 121134243; foo.val = 123123; Foo bar = new Foo(); assertTrue(dao.objectsEqual(foo, foo)); assertFalse(dao.objectsEqual(f...
BaseDaoImpl implements Dao<T, ID> { @Override public CloseableIterator<T> iterator() { return iterator(DatabaseConnection.DEFAULT_RESULT_FLAGS); } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connection...
@Test public void testIterator() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo1 = new Foo(); int equal1 = 1231231232; foo1.equal = equal1; assertEquals(1, dao.create(foo1)); Foo foo2 = new Foo(); int equal2 = 1231232; foo2.equal = equal2; assertEquals(1, dao.create(foo2)); CloseableIter...
BindingParameter { @Override public boolean equals(Object obj) { if (obj == null) return false; if (getClass() != obj.getClass()) return false; final BindingParameter other = (BindingParameter) obj; return Objects.equal(this.getParameterName(), other.getParameterName()) && Objects.equal(this.getPropertyPath(), other.ge...
@Test public void testEquals() throws Exception { BindingParameter bp = BindingParameter.create("a", "b", null); BindingParameter bp2 = BindingParameter.create("a", "b", null); assertThat(bp.equals(bp2), equalTo(true)); assertThat(bp.equals(null), equalTo(false)); assertThat(bp.equals(new Object()), equalTo(false)); }
BaseDaoImpl implements Dao<T, ID> { public DatabaseTableConfig<T> getTableConfig() { return tableConfig; } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConf...
@Test public void testTableConfig() throws Exception { DatabaseTableConfig<Foo> config = DatabaseTableConfig.fromClass(connectionSource, Foo.class); BaseDaoImpl<Foo, Integer> dao = new BaseDaoImpl<Foo, Integer>(connectionSource, config) { }; assertSame(config, dao.getTableConfig()); }
BaseDaoImpl implements Dao<T, ID> { @Override public boolean isUpdatable() { return tableInfo.isUpdatable(); } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, DatabaseTableConfig<T> table...
@Test public void testIsUpdatable() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, false); assertTrue(dao.isUpdatable()); }
BaseDaoImpl implements Dao<T, ID> { @Override public boolean isTableExists() throws SQLException { checkForInitialized(); DatabaseConnection connection = connectionSource.getReadOnlyConnection(tableInfo.getTableName()); try { return connection.isTableExists(tableInfo.getTableName()); } finally { connectionSource.releas...
@Test public void testIsTableExists() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, false); assertFalse(dao.isTableExists()); TableUtils.createTable(connectionSource, Foo.class); assertTrue(dao.isTableExists()); TableUtils.dropTable(connectionSource, Foo.class, true); assertFalse(dao.isTableExists());...
BaseDaoImpl implements Dao<T, ID> { @Override public UpdateBuilder<T, ID> updateBuilder() { checkForInitialized(); return new UpdateBuilder<T, ID>(databaseType, tableInfo, this); } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protected BaseD...
@Test public void testUpdateBuilder() throws Exception { BaseDaoImpl<Foo, Integer> dao = new BaseDaoImpl<Foo, Integer>(connectionSource, Foo.class) { }; dao.updateBuilder(); }
BaseDaoImpl implements Dao<T, ID> { @Override public DeleteBuilder<T, ID> deleteBuilder() { checkForInitialized(); return new DeleteBuilder<T, ID>(databaseType, tableInfo, this); } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protected BaseD...
@Test public void testDeleteBuilder() throws Exception { BaseDaoImpl<Foo, Integer> dao = new BaseDaoImpl<Foo, Integer>(connectionSource, Foo.class) { }; dao.deleteBuilder(); }
BaseDaoImpl implements Dao<T, ID> { @Override public Class<T> getDataClass() { return dataClass; } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig); pri...
@Test public void testDataClass() throws Exception { BaseDaoImpl<Foo, Integer> dao = new BaseDaoImpl<Foo, Integer>(Foo.class) { }; assertEquals(Foo.class, dao.getDataClass()); }
BaseDaoImpl implements Dao<T, ID> { @Override public int updateRaw(String statement, String... arguments) throws SQLException { checkForInitialized(); DatabaseConnection connection = connectionSource.getReadWriteConnection(tableInfo.getTableName()); try { return statementExecutor.updateRaw(connection, statement, argume...
@Test public void testUpdateRaw() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo1 = new Foo(); assertEquals(1, dao.create(foo1)); Foo foo2 = new Foo(); assertEquals(1, dao.create(foo2)); assertEquals(2, dao.queryForAll().size()); dao.updateRaw("DELETE FROM FOO WHERE " + Foo.ID_COLUMN_NAM...
BaseDaoImpl implements Dao<T, ID> { @Override public int executeRaw(String statement, String... arguments) throws SQLException { checkForInitialized(); DatabaseConnection connection = connectionSource.getReadWriteConnection(tableInfo.getTableName()); try { return statementExecutor.executeRaw(connection, statement, argu...
@Test public void testExecuteRaw() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo1 = new Foo(); assertEquals(1, dao.create(foo1)); Foo foo2 = new Foo(); assertEquals(1, dao.create(foo2)); assertEquals(2, dao.queryForAll().size()); dao.executeRaw("TRUNCATE TABLE FOO"); assertEquals(0, dao...
BaseDaoImpl implements Dao<T, ID> { @Override public ID extractId(T data) throws SQLException { checkForInitialized(); FieldType idField = tableInfo.getIdField(); if (idField == null) { throw new SQLException("Class " + dataClass + " does not have an id field"); } @SuppressWarnings("unchecked") ID id = (ID) idField.ext...
@Test public void testExtractId() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo = new Foo(); assertEquals((Integer) foo.id, dao.extractId(foo)); }
FunctionalBindingParameterInvoker implements BindingParameterInvoker { public static FunctionalBindingParameterInvoker create( Type originalType, BindingParameter bindingParameter) { try { FunctionalBindingParameterInvoker invokerGroup = new FunctionalBindingParameterInvoker(originalType, bindingParameter); return invo...
@Test public void testBindingException4() throws Exception { thrown.expect(BindingException.class); thrown.expectMessage("Parameter ':user.userBag.ite' can't be readable; " + "caused by: There is no getter/setter for property named 'ite' in 'class org.jfaster.mango.binding.FunctionalBindingParameterInvokerTest$UserBag'...
BeanUtil { public static List<PropertyMeta> fetchPropertyMetas(Class<?> clazz) { return cache.get(clazz); } static List<PropertyMeta> fetchPropertyMetas(Class<?> clazz); }
@Test public void fetchPropertyMetas() throws Exception { Set<PropertyMeta> pms = Sets.newHashSet(BeanUtil.fetchPropertyMetas(A.class)); Set<PropertyMeta> set = Sets.newHashSet(); set.add(getPropertyMeta(A.class, "id", int.class)); set.add(getPropertyMeta(A.class, "uid", int.class)); set.add(getPropertyMeta(A.class, "n...
BaseDaoImpl implements Dao<T, ID> { @Override public long countOf() throws SQLException { checkForInitialized(); DatabaseConnection connection = connectionSource.getReadOnlyConnection(tableInfo.getTableName()); try { return statementExecutor.queryForCountStar(connection); } finally { connectionSource.releaseConnection(...
@Test public void testCountOf() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); assertEquals(0, dao.countOf()); Foo foo = new Foo(); assertEquals(1, dao.create(foo)); assertEquals(1, dao.countOf()); assertEquals(1, dao.create(foo)); assertEquals(2, dao.countOf()); }
BaseDaoImpl implements Dao<T, ID> { @Override public List<T> queryForEq(String fieldName, Object value) throws SQLException { return queryBuilder().where().eq(fieldName, value).query(); } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protected...
@Test public void testQueryForEq() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); assertEquals(0, dao.countOf()); Foo foo1 = new Foo(); foo1.val = 1231231; assertEquals(1, dao.create(foo1)); Foo foo2 = new Foo(); foo2.val = foo1.val + 1; assertEquals(1, dao.create(foo2)); List<Foo> results = dao...
BaseDaoImpl implements Dao<T, ID> { @Override public List<T> queryForMatching(T matchObj) throws SQLException { return queryForMatching(matchObj, false); } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protected BaseDaoImpl(ConnectionSource c...
@Test public void testQueryForMatching() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); assertEquals(0, dao.countOf()); Foo foo1 = new Foo(); int val = 1231231; foo1.val = val; assertEquals(1, dao.create(foo1)); Foo foo2 = new Foo(); foo2.val = val + 1; assertEquals(1, dao.create(foo2)); Foo mat...
BaseDaoImpl implements Dao<T, ID> { @Override public List<T> queryForMatchingArgs(T matchObj) throws SQLException { return queryForMatching(matchObj, true); } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protected BaseDaoImpl(ConnectionSourc...
@Test public void testQueryForMatchingArgs() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); assertEquals(0, dao.countOf()); Foo foo1 = new Foo(); int val = 1231231; foo1.val = val; assertEquals(1, dao.create(foo1)); Foo foo2 = new Foo(); foo2.val = val + 1; assertEquals(1, dao.create(foo2)); Foo...
BaseDaoImpl implements Dao<T, ID> { @Override public List<T> queryForFieldValues(Map<String, Object> fieldValues) throws SQLException { return queryForFieldValues(fieldValues, false); } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protected ...
@Test public void testQueryForFieldValues() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); assertEquals(0, dao.countOf()); Foo foo1 = new Foo(); foo1.val = 1231231; assertEquals(1, dao.create(foo1)); Foo foo2 = new Foo(); foo2.val = foo1.val + 1; assertEquals(1, dao.create(foo2)); Map<String, Ob...
BaseDaoImpl implements Dao<T, ID> { @Override public List<T> queryForFieldValuesArgs(Map<String, Object> fieldValues) throws SQLException { return queryForFieldValues(fieldValues, true); } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> dataClass); protecte...
@Test public void testQueryForFieldValuesArgs() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put(Foo.STRING_COLUMN_NAME, "this id has a quote '"); dao.queryForFieldValuesArgs(fieldValues); }
BaseDaoImpl implements Dao<T, ID> { static <T, ID> Dao<T, ID> createDao(ConnectionSource connectionSource, Class<T> clazz) throws SQLException { return new BaseDaoImpl<T, ID>(connectionSource, clazz) { }; } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(ConnectionSource connectionSource, Class<T> da...
@Test public void testForeignCollectionAutoRefresh() throws Exception { createDao(ForeignCollectionAutoRefresh.class, false); }
BaseDaoImpl implements Dao<T, ID> { @Override public CreateOrUpdateStatus createOrUpdate(T data) throws SQLException { if (data == null) { return new CreateOrUpdateStatus(false, false, 0); } ID id = extractId(data); if (id == null || !idExists(id)) { int numRows = create(data); return new CreateOrUpdateStatus(true, fal...
@Test public void testCreateOrUpdate() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo1 = new Foo(); int equal1 = 21313; foo1.equal = equal1; CreateOrUpdateStatus status = dao.createOrUpdate(foo1); assertTrue(status.isCreated()); assertFalse(status.isUpdated()); assertEquals(1, status.get...
BaseDaoImpl implements Dao<T, ID> { @Override public T queryForSameId(T data) throws SQLException { checkForInitialized(); if (data == null) { return null; } ID id = extractId(data); if (id == null) { return null; } else { return queryForId(id); } } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl(Con...
@Test public void testQueryForSameId() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo1 = new Foo(); foo1.equal = 198412893; assertEquals(1, dao.create(foo1)); Foo fooResult = dao.queryForSameId(foo1); assertEquals(foo1.id, fooResult.id); assertEquals(foo1.equal, fooResult.equal); }
BaseDaoImpl implements Dao<T, ID> { @Override public T createIfNotExists(T data) throws SQLException { if (data == null) { return null; } T existing = queryForSameId(data); if (existing == null) { create(data); return data; } else { return existing; } } protected BaseDaoImpl(Class<T> dataClass); protected BaseDaoImpl...
@Test public void testCreateIfNotExists() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo1 = new Foo(); foo1.equal = 198412893; Foo fooResult = dao.createIfNotExists(foo1); assertSame(foo1, fooResult); fooResult = dao.createIfNotExists(foo1); assertNotSame(foo1, fooResult); assertEquals(f...
InvocationContextFactory { public InvocationContext newInvocationContext(Object[] values) { InvocationContext context = DefaultInvocationContext.create(); for (int i = 0; i < values.length; i++) { String parameterName = parameterContext.getParameterNameByPosition(i); context.addParameter(parameterName, values[i]); } re...
@Test public void testNewInvocationContext() throws Exception { List<Annotation> empty = Collections.emptyList(); ParameterDescriptor p0 = ParameterDescriptor.create(0, String.class, empty, "name"); ParameterDescriptor p1 = ParameterDescriptor.create(1, int.class, empty, "id"); List<ParameterDescriptor> pds = Arrays.as...
BaseDaoImpl implements Dao<T, ID> { @Override public long queryRawValue(String query, String... arguments) throws SQLException { checkForInitialized(); DatabaseConnection connection = connectionSource.getReadOnlyConnection(tableInfo.getTableName()); try { return statementExecutor.queryForLong(connection, query, argumen...
@Test public void testQueryRawValue() throws Exception { Dao<Foo, Object> dao = createDao(Foo.class, true); assertEquals(1, dao.create(new Foo())); assertEquals(1, dao.queryRawValue("select max(" + Foo.ID_COLUMN_NAME + ") from foo")); assertEquals(1, dao.create(new Foo())); assertEquals(2, dao.queryRawValue("select max...
LruObjectCache implements ObjectCache { @Override public <T> int size(Class<T> clazz) { Map<Object, Object> objectMap = getMapForClass(clazz); if (objectMap == null) { return 0; } else { return objectMap.size(); } } LruObjectCache(int capacity); @Override synchronized void registerClass(Class<T> clazz); @Override T get...
@Test public void testStuff() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); LruObjectCache cache = new LruObjectCache(2); dao.setObjectCache(cache); Foo foo1 = new Foo(); int val = 12312321; foo1.val = val; assertEquals(1, dao.create(foo1)); assertEquals(1, cache.size(Foo.class)); Foo result = ...
LruObjectCache implements ObjectCache { @Override public <T> void clear(Class<T> clazz) { Map<Object, Object> objectMap = getMapForClass(clazz); if (objectMap != null) { objectMap.clear(); } } LruObjectCache(int capacity); @Override synchronized void registerClass(Class<T> clazz); @Override T get(Class<T> clazz, ID id)...
@Test public void testClear() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); LruObjectCache cache = new LruObjectCache(2); dao.setObjectCache(cache); Foo foo = new Foo(); int val = 12312321; foo.val = val; assertEquals(1, dao.create(foo)); assertEquals(1, cache.size(Foo.class)); Foo result = dao...
EagerForeignCollection extends BaseForeignCollection<T, ID> implements CloseableWrappedIterable<T>, Serializable { @Override public boolean contains(Object o) { return results.contains(o); } EagerForeignCollection(Dao<T, ID> dao, Object parent, Object parentId, FieldType foreignFieldType, String orderColumn, boole...
@Test public void testContains() throws Exception { Dao<Eager, Integer> eagerDao = createDao(Eager.class, true); Dao<Foreign, Integer> foreignDao = createDao(Foreign.class, true); Eager eager = new Eager(); assertEquals(1, eagerDao.create(eager)); Foreign f0 = new Foreign(); f0.eager = eager; assertEquals(1, foreignDao...
DaoManager { public synchronized static <D extends Dao<T, ?>, T> D createDao(ConnectionSource connectionSource, Class<T> clazz) throws SQLException { if (connectionSource == null) { throw new IllegalArgumentException("connectionSource argument cannot be null"); } ClassConnectionSource key = new ClassConnectionSource(co...
@Test(expected = IllegalArgumentException.class) public void testCreateDaoNull() throws Exception { DaoManager.createDao(null, Foo.class); } @Test(expected = IllegalArgumentException.class) public void testCreateDaoTableNull() throws Exception { DaoManager.createDao(null, new DatabaseTableConfig<Foo>()); } @Test public...
DaoManager { public synchronized static <D extends Dao<T, ?>, T> D lookupDao(ConnectionSource connectionSource, Class<T> clazz) { if (connectionSource == null) { throw new IllegalArgumentException("connectionSource argument cannot be null"); } ClassConnectionSource key = new ClassConnectionSource(connectionSource, claz...
@Test(expected = IllegalArgumentException.class) public void testLookupDaoNull() { DaoManager.lookupDao(null, Foo.class); } @Test public void testLookupDaoUnknown() { assertNull(DaoManager.lookupDao(connectionSource, getClass())); } @Test(expected = IllegalArgumentException.class) public void testLookupDaoTableNull() {...
DaoManager { public static synchronized void registerDao(ConnectionSource connectionSource, Dao<?, ?> dao) { if (connectionSource == null) { throw new IllegalArgumentException("connectionSource argument cannot be null"); } addDaoToClassMap(new ClassConnectionSource(connectionSource, dao.getDataClass()), dao); } synchr...
@Test public void testRegisterDao() throws Exception { Dao<RegisterClass, Void> dao = DaoManager.lookupDao(connectionSource, RegisterClass.class); assertNull(dao); Dao<? extends RegisterClass, Object> daoImpl = BaseDaoImpl.createDao(connectionSource, RegisterClass.class); DaoManager.registerDao(connectionSource, daoImp...
DefaultInvocationContext implements InvocationContext { @Override @Nullable public Object getNullableBindingValue(BindingParameterInvoker invoker) { String key = getCacheKey(invoker); if (cache.containsKey(key)) { return cache.get(key); } String parameterName = invoker.getBindingParameter().getParameterName(); if (!par...
@Test public void testGetNullableBindingValue() throws Exception { DefaultInvocationContext ctx = DefaultInvocationContext.create(); UserBag userBag = new UserBag(); userBag.setName("ash"); User user = new User(); user.setUserBag(userBag); user.setId(100); ctx.addParameter("userId", 9527); ctx.addParameter("user", user...
RuntimeExceptionDao implements Dao<T, ID> { @Override public CloseableIterator<T> iterator() { return dao.iterator(); } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(ConnectionSource connectionSource, Class<T> clazz); static RuntimeExceptionDao<T, ID> createDao(ConnectionSource connec...
@Test public void testIfAllMethodsAreThere() { List<String> failedMessages = new ArrayList<String>(); List<Method> runtimeMethods = new ArrayList<Method>(Arrays.asList(RuntimeExceptionDao.class.getDeclaredMethods())); List<Method> daoMethods = new ArrayList<Method>(Arrays.asList(Dao.class.getDeclaredMethods())); daoMet...
RuntimeExceptionDao implements Dao<T, ID> { public static <T, ID> RuntimeExceptionDao<T, ID> createDao(ConnectionSource connectionSource, Class<T> clazz) throws SQLException { @SuppressWarnings("unchecked") Dao<T, ID> castDao = (Dao<T, ID>) DaoManager.createDao(connectionSource, clazz); return new RuntimeExceptionDao<T...
@Test public void testCreateDao() throws Exception { createDao(Foo.class, true); RuntimeExceptionDao<Foo, String> dao = RuntimeExceptionDao.createDao(connectionSource, Foo.class); assertEquals(0, dao.countOf()); }
RuntimeExceptionDao implements Dao<T, ID> { @Override public T queryForId(ID id) { try { return dao.queryForId(id); } catch (SQLException e) { logMessage(e, "queryForId threw exception on: " + id); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(Connec...
@Test(expected = RuntimeException.class) public void testQueryForIdThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.queryForId(isA(String.class))).andT...
RuntimeExceptionDao implements Dao<T, ID> { @Override public T queryForFirst(PreparedQuery<T> preparedQuery) { try { return dao.queryForFirst(preparedQuery); } catch (SQLException e) { logMessage(e, "queryForFirst threw exception on: " + preparedQuery); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> ...
@Test(expected = RuntimeException.class) public void testQueryForFirstPreparedThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.queryForFirst(null)).and...
RuntimeExceptionDao implements Dao<T, ID> { @Override public List<T> queryForAll() { try { return dao.queryForAll(); } catch (SQLException e) { logMessage(e, "queryForAll threw exception"); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(ConnectionSour...
@Test(expected = RuntimeException.class) public void testQueryForAllThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.queryForAll()).andThrow(new SQLExc...
RuntimeExceptionDao implements Dao<T, ID> { @Override public List<T> queryForEq(String fieldName, Object value) { try { return dao.queryForEq(fieldName, value); } catch (SQLException e) { logMessage(e, "queryForEq threw exception on: " + fieldName); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao)...
@Test(expected = RuntimeException.class) public void testQueryForEqThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.queryForEq(null, null)).andThrow(ne...
RuntimeExceptionDao implements Dao<T, ID> { @Override public List<T> queryForMatching(T matchObj) { try { return dao.queryForMatching(matchObj); } catch (SQLException e) { logMessage(e, "queryForMatching threw exception on: " + matchObj); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static Ru...
@Test(expected = RuntimeException.class) public void testQueryForMatchingThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.queryForMatching(null)).andTh...
DefaultInvocationContext implements InvocationContext { @Override public Object getBindingValue(BindingParameterInvoker invoker) { Object value = getNullableBindingValue(invoker); if (value == null) { throw new BindingException("Parameter '" + invoker.getBindingParameter() + "' need a non-null value"); } return value; ...
@Test public void testGetBindingValue() throws Exception { DefaultInvocationContext ctx = DefaultInvocationContext.create(); ctx.addParameter("userId", 9527); BindingParameterInvoker userIdInvoker = FunctionalBindingParameterInvoker.create(User.class, BindingParameter.create("userId", "", null)); assertThat(ctx.getBind...
RuntimeExceptionDao implements Dao<T, ID> { @Override public List<T> queryForMatchingArgs(T matchObj) { try { return dao.queryForMatchingArgs(matchObj); } catch (SQLException e) { logMessage(e, "queryForMatchingArgs threw exception on: " + matchObj); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao...
@Test(expected = RuntimeException.class) public void testQueryForMatchingArgsThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.queryForMatchingArgs(null...
RuntimeExceptionDao implements Dao<T, ID> { @Override public List<T> queryForFieldValues(Map<String, Object> fieldValues) { try { return dao.queryForFieldValues(fieldValues); } catch (SQLException e) { logMessage(e, "queryForFieldValues threw exception"); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID...
@Test(expected = RuntimeException.class) public void testQueryForFieldsValuesThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.queryForFieldValues(null)...
RuntimeExceptionDao implements Dao<T, ID> { @Override public List<T> queryForFieldValuesArgs(Map<String, Object> fieldValues) { try { return dao.queryForFieldValuesArgs(fieldValues); } catch (SQLException e) { logMessage(e, "queryForFieldValuesArgs threw exception"); throw new RuntimeException(e); } } RuntimeExceptionD...
@Test(expected = RuntimeException.class) public void testQueryForFieldsValuesArgsThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.queryForFieldValuesAr...
RuntimeExceptionDao implements Dao<T, ID> { @Override public T queryForSameId(T data) { try { return dao.queryForSameId(data); } catch (SQLException e) { logMessage(e, "queryForSameId threw exception on: " + data); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID>...
@Test(expected = RuntimeException.class) public void testQueryForSameIdThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.queryForSameId(null)).andThrow(...
RuntimeExceptionDao implements Dao<T, ID> { @Override public List<T> query(PreparedQuery<T> preparedQuery) { try { return dao.query(preparedQuery); } catch (SQLException e) { logMessage(e, "query threw exception on: " + preparedQuery); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static Runti...
@Test(expected = RuntimeException.class) public void testQueryThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.query(null)).andThrow(new SQLException("...
RuntimeExceptionDao implements Dao<T, ID> { @Override public int create(T data) { try { return dao.create(data); } catch (SQLException e) { logMessage(e, "create threw exception on: " + data); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(ConnectionS...
@Test(expected = RuntimeException.class) public void testCreateThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.create((Foo) null)).andThrow(new SQLExc...
RuntimeExceptionDao implements Dao<T, ID> { @Override public T createIfNotExists(T data) { try { return dao.createIfNotExists(data); } catch (SQLException e) { logMessage(e, "createIfNotExists threw exception on: " + data); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionD...
@Test(expected = RuntimeException.class) public void testCreateIfNotExistsThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.createIfNotExists(null)).and...
RuntimeExceptionDao implements Dao<T, ID> { @Override public CreateOrUpdateStatus createOrUpdate(T data) { try { return dao.createOrUpdate(data); } catch (SQLException e) { logMessage(e, "createOrUpdate threw exception on: " + data); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static Runtime...
@Test(expected = RuntimeException.class) public void testCreateOrUpdateThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.createOrUpdate(null)).andThrow(...
RuntimeExceptionDao implements Dao<T, ID> { @Override public int update(T data) { try { return dao.update(data); } catch (SQLException e) { logMessage(e, "update threw exception on: " + data); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(ConnectionS...
@Test(expected = RuntimeException.class) public void testUpdateThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.update((Foo) null)).andThrow(new SQLExc...
RuntimeExceptionDao implements Dao<T, ID> { @Override public int updateId(T data, ID newId) { try { return dao.updateId(data, newId); } catch (SQLException e) { logMessage(e, "updateId threw exception on: " + data); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID...
@Test(expected = RuntimeException.class) public void testUpdateIdThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.updateId(null, null)).andThrow(new SQ...
DefaultInvocationContext implements InvocationContext { @Override public void setBindingValue(BindingParameterInvoker invoker, Object value) { String key = getCacheKey(invoker); cache.put(key, value); } private DefaultInvocationContext(); static DefaultInvocationContext create(); @Override void addParameter(String par...
@Test public void testSetBindingValue() throws Exception { DefaultInvocationContext ctx = DefaultInvocationContext.create(); ctx.addParameter("userId", 9527); BindingParameterInvoker userIdInvoker = FunctionalBindingParameterInvoker.create(User.class, BindingParameter.create("userId", "", null)); assertThat(ctx.getBind...
RuntimeExceptionDao implements Dao<T, ID> { @Override public int refresh(T data) { try { return dao.refresh(data); } catch (SQLException e) { logMessage(e, "refresh threw exception on: " + data); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(Connecti...
@Test(expected = RuntimeException.class) public void testRefreshThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.refresh(null)).andThrow(new SQLExcepti...
RuntimeExceptionDao implements Dao<T, ID> { @Override public int delete(T data) { try { return dao.delete(data); } catch (SQLException e) { logMessage(e, "delete threw exception on: " + data); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(ConnectionS...
@Test(expected = RuntimeException.class) public void testDeleteThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.delete((Foo) null)).andThrow(new SQLExc...
RuntimeExceptionDao implements Dao<T, ID> { @Override public int deleteById(ID id) { try { return dao.deleteById(id); } catch (SQLException e) { logMessage(e, "deleteById threw exception on: " + id); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(Conn...
@Test(expected = RuntimeException.class) public void testDeleteByIdThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.deleteById(null)).andThrow(new SQLE...
RuntimeExceptionDao implements Dao<T, ID> { @Override public int deleteIds(Collection<ID> ids) { try { return dao.deleteIds(ids); } catch (SQLException e) { logMessage(e, "deleteIds threw exception on: " + ids); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> cr...
@Test(expected = RuntimeException.class) public void testDeleteIdsThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.deleteIds(null)).andThrow(new SQLExc...
RuntimeExceptionDao implements Dao<T, ID> { @Override public void closeLastIterator() { try { dao.closeLastIterator(); } catch (IOException e) { logMessage(e, "closeLastIterator threw exception"); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(Connect...
@Test(expected = RuntimeException.class) public void testCloseLastIteratorThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); dao.closeLastIterator(); expectLastCall...
RuntimeExceptionDao implements Dao<T, ID> { @Override public CloseableIterator<T> closeableIterator() { return dao.closeableIterator(); } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(ConnectionSource connectionSource, Class<T> clazz); static RuntimeExceptionDao<T, ID> createDao(Conne...
@Test public void testCloseableIterator() { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.closeableIterator()).andReturn(null); replay(dao); rtDao.closeableIterator(); verify(...
DefaultParameterContext implements ParameterContext { @Override public String getParameterNameByPosition(int position) { String name = positionToNameMap.get(position); if (name == null) { throw new IllegalStateException("parameter name can not be found by position [" + position + "]"); } return name; } private Default...
@Test public void testGetParameterNameByPosition() throws Exception { List<Annotation> empty = Collections.emptyList(); ParameterDescriptor p0 = ParameterDescriptor.create(0, String.class, empty, "param1"); ParameterDescriptor p1 = ParameterDescriptor.create(1, int.class, empty, "param2"); List<ParameterDescriptor> pds...
RuntimeExceptionDao implements Dao<T, ID> { @Override public GenericRawResults<String[]> queryRaw(String query, String... arguments) { try { return dao.queryRaw(query, arguments); } catch (SQLException e) { logMessage(e, "queryRaw threw exception on: " + query); throw new RuntimeException(e); } } RuntimeExceptionDao(Da...
@Test(expected = RuntimeException.class) public void testQueryRawThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.queryRaw(null)).andThrow(new SQLExcep...
RuntimeExceptionDao implements Dao<T, ID> { @Override public long queryRawValue(String query, String... arguments) { try { return dao.queryRawValue(query, arguments); } catch (SQLException e) { logMessage(e, "queryRawValue threw exception on: " + query); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID>...
@Test public void testQueryRawValue() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); String query = "fkeowjfkewfewf"; expect(dao.queryRawValue(query, new String[0])).an...
RuntimeExceptionDao implements Dao<T, ID> { @Override public int executeRaw(String statement, String... arguments) { try { return dao.executeRaw(statement, arguments); } catch (SQLException e) { logMessage(e, "executeRaw threw exception on: " + statement); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, I...
@Test public void testExecuteRaw() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.executeRaw(null)).andReturn(0); replay(dao); rtDao.executeRaw(null); verify...
RuntimeExceptionDao implements Dao<T, ID> { @Override public void assignEmptyForeignCollection(T parent, String fieldName) { try { dao.assignEmptyForeignCollection(parent, fieldName); } catch (SQLException e) { logMessage(e, "assignEmptyForeignCollection threw exception on " + fieldName); throw new RuntimeException(e);...
@Test public void testAssignEmptyForeignCollection() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); dao.assignEmptyForeignCollection(null, null); replay(dao); rtDao.ass...
DefaultParameterContext implements ParameterContext { @Override public BindingParameterInvoker getBindingParameterInvoker(BindingParameter bindingParameter) { String parameterName = bindingParameter.getParameterName(); Type type = nameToTypeMap.get(parameterName); if (type == null) { throw new BindingException("Paramet...
@Test public void testGetBindingParameterInvoker() throws Exception { List<Annotation> empty = Collections.emptyList(); ParameterDescriptor p0 = ParameterDescriptor.create(0, String.class, empty, "1"); ParameterDescriptor p1 = ParameterDescriptor.create(1, User.class, empty, "2"); List<ParameterDescriptor> pds = Arrays...
RuntimeExceptionDao implements Dao<T, ID> { @Override public int executeRawNoArgs(String statement) { try { return dao.executeRawNoArgs(statement); } catch (SQLException e) { logMessage(e, "executeRawNoArgs threw exception on: " + statement); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); stati...
@Test public void testExecuteRawNoArgs() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.executeRawNoArgs(null)).andReturn(0); replay(dao); rtDao.executeRawNo...
RuntimeExceptionDao implements Dao<T, ID> { @Override public void setObjectCache(boolean enabled) { try { dao.setObjectCache(enabled); } catch (SQLException e) { logMessage(e, "setObjectCache(" + enabled + ") threw exception"); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExcept...
@Test public void testSetObjectCache() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); dao.setObjectCache(false); replay(dao); rtDao.setObjectCache(false); verify(dao); ...
RuntimeExceptionDao implements Dao<T, ID> { @Override public int updateRaw(String statement, String... arguments) { try { return dao.updateRaw(statement, arguments); } catch (SQLException e) { logMessage(e, "updateRaw threw exception on: " + statement); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> ...
@Test(expected = RuntimeException.class) public void testUpdateRawThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.updateRaw(null)).andThrow(new SQLExc...
RuntimeExceptionDao implements Dao<T, ID> { @Override public <CT> CT callBatchTasks(Callable<CT> callable) { try { return dao.callBatchTasks(callable); } catch (Exception e) { logMessage(e, "callBatchTasks threw exception on: " + callable); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static ...
@Test(expected = RuntimeException.class) public void testCallBatchTasksThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.callBatchTasks(null)).andThrow(...
RuntimeExceptionDao implements Dao<T, ID> { @Override public boolean objectsEqual(T data1, T data2) { try { return dao.objectsEqual(data1, data2); } catch (SQLException e) { logMessage(e, "objectsEqual threw exception on: " + data1 + " and " + data2); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> da...
@Test(expected = RuntimeException.class) public void testObjectsEqualThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.objectsEqual(null, null)).andThro...
DefaultParameterContext implements ParameterContext { @Override public List<ParameterDescriptor> getParameterDescriptors() { return parameterDescriptors; } private DefaultParameterContext(List<ParameterDescriptor> parameterDescriptors); static DefaultParameterContext create(List<ParameterDescriptor> parameterDescripto...
@Test public void testGetParameterDescriptors() throws Exception { List<Annotation> empty = Collections.emptyList(); ParameterDescriptor p0 = ParameterDescriptor.create(0, String.class, empty, "1"); ParameterDescriptor p1 = ParameterDescriptor.create(1, User.class, empty, "2"); List<ParameterDescriptor> pds = Arrays.as...
RuntimeExceptionDao implements Dao<T, ID> { @Override public ID extractId(T data) { try { return dao.extractId(data); } catch (SQLException e) { logMessage(e, "extractId threw exception on: " + data); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(Con...
@Test(expected = RuntimeException.class) public void testExtractIdThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.extractId(null)).andThrow(new SQLExc...
RuntimeExceptionDao implements Dao<T, ID> { @Override public boolean isTableExists() { try { return dao.isTableExists(); } catch (SQLException e) { logMessage(e, "isTableExists threw exception"); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(Connecti...
@Test(expected = RuntimeException.class) public void testIsTableExistsThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.isTableExists()).andThrow(new SQ...
RuntimeExceptionDao implements Dao<T, ID> { @Override public long countOf() { try { return dao.countOf(); } catch (SQLException e) { logMessage(e, "countOf threw exception"); throw new RuntimeException(e); } } RuntimeExceptionDao(Dao<T, ID> dao); static RuntimeExceptionDao<T, ID> createDao(ConnectionSource connectionSo...
@Test(expected = RuntimeException.class) public void testCountOfThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.countOf()).andThrow(new SQLException("...
RuntimeExceptionDao implements Dao<T, ID> { @Override public <FT> ForeignCollection<FT> getEmptyForeignCollection(String fieldName) { try { return dao.getEmptyForeignCollection(fieldName); } catch (SQLException e) { logMessage(e, "getEmptyForeignCollection threw exception on " + fieldName); throw new RuntimeException(e...
@Test(expected = RuntimeException.class) public void testGetEmptyForeignCollectionThrow() throws Exception { @SuppressWarnings("unchecked") Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class); RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao); expect(dao.getEmptyForeignColle...