import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Collections;
import java.util.List;
import javax.annotation.CheckForNull;
import org.apache.commons.dbutils.DbUtils;
pstmt.setString(2, Type.SOURCE);
rs = pstmt.executeQuery();
if (rs.next()) {
- return END_OF_LINE_SPLITTER.splitToList(rs.getString(1));
+ String string = rs.getString(1);
+ if (string == null) {
+ return Collections.emptyList();
+ }
+ return END_OF_LINE_SPLITTER.splitToList(string);
}
return null;
} catch (SQLException e) {
"project_uuid", "file_uuid", "data_hash", "line_hashes", "src_hash", "created_at", "updated_at", "data_type", "revision");
}
+ @Test
+ public void selectLineHashes_does_not_fail_when_lineshashes_is_null() {
+
+ dbTester.prepareDbUnit(getClass(), "shared.xml");
+
+ underTest.insert(new FileSourceDto()
+ .setProjectUuid("PRJ_UUID")
+ .setFileUuid("FILE2_UUID")
+ .setBinaryData("FILE2_BINARY_DATA".getBytes())
+ .setDataHash("FILE2_DATA_HASH")
+ .setSrcHash("FILE2_HASH")
+ .setDataType(Type.SOURCE)
+ .setCreatedAt(1500000000000L)
+ .setUpdatedAt(1500000000001L)
+ .setRevision("123456789"));
+
+ assertThat(underTest.selectLineHashes(dbTester.getSession(), "FILE2_UUID")).isEmpty();
+ }
+
@Test
public void update() {
dbTester.prepareDbUnit(getClass(), "shared.xml");