Skip to content

Commit

Permalink
fix issue with the @table annotation when combining numberedRows with…
Browse files Browse the repository at this point in the history
… columnTitles (fixes #166)
  • Loading branch information
Jan Schäfer committed Nov 11, 2015
1 parent 97af18e commit 0eb2ec6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Fixed issue with primitive arrays and the @Table annotation [#162](https://github.com/TNG/JGiven/issues/162)
* Fixed an issue when using the `@Table` parameter that could lead to unwanted parameters in the data table [#161](https://github.com/TNG/JGiven/issues/161)
* Fixed an issue with the Maven Plugin where the customJsFile parameter actually set the customCssFile parameter [#167](https://github.com/TNG/JGiven/issues/167)
* Fixed an issue with the @Table annotation when combining numberedRows with columnTitles [#166](https://github.com/TNG/JGiven/issues/166)

## New Features

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.tngtech.jgiven.report.model;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Lists;
import com.tngtech.jgiven.annotation.Table.HeaderType;
import com.tngtech.jgiven.impl.util.AssertionUtil;

Expand All @@ -22,7 +24,17 @@ public class DataTable {

public DataTable( HeaderType headerType, List<List<String>> data ) {
this.headerType = headerType;
this.data = data;
this.data = copy( data );
}

private List<List<String>> copy( List<List<String>> data ) {
List<List<String>> dataCopy = Lists.newArrayListWithExpectedSize( data.size() );

for( List<String> row : data ) {
dataCopy.add( new ArrayList<String>( row ) );
}

return dataCopy;
}

public HeaderType getHeaderType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public void a_list_of_POJOs_with_numbered_rows(

public void a_list_of_POJOs_with_numbered_rows_and_custom_header(
@Table( numberedRowsHeader = "Counter" ) TestCustomer... testCustomer ) {}

public void a_two_dimensional_array_with_numbered_rows(
@Table( numberedRows = true, columnTitles = "t" ) Object[][] testCustomer ) {}

}

static class TestCustomer {
Expand Down Expand Up @@ -131,4 +135,11 @@ public void parameter_tables_can_have_numbered_rows_with_custom_headers() {
new TestCustomer( "Lee Smith", "lee@smith.com" )
);
}

@Test
public void two_dimensional_arrays_can_be_numbered() {
given().a_two_dimensional_array_with_numbered_rows( new Object[][] {
{ "a" },
{ "b" } } );
}
}

0 comments on commit 0eb2ec6

Please sign in to comment.