@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "test-context.xml")
public class WhenAvatarFielsIsAdded {

	@Autowired
	private DataSource dataSource;

	@Test
	public void avatarAttributeShouldExists() throws SQLException {

		JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
		ResultSetMetaData resultSetMetaData = (ResultSetMetaData) jdbcTemplate
				.execute(new StatementCallback() {

					public Object doInStatement(Statement statement)
							throws SQLException, DataAccessException {
						return statement.executeQuery("SELECT * FROM author")
								.getMetaData();
					}
				});
		assertThat(resultSetMetaData.getColumnName(5), is("AVATAR"));
	}

	@Test
	public void previousAuthorsAvatarAttributeShouldNotBeNull()
			throws SQLException {

		JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

		int numberOfNullAvatarContent = jdbcTemplate
				.queryForInt("SELECT count(*) FROM author WHERE avatar IS NULL");
		assertThat(numberOfNullAvatarContent, is(0));
	}
}