Hi Johann,

On 15 Apr 2016, at 11:53 pm, Johann Werner <[email protected]> wrote:

> do you have an example where ERXEOControlUtilities.validateUniquenessOf() 
> does not work because of ERXArrayUtilities.arrayMinusObject()? What is the 
> exact error?

This is in the middle of a WOUnit test, so the error is that 
validateUniquenessOf() throws a “UniquenessViolationNewObject” because count == 
1 at line 2417. This test passes with Wonder 6, fails with Wonder 7.

> I doubt that object is not removed from the array, the only reason that comes 
> to my mind would be that the editing context of object and that of the array 
> are different so that equals() would return false but 
> ERXEOControlUtilities.validateUniquenessOf() uses the same editing context 
> for both params. Perhaps some other part is the cause of your problem?

I think I have narrowed it down: the behaviour of the old and new methods are 
different with respect to duplicate objects in the supplied array. 
Specifically, if the object to be removed is present more than once in the 
array, the old method removes all references to it, the new method removes a 
single reference to it. Here’s a demonstration:

public class ArrayTest {
        public static class Foo {
        }

        @Test
        public void arrayTest() {
                Foo a = new Foo();
                NSMutableArray<Foo> array = new NSMutableArray<Foo>();
                array.add(a);
                System.out.println("ArrayTest.arrayTest: array = " + array);
                array.add(a);
                System.out.println("ArrayTest.arrayTest: array = " + array);
                NSArray<Foo> result = ERXArrayUtilities.arrayMinusObject(array, 
a);
                System.out.println("ArrayTest.arrayTest: result = " + result);
                return;
        }
}

The old method gives this output:

ArrayTest.arrayTest: array = 
(net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca)
ArrayTest.arrayTest: array = 
(net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca, 
net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca)
ArrayTest.arrayTest: result = ()

and the new method gives this output:

ArrayTest.arrayTest: array = 
(net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca)
ArrayTest.arrayTest: array = 
(net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca, 
net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca)
ArrayTest.arrayTest: result = 
(net.logicsquad.feedback.tests.ArrayTest$Foo@1a93a7ca)

Again, I know we agreed that Wonder 7 need not maintain backwards compatibility 
(and I still support this), I wonder whether this particular behavioural change 
was intended, and whether we should think about reverting it. I haven’t tested 
ERXEOControlUtilities.validateUniquenessOf(), in particular, outside WOUnit, 
and I don’t know why the fetch at 2405 would bring in two copies of the same 
object, but it does in this test, and the old behaviour of arrayMinusObject() 
accounted for that.

What do you think?

And while we’re here:

>> 1. With the new method signature for arrayMinusArray(), WOUnit’s 
>> MockEditingContext can’t even find that method:
>> 
>> java.lang.NoSuchMethodError: 
>> er.extensions.foundation.ERXArrayUtilities.arrayMinusArray(Lcom/webobjects/foundation/NSArray;Lcom/webobjects/foundation/NSArray;)Lcom/webobjects/foundation/NSArray;
>>      at 
>> com.wounit.rules.MockEditingContext.saveChanges(MockEditingContext.java:310)
>> 
>> 
>> It’s not immediately clear to me why this would be the case, as obviously 
>> NSArray implements Collection, and the new signature is:
>> 
>> public static <T> NSArray<T> arrayMinusArray(Collection<T> array, 
>> Collection<?> minus)

Any thoughts on this one? It’s a bit of a show-stopper for WOUnit at the moment.


-- 
Paul Hoadley
http://logicsquad.net/



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to