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: