@Test public void shouldCreateDatabase() throws Exception { WikiDB db = new WikiDB(tempDir); TopicData data = db.selectTopic("test"); assertThat(data).isNull(); }
@Nullable public TopicData selectTopic(String name) throws SQLException { TopicData topicData = new TopicData(name); fSelectContent.setString(1, name); try (ResultSet resultSet = fSelectContent.executeQuery()) { if (resultSet.next()) { topicData.setContent(resultSet.getString(1)); return topicData; } } return null; }
WikiDB implements Closeable { @Nullable public TopicData selectTopic(String name) throws SQLException { TopicData topicData = new TopicData(name); fSelectContent.setString(1, name); try (ResultSet resultSet = fSelectContent.executeQuery()) { if (resultSet.next()) { topicData.setContent(resultSet.getString(1)); return topicData; } } return null; } }
WikiDB implements Closeable { @Nullable public TopicData selectTopic(String name) throws SQLException { TopicData topicData = new TopicData(name); fSelectContent.setString(1, name); try (ResultSet resultSet = fSelectContent.executeQuery()) { if (resultSet.next()) { topicData.setContent(resultSet.getString(1)); return topicData; } } return null; } WikiDB(File directory); }
WikiDB implements Closeable { @Nullable public TopicData selectTopic(String name) throws SQLException { TopicData topicData = new TopicData(name); fSelectContent.setString(1, name); try (ResultSet resultSet = fSelectContent.executeQuery()) { if (resultSet.next()) { topicData.setContent(resultSet.getString(1)); return topicData; } } return null; } WikiDB(File directory); void tearDown(); @Override void close(); @Nullable TopicData selectTopic(String name); void insertTopic(TopicData topic); void updateTopic(TopicData topic); @Nullable ImageData selectImage(String imageName); void insertImage(ImageData imageData); void updateImage(ImageData imageData); @Override String toString(); }
WikiDB implements Closeable { @Nullable public TopicData selectTopic(String name) throws SQLException { TopicData topicData = new TopicData(name); fSelectContent.setString(1, name); try (ResultSet resultSet = fSelectContent.executeQuery()) { if (resultSet.next()) { topicData.setContent(resultSet.getString(1)); return topicData; } } return null; } WikiDB(File directory); void tearDown(); @Override void close(); @Nullable TopicData selectTopic(String name); void insertTopic(TopicData topic); void updateTopic(TopicData topic); @Nullable ImageData selectImage(String imageName); void insertImage(ImageData imageData); void updateImage(ImageData imageData); @Override String toString();  }