Christian,
Thanks for the answer! I¹ve looked through our code and it seems like a
solution.
Regards, Eugene
On 12/7/06 7:28 PM, "Christian Pekeler" <[EMAIL PROTECTED]> wrote:
>> > EOEnterpriseObjectClazz.objectWithPrimaryKeyValue(ec, pk);
>> > or
>> > EOUtilities.objectWithPrimaryKeyValue(ec, entity, pk);
>> >
>> > These methods create qualifiers against primary key attribute which
>> > is not selected as a class property in model.
>
> Why do you fetch objects by their primary key? I don't mean to sound
> condescending, but I don't think I've ever had to do this in my 8
> years of working with WO.
>
> Anyways, the MockEditingContext is meant for testing in memory. It
> can't handle hard-coded sql, raw rows, or access to non-property
> attributes. One way around this is to factor out any such code into
> extra methods and stub them out for unit testing. For example:
>
> public class Blah {
>
> public String foo() {
> ...
> ... someEO();
> ...
> }
>
> protected SomeEO someEO() {
> return (SomeEO)EOUtilities.objectWithPrimaryKeyValue(...);
> }
> }
>
> public class BlahTest {
>
> static class TestBlah extends Blah {
> SomeEO someEO;
> @Override
> protected SomeEO someEO() {
> return someEO;
> }
> }
>
> @Test
> public void foo() {
> TestBlah blah = new TestBlah();
> blah.someEO = mockEditingContext().createSavedObject(SomeEO.class);
> assertEquals("...", blah.foo());
> }
>
> }
>
> Christian
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/vesper%40mactime.ru
>
> This email sent to [EMAIL PROTECTED]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]