Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backwards compatibility for RoboCursor.getColumnCount(). #2830

Merged
merged 1 commit into from
Jan 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ public void close() {

@Override
public int getColumnCount() {
return columnNames.size();
if (columnNames.isEmpty()) {
return results[0].length;
} else {
return columnNames.size();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ public void query_shouldMakeQueryParamsAvailable() throws Exception {
assertThat(cursor.sortOrder).isEqualTo("sortOrder");
}

@Test
public void getColumnCount_whenSetColumnNamesHasntBeenCalled_shouldReturnCountFromData() throws Exception {
RoboCursor cursor = new RoboCursor();
cursor.setResults(new Object[][]{
new Object[] {1, 2, 3},
new Object[] {1, 2},
});
assertThat(cursor.getColumnCount()).isEqualTo(3);

cursor.setColumnNames(asList("a", "b", "c", "d"));
assertThat(cursor.getColumnCount()).isEqualTo(4);
}

@Test
public void getColumnName_shouldReturnColumnName() throws Exception {
assertThat(cursor.getColumnCount()).isEqualTo(8);
Expand Down