@Test public void QueryTableHasCorrectColumns() throws IOException { try { DataSource queryDataSource = Config.userDatabaseDataSource(); String getColumns = "DESCRIBE " + QueryDaoImpl.QUERY_TABLE; JdbcTemplate queryDatabase = new JdbcTemplate(queryDataSource); List<MySQLColumn> columns = queryDatabase.query(getColumns, new ParseMySQLColumns()); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.QUERY_ID, MySQLColumn.INT_UNSIGNED(10), MySQLColumn.NEVER_NULL, MySQLColumn.PRIMARY_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.METADATA_ID, MySQLColumn.INT_UNSIGNED(10), MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.EXPERIMENT, MySQLColumn.VARCHAR(255), MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.BARCODE, MySQLColumn.VARCHAR(255), MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.MEASUREMENT, MySQLColumn.VARCHAR(255), MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.START_TIME, MySQLColumn.DATETIME, MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.END_TIME, MySQLColumn.DATETIME, MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.WATERING, MySQLColumn.TINYINT(1), MySQLColumn.NEVER_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.VISIBLE, MySQLColumn.TINYINT(1), MySQLColumn.NEVER_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.FLUORESCENT, MySQLColumn.TINYINT(1), MySQLColumn.NEVER_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.INFRARED, MySQLColumn.TINYINT(1), MySQLColumn.NEVER_NULL, MySQLColumn.NOT_KEY)); } catch (MalformedConfigException e) { fail("Configuration file missing fields."); } }
@Test public void QueryMetadataTableHasCorrectColumns() throws IOException { try { DataSource queryDataSource = Config.userDatabaseDataSource(); String getColumns = "DESCRIBE " + QueryDaoImpl.METADATA_TABLE; JdbcTemplate queryDatabase = new JdbcTemplate(queryDataSource); List<MySQLColumn> columns = queryDatabase.query(getColumns, new ParseMySQLColumns()); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.METADATA_ID, MySQLColumn.INT_UNSIGNED(10), MySQLColumn.NEVER_NULL, MySQLColumn.PRIMARY_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.QUERY_ID, MySQLColumn.INT_UNSIGNED(10), MySQLColumn.NEVER_NULL, MySQLColumn.MULTIPLE_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.USER_ID, MySQLColumn.INT_UNSIGNED(10), MySQLColumn.CAN_NULL, MySQLColumn.MULTIPLE_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.COMMENT, MySQLColumn.TEXT, MySQLColumn.CAN_NULL, MySQLColumn.MULTIPLE_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.DATE_MADE, MySQLColumn.DATETIME, MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.DOWNLOAD_BEGIN, MySQLColumn.DATETIME, MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.DOWNLOAD_END, MySQLColumn.DATETIME, MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.INTERRUPTED, MySQLColumn.TINYINT(1), MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.MISSED_SNAPSHOTS, MySQLColumn.TEXT, MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.SIZE, MySQLColumn.BIGINT(20), MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.NUM_SNAPSHOTS, MySQLColumn.INT(11), MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); ListAssert.assertContains( columns, new MySQLColumn( QueryDaoImpl.NUM_TILES, MySQLColumn.INT(11), MySQLColumn.CAN_NULL, MySQLColumn.NOT_KEY)); } catch (MalformedConfigException e) { fail("Configuration file missing fields."); } }