Skip to content

Commit

Permalink
Modify example to use custom converter for table cell. Passes with CL…
Browse files Browse the repository at this point in the history
…I runner, fails with JUnit runner. No idea why yet...
  • Loading branch information
aslakhellesoy committed Jul 9, 2013
1 parent 4bdc2a7 commit 81e42b1
Showing 1 changed file with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package cucumber.examples.java.calculator;

import cucumber.api.Transformer;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import cucumber.deps.com.thoughtworks.xstream.annotations.XStreamConverter;

import java.util.List;

Expand All @@ -14,7 +16,7 @@ public class ShoppingStepdefs {
@Given("^the following groceries:$")
public void the_following_groceries(List<Grocery> groceries) {
for (Grocery grocery : groceries) {
calc.push(grocery.price);
calc.push(grocery.price.value);
calc.push("+");
}
}
Expand All @@ -32,6 +34,30 @@ public void my_change_should_be_(int change) {

public static class Grocery {
public String name;
public int price;
public Price price;

public Grocery() {
super();
}
}

@XStreamConverter(Price.Converter.class)
public static class Price {
public int value;

public Price(int value) {
this.value = value;
}

public static class Converter extends Transformer<Price> {
public Converter() {
System.out.println("******** CONVERTER INSTANTIATED");
}

@Override
public Price transform(String value) {
return new Price(Integer.parseInt(value));
}
}
}
}

0 comments on commit 81e42b1

Please sign in to comment.