Mauro,

I just implemented this based on your suggestions.  It works great.
Thank you.  I'll be using it next month on a new project.

On Wed, Dec 23, 2009 at 12:29 PM, Mauro Talevi
<[email protected]> wrote:
> Christopher Gardner wrote:
>>
>> Earlier in this thread your example showed  the table passed into the
>> Given method as a String.
>>
>> @When("I do something with a table $tableContent")
>> public void doSomethingWithATable(String tableContent){
>>  ExamplesTable table = new ExamplesTable(tableContent);
>>  // use table to retrieve contents by row
>> }
>>
>> Later in the thread, it was passed as an ExamplesTable?  Was that due
>> to supporting changes made in 2.4, and for 2.3 we will still need to
>> pass the table as a String?  Also, below you mention the need to write
>> a converter.  Is this what you're talking about?
>>
>>  private List<Trader> toTraders(ExamplesTable table) {
>>        List<Trader> traders = new ArrayList<Trader>();
>>        List<Map<String, String>> rows = table.getRows();
>>        for (Map<String, String> row : rows) {
>>            String name = row.get("name");
>>            String rank = row.get("rank");
>>            traders.add(new Trader(name, rank));
>>        }
>>        Collections.sort(traders);
>>        return traders;
>>    }
>>
>> Thanks.
>
>
> Yes, all you need to do is to add the following parameter converter:
>
>    public class ExamplesTableConverter implements ParameterConverter {
>        public boolean accept(Type type) {
>            if (type instanceof Class<?>) {
>                return ExamplesTable.class.isAssignableFrom((Class<?>) type);
>            }
>            return false;
>        }
>
>        public Object convertValue(String value, Type type) {
>            return new ExamplesTable(value);
>        }
>
>    }
>
> And configure it as explained in
>
> http://jbehave.org/reference/stable/parameter-converters.html
>
> Cheers
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to