inners[i] = inner;
}
}
public void testHigherOrderMethod()
throws Exception{
final Component c = Components.ctor(ArrayList.class, null);
testHigherOrderMethod(c);
testHigherOrderMethod(c.cast(null));
final Component nested = Components.ctor(MultiBean.class);
testHigherOrderMethod(
nested.bean(new String[]{"inner"})
.withProperty("inner",
Components.ctor(MultiBean.InnerBean.class)
)
.method("getInner").method("getList")
);
testHigherOrderMethod(
nested.cast(null).bean(new String[]{"inner"})
.withProperty("inner",
Components.ctor(MultiBean.InnerBean.class)
)
.method("getInner").method("getList")
);
testHigherOrderMethod(
nested.cast(null).bean(new String[]{"inner"})
.withProperty("inner",
Components.ctor(MultiBean.InnerBean.class)
)
.method("getInner").method("getListAsObject")
);
try{
testHigherOrderMethod(
nested.bean(new String[]{"inner"})
.withProperty("inner",
Components.ctor(MultiBean.InnerBean.class)
)
.method("getInner").method("getListAsObject")
);
fail("should have failed with IllegalArgumentException");
}
catch(IllegalArgumentException e){
assertEquals("method java.lang.Object.size not found", e.getMessage());
}
//test nested bean
testHigherOrderMethod(
nested.bean(new String[]{"inner"})
.withProperty("inner",
Components.ctor(MultiBean.InnerBean.class)
)
.getter("inner").getter("list")
);
testHigherOrderMethod(
nested.setter("inner")
.withArgument(0,
Components.ctor(MultiBean.InnerBean.class)
)
.getter("inner").getter("list")
);
testHigherOrderMethod(
nested.cast(null).bean(new String[]{"inner"})
.withProperty("inner",
Components.ctor(MultiBean.InnerBean.class)
)
.getter("inner").getter("list")
);
testHigherOrderMethod(
nested.cast(null).setter("inner")
.withArgument(0,
Components.ctor(MultiBean.InnerBean.class)
)
.getter("inner").getter("list")
);
try{
testHigherOrderMethod(
nested.bean(new String[]{"inner"})
.withProperty("inner",
Components.ctor(MultiBean.InnerBean.class)
)
.getter("inner").getter("listAsObject")
);
fail("should have failed with IllegalArgumentException");
}
catch(IllegalArgumentException e){
assertEquals("method java.lang.Object.size not found", e.getMessage());
}
testHigherOrderMethod(
nested.cast(null).bean(new String[]{"inner"})
.withProperty("inner",
Components.ctor(MultiBean.InnerBean.class)
)
.getter("innerAsObject").method("getListAsObject")
);
testHigherOrderMethod(
nested.cast(null).bean(new String[]{"inner"})
.withProperty("inner",
Components.ctor(MultiBean.InnerBean.class)
)
.getter("innerAsObject").getter("listAsObject")
);
try{
testHigherOrderMethod(
nested.bean(new String[]{"inner"})
.withProperty("inner",
Components.ctor(MultiBean.InnerBean.class)
)
.getter("innerAsObject").getter("list")
);