Hi Paul, > Am 16.04.2016 um 00:55 schrieb Paul Hoadley <[email protected]>: > > 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:
that is annoying. I created a pull request to overcome this problem (https://github.com/wocommunity/wonder/pull/734). The goal was to try to stick to official Java API and cut down WO specific functions (dreaming of replacing WO specific classes with plain Java implementations ;-). Please have a look at it and check if that suits you. jw > > 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/ > > >
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ 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]
