Re: Unit testing FormComponentPanel

2014-08-07 Thread Martin Grigorov
Do you fire an Ajax call
with org.apache.wicket.util.tester.BaseWicketTester#executeBehavior(a
jaxFormChoiceComponentUpdatingBehavior) ?
This will simulate the click event on the radio element.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov


On Thu, Aug 7, 2014 at 10:03 AM, lucast  wrote:

> Thank you, Martin,
>
> I have implemented the solution, as suggested:
>
> wicketTester.getRequest().setParameter(""formComponentPanel:radioChoice"",
> ""value"")
>
>
> However, AjaxFormChoiceComponentUpdatingBehavior.onUpdate() (which I have
> added to radioChoice) does not behave as expected during test.
>
> Normally, inside of onUpdate() I obtain the value from radioChoice by
> calling radioChoice.getModelObject().
>
> However, when I execute
>
> radioChoice.getModelObject() returns null.
>
> From inside the test, the only way I can obtain a value from inside
> AjaxFormChoiceComponentUpdatingBehavior.onUpdate() is by calling
> radioChoice.getInput() which only returns a string.
>
> How can I get radioChoice.getModelObject()  to return a value from inside
> the test?
>
> I fear I am missing something really obvious in my tests.
>
> Thanks, once more,
> Lucas
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Unit-testing-FormComponentPanel-tp4666900p4666923.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Unit testing FormComponentPanel

2014-08-07 Thread lucast
Thank you, Martin,

I have implemented the solution, as suggested:

wicketTester.getRequest().setParameter(""formComponentPanel:radioChoice"",
""value"")


However, AjaxFormChoiceComponentUpdatingBehavior.onUpdate() (which I have
added to radioChoice) does not behave as expected during test.

Normally, inside of onUpdate() I obtain the value from radioChoice by
calling radioChoice.getModelObject().

However, when I execute

radioChoice.getModelObject() returns null. 

>From inside the test, the only way I can obtain a value from inside
AjaxFormChoiceComponentUpdatingBehavior.onUpdate() is by calling
radioChoice.getInput() which only returns a string.

How can I get radioChoice.getModelObject()  to return a value from inside
the test?

I fear I am missing something really obvious in my tests.

Thanks, once more,
Lucas


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unit-testing-FormComponentPanel-tp4666900p4666923.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Unit testing FormComponentPanel

2014-08-06 Thread lucast
Thank you, Martin.

I am able to successfully call 



but when I try to get hold of the object above in order to use it in
tester.executeAjaxEvent I get null value.

These are the calls I have used:


I'm terribly sorry but what would be the function I need to execute to get
hold of the object I need to pass to tester.executeAjaxEvent(), please?

Thanks, once more,
Lucas



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unit-testing-FormComponentPanel-tp4666900p4666914.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Unit testing FormComponentPanel

2014-08-06 Thread Martin Grigorov
Hi,

FormTester#setValue() just sets parameters in the request.
So you can do something similar:

tester.getRequest().add/setParameter(formComponent.getInputName(),
"someValue");
// ... more params
tester.executeAjaxEvent(someComponent, "eventName")

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov


On Wed, Aug 6, 2014 at 1:38 PM, lucast  wrote:

> Dear Forum,
> I am trying to unit test a FormComponentPanel. I would like to populate its
> fields and test some ajax behaviour as well.
>
> Is it possible to test a FormComponentPanel and its behaviour in isolation
> and not as part of a form?
>
> How can this be achieved? For testing a form, I call
>
>
> Is there a similar call I can use to test FormComponentPanel?
>
> Thanks in advance,
> Lucas
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Unit-testing-FormComponentPanel-tp4666900.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Unit testing FormComponentPanel

2014-08-06 Thread lucast
Dear Forum,
I am trying to unit test a FormComponentPanel. I would like to populate its
fields and test some ajax behaviour as well.

Is it possible to test a FormComponentPanel and its behaviour in isolation
and not as part of a form?

How can this be achieved? For testing a form, I call


Is there a similar call I can use to test FormComponentPanel?

Thanks in advance,
Lucas

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Unit-testing-FormComponentPanel-tp4666900.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org