### Question:
SqliteDataExporter implements DataExporter { @Override public void export(final StoreLoader loader, final Path output, final String username, final String password) throws SQLException, IOException { final String connectionString = "jdbc:sqlite:" + output.toString(); final List<String> createTableStatements = Stream.of(getClass().getResourceAsStream(CREATE_TABLE_RESOURCE)) .map(InputStreamReader::new) .map(BufferedReader::new) .flatMap(BufferedReader::lines) .collect(Collectors.toList()); try (Connection conn = DriverManager.getConnection(connectionString, username, password)) { try (Statement stmt = conn.createStatement()) { for (final String createTable : createTableStatements) { stmt.executeUpdate(createTable); } } try (PreparedStatement insertStatement = conn.prepareStatement(INSERT_ROW)) { DataEntry next; while ((next = loader.nextEntry()) != null) { try (InputStream data = next.getValue()) { insertStatement.setBytes(1, next.getKey()); insertStatement.setBytes(2, IOUtils.toByteArray(data)); insertStatement.execute(); } } } } }  @Override void export(final StoreLoader loader,
                       final Path output,
                       final String username,
                       final String password);  }### Answer:
@Test public void exportSingleLine() throws SQLException, IOException { final Path outputPath = Files.createTempFile("exportSingleLine", ".db"); final StoreLoader mockLoader = new MockDataLoader(singletonMap("HASH", "VALUE")); exporter.export(mockLoader, outputPath, null, null); final String connectionString = "jdbc:sqlite:" + outputPath; try (Connection conn = DriverManager.getConnection(connectionString); ResultSet rs = conn.createStatement().executeQuery(QUERY)) { final ResultSetMetaData metaData = rs.getMetaData(); final List<String> columnNames = IntStream .range(1, metaData.getColumnCount() + 1) .mapToObj(i -> JdbcCallback.execute(() -> metaData.getColumnName(i))) .collect(Collectors.toList()); assertThat(columnNames).containsExactlyInAnyOrder("HASH", "ENCODED_PAYLOAD", "TIMESTAMP"); while (rs.next()) { assertThat(rs.getString("TIMESTAMP")).isNull(); assertThat(rs.getString("HASH")).isEqualTo("HASH"); assertThat(rs.getString("ENCODED_PAYLOAD")).isEqualTo("VALUE"); } } }
@Test public void exportSingleLineWithUsernameAndPassword() throws SQLException, IOException { final Path outputPath = Files.createTempFile("exportSingleLine", ".db"); final String username = "sa"; final String password = "pass"; final StoreLoader mockLoader = new MockDataLoader(singletonMap("HASH", "VALUE")); exporter.export(mockLoader, outputPath, username, password); final String connectionString = "jdbc:sqlite:" + outputPath; try (Connection conn = DriverManager.getConnection(connectionString, username, password); ResultSet rs = conn.createStatement().executeQuery(QUERY)) { final ResultSetMetaData metaData = rs.getMetaData(); final List<String> columnNames = IntStream .range(1, metaData.getColumnCount() + 1) .mapToObj(i -> JdbcCallback.execute(() -> metaData.getColumnName(i))) .collect(Collectors.toList()); assertThat(columnNames).containsExactlyInAnyOrder("HASH", "ENCODED_PAYLOAD", "TIMESTAMP"); while (rs.next()) { assertThat(rs.getString("TIMESTAMP")).isNull(); assertThat(rs.getString("HASH")).isEqualTo("HASH"); assertThat(rs.getString("ENCODED_PAYLOAD")).isEqualTo("VALUE"); } } }