Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
KostyaSha committed Oct 15, 2016
1 parent 3e93b30 commit e2da85b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions core/src/test/java/org/kohsuke/stapler/DataBindingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import junit.framework.TestCase;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.beanutils.FluentPropertyBeanIntrospector;
import org.junit.Test;

import javax.annotation.PostConstruct;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -398,4 +400,34 @@ public void testDerivedProperty() {
DerivedProperty r = bind("{items:[1,3,5]}",DerivedProperty.class);
assertEquals(Arrays.asList(1,3,5),r.getItems());
}

public static class FluentSetter {
private List<String> items;

@DataBoundConstructor
public FluentSetter() {}

/**
* WIP This tests passes in stapler, bad fluent doesn't work in jenkins...
* @see FluentPropertyBeanIntrospector
*
* It is also possible to transform it to `withXXX()` to have clear vision.
*/
@DataBoundSetter
// public void setItems(List<String> items) {
public FluentSetter setItems(List<String> items) {
this.items = items;
return this;
}

public List<String> getItems() {
return items;
}
}


public void testFluentSetter() {
FluentSetter fl = bind("{items : 'someItem'}", FluentSetter.class);
assertEquals(Arrays.asList("someItem"), fl.getItems());
}
}

0 comments on commit e2da85b

Please sign in to comment.