This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git

commit abaf739a91ca6262b359c0596626e25d2541781d
Author: Andrus Adamchik <[email protected]>
AuthorDate: Thu May 14 10:40:24 2026 -0400

    tests cleanup - unwinding DI
---
 .../cayenne/access/DataContextLocalObjectIT.java   |  74 +++++-------
 .../DataContextObjectIdQuery_PolymorphicIT.java    |  59 ++++------
 ...DataContextRelationshipQuery_PolymorphicIT.java |  26 +----
 .../cayenne/unit/di/DataChannelInterceptor.java    |   4 +-
 .../apache/cayenne/unit/di/UnitTestClosure.java    |  24 ----
 .../runtime/RuntimeCaseDataChannelInterceptor.java |   9 +-
 .../cayenne/util/ShallowMergeOperationIT.java      | 126 ++++++++++-----------
 7 files changed, 116 insertions(+), 206 deletions(-)

diff --git 
a/cayenne/src/test/java/org/apache/cayenne/access/DataContextLocalObjectIT.java 
b/cayenne/src/test/java/org/apache/cayenne/access/DataContextLocalObjectIT.java
index d9d0d1dc0..085b45c29 100644
--- 
a/cayenne/src/test/java/org/apache/cayenne/access/DataContextLocalObjectIT.java
+++ 
b/cayenne/src/test/java/org/apache/cayenne/access/DataContextLocalObjectIT.java
@@ -26,18 +26,13 @@ import org.apache.cayenne.runtime.CayenneRuntime;
 import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.unit.di.DataChannelInterceptor;
-import org.apache.cayenne.unit.di.UnitTestClosure;
 import org.apache.cayenne.unit.di.runtime.CayenneProjects;
 import org.apache.cayenne.unit.di.runtime.CayenneTestsEnv;
 import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.extension.RegisterExtension;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNotSame;
-import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.*;
 
 public class DataContextLocalObjectIT  {
 
@@ -72,13 +67,10 @@ public class DataContextLocalObjectIT  {
         final Artist a1 = Cayenne.objectForPK(context1, Artist.class, 456);
         final Artist a2 = Cayenne.objectForPK(context2, Artist.class, 456);
 
-        interceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                Artist a3 = context2.localObject(a1);
-                assertSame(a3, a2);
-                assertSame(context2, a3.getObjectContext());
-            }
+        interceptor.runWithQueriesBlocked(() -> {
+            Artist a3 = context2.localObject(a1);
+            assertSame(a3, a2);
+            assertSame(context2, a3.getObjectContext());
         });
     }
 
@@ -88,12 +80,9 @@ public class DataContextLocalObjectIT  {
 
         final Artist a1 = Cayenne.objectForPK(context1, Artist.class, 456);
 
-        interceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                Artist a2 = context1.localObject(a1);
-                assertSame(a2, a1);
-            }
+        interceptor.runWithQueriesBlocked(() -> {
+            Artist a2 = context1.localObject(a1);
+            assertSame(a2, a1);
         });
     }
 
@@ -103,14 +92,11 @@ public class DataContextLocalObjectIT  {
 
         final Artist a1 = Cayenne.objectForPK(context1, Artist.class, 456);
 
-        interceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                Artist a3 = context2.localObject(a1);
-                assertNotSame(a3, a1);
-                assertEquals(a3.getObjectId(), a1.getObjectId());
-                assertSame(context2, a3.getObjectContext());
-            }
+        interceptor.runWithQueriesBlocked(() -> {
+            Artist a3 = context2.localObject(a1);
+            assertNotSame(a3, a1);
+            assertEquals(a3.getObjectId(), a1.getObjectId());
+            assertSame(context2, a3.getObjectContext());
         });
     }
 
@@ -133,40 +119,34 @@ public class DataContextLocalObjectIT  {
     }
 
     @Test
-    public void localObject_TempId() throws Exception {
+    public void localObject_TempId() {
 
         final Artist a1 = context1.newObject(Artist.class);
 
-        interceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
+        interceptor.runWithQueriesBlocked(() -> {
 
-                Artist a = context2.localObject(a1);
-                assertNotNull(a);
-                assertEquals(a1.getObjectId(), a.getObjectId());
+            Artist a = context2.localObject(a1);
+            assertNotNull(a);
+            assertEquals(a1.getObjectId(), a.getObjectId());
 
-                // FFE must be thrown on attempt to read non-existing temp ID
-                assertThrows(FaultFailureException.class, a::getArtistName);
-            }
+            // FFE must be thrown on attempt to read non-existing temp ID
+            assertThrows(FaultFailureException.class, a::getArtistName);
         });
     }
 
     @Test
-    public void localObject_TempId_NestedContext() throws Exception {
+    public void localObject_TempId_NestedContext() {
 
         final Artist a1 = context1.newObject(Artist.class);
 
         final ObjectContext nestedContext = runtime.newContext(context1);
 
-        interceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
+        interceptor.runWithQueriesBlocked(() -> {
 
-                Artist a3 = nestedContext.localObject(a1);
-                assertNotSame(a3, a1);
-                assertEquals(a3.getObjectId(), a1.getObjectId());
-                assertSame(nestedContext, a3.getObjectContext());
-            }
+            Artist a3 = nestedContext.localObject(a1);
+            assertNotSame(a3, a1);
+            assertEquals(a3.getObjectId(), a1.getObjectId());
+            assertSame(nestedContext, a3.getObjectContext());
         });
     }
 }
diff --git 
a/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectIdQuery_PolymorphicIT.java
 
b/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectIdQuery_PolymorphicIT.java
index 61be30cd6..054477b02 100644
--- 
a/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectIdQuery_PolymorphicIT.java
+++ 
b/cayenne/src/test/java/org/apache/cayenne/access/DataContextObjectIdQuery_PolymorphicIT.java
@@ -27,7 +27,6 @@ import 
org.apache.cayenne.testdo.inheritance_people.AbstractPerson;
 import org.apache.cayenne.testdo.inheritance_people.Employee;
 import org.apache.cayenne.testdo.inheritance_people.Manager;
 import org.apache.cayenne.unit.di.DataChannelInterceptor;
-import org.apache.cayenne.unit.di.UnitTestClosure;
 import org.apache.cayenne.unit.di.runtime.PeopleProjectCase;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -35,7 +34,7 @@ import org.junit.jupiter.api.Test;
 import java.sql.SQLException;
 import java.sql.Types;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 public class DataContextObjectIdQuery_PolymorphicIT extends PeopleProjectCase {
 
@@ -65,21 +64,17 @@ public class DataContextObjectIdQuery_PolymorphicIT extends 
PeopleProjectCase {
                                ObjectIdQuery.CACHE);
 
                AbstractPerson ap1 = (AbstractPerson) 
Cayenne.objectForQuery(context1, q1);
-               assertTrue(ap1 instanceof Manager);
+        assertInstanceOf(Manager.class, ap1);
 
-               queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-                       @Override
-                       public void execute() {
-                               // use different context to ensure we hit 
shared cache
-                               AbstractPerson ap2 = (AbstractPerson) 
Cayenne.objectForQuery(context2, q1);
-                               assertTrue(ap2 instanceof Manager);
-                       }
-               });
+               queryInterceptor.runWithQueriesBlocked(() -> {
+            // use different context to ensure we hit shared cache
+            AbstractPerson ap2 = (AbstractPerson) 
Cayenne.objectForQuery(context2, q1);
+            assertInstanceOf(Manager.class, ap2);
+        });
        }
 
        @Test
-       public void polymorphicSharedCache_AfterCayenneInsert() throws 
SQLException {
+       public void polymorphicSharedCache_AfterCayenneInsert() {
 
 
                // see CAY-2101... we are trying to get a snapshot from a new 
object in the shared cache, and then read this
@@ -97,15 +92,11 @@ public class DataContextObjectIdQuery_PolymorphicIT extends 
PeopleProjectCase {
                                ObjectIdQuery.CACHE);
 
 
-               queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-                       @Override
-                       public void execute() {
-                               // use different context to ensure we hit 
shared cache
-                               AbstractPerson ap1 = (AbstractPerson) 
Cayenne.objectForQuery(context2, q1);
-                               assertTrue(ap1 instanceof Employee);
-                       }
-               });
+               queryInterceptor.runWithQueriesBlocked(() -> {
+            // use different context to ensure we hit shared cache
+            AbstractPerson ap1 = (AbstractPerson) 
Cayenne.objectForQuery(context2, q1);
+            assertInstanceOf(Employee.class, ap1);
+        });
        }
 
        @Test
@@ -117,19 +108,15 @@ public class DataContextObjectIdQuery_PolymorphicIT 
extends PeopleProjectCase {
                                ObjectIdQuery.CACHE);
 
                AbstractPerson ap1 = (AbstractPerson) 
Cayenne.objectForQuery(context1, q1);
-               assertTrue(ap1 instanceof Manager);
-
-               queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-                       @Override
-                       public void execute() {
-                               // use same context to ensure we hit local cache
-                               // note that this does not guarantee test 
correctness. If local
-                               // cache polymorphic ID lookup is broken, 
shared cache will pick
-                               // it up
-                               AbstractPerson ap2 = (AbstractPerson) 
Cayenne.objectForQuery(context1, q1);
-                               assertTrue(ap2 instanceof Manager);
-                       }
-               });
+        assertInstanceOf(Manager.class, ap1);
+
+               queryInterceptor.runWithQueriesBlocked(() -> {
+            // use same context to ensure we hit local cache
+            // note that this does not guarantee test correctness. If local
+            // cache polymorphic ID lookup is broken, shared cache will pick
+            // it up
+            AbstractPerson ap2 = (AbstractPerson) 
Cayenne.objectForQuery(context1, q1);
+            assertInstanceOf(Manager.class, ap2);
+        });
        }
 }
diff --git 
a/cayenne/src/test/java/org/apache/cayenne/access/DataContextRelationshipQuery_PolymorphicIT.java
 
b/cayenne/src/test/java/org/apache/cayenne/access/DataContextRelationshipQuery_PolymorphicIT.java
index d4e5dc686..8f7114590 100644
--- 
a/cayenne/src/test/java/org/apache/cayenne/access/DataContextRelationshipQuery_PolymorphicIT.java
+++ 
b/cayenne/src/test/java/org/apache/cayenne/access/DataContextRelationshipQuery_PolymorphicIT.java
@@ -20,44 +20,30 @@
 package org.apache.cayenne.access;
 
 import org.apache.cayenne.Cayenne;
-import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.testdo.inheritance_people.Employee;
 import org.apache.cayenne.testdo.inheritance_people.PersonNotes;
 import org.apache.cayenne.unit.di.DataChannelInterceptor;
-import org.apache.cayenne.unit.di.UnitTestClosure;
 import org.apache.cayenne.unit.di.runtime.PeopleProjectCase;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import java.sql.SQLException;
-import java.sql.Types;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
 public class DataContextRelationshipQuery_PolymorphicIT extends 
PeopleProjectCase {
 
         private DataContext context1;
-
         private DataContext context2;
-
         private DataChannelInterceptor queryInterceptor;
 
-    private TableHelper tPerson;
-    private TableHelper tPersonNotes;
-
     @BeforeEach
     public void before() {
         context1 = env.context();
         context2 = (DataContext) env.runtime().newContext();
         queryInterceptor = env.dataChannelInterceptor();
-        tPerson = new TableHelper(dbHelper, "PERSON").setColumns("PERSON_ID", 
"NAME", "PERSON_TYPE")
-                .setColumnTypes(Types.INTEGER, Types.VARCHAR, Types.CHAR);
-
-        tPersonNotes = new TableHelper(dbHelper, 
"PERSON_NOTES").setColumns("ID", "PERSON_ID", "NOTES");
     }
 
     @Test
-    public void polymorphicSharedCache() throws SQLException {
+    public void polymorphicSharedCache() {
 
 
         // see CAY-2101... we are trying to get a snapshot from a new object 
in the shared cache, and then read this
@@ -74,12 +60,6 @@ public class DataContextRelationshipQuery_PolymorphicIT 
extends PeopleProjectCas
         // use different context to ensure we hit shared cache for 
relationship resolving
         final PersonNotes nPeer = Cayenne.objectForPK(context2, 
PersonNotes.class, Cayenne.intPKForObject(n));
 
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            @Override
-            public void execute() {
-                assertTrue(nPeer.getPerson() instanceof Employee);
-            }
-        });
+        queryInterceptor.runWithQueriesBlocked(() -> 
assertInstanceOf(Employee.class, nPeer.getPerson()));
     }
 }
diff --git 
a/cayenne/src/test/java/org/apache/cayenne/unit/di/DataChannelInterceptor.java 
b/cayenne/src/test/java/org/apache/cayenne/unit/di/DataChannelInterceptor.java
index 2925971e9..e7e8503cb 100644
--- 
a/cayenne/src/test/java/org/apache/cayenne/unit/di/DataChannelInterceptor.java
+++ 
b/cayenne/src/test/java/org/apache/cayenne/unit/di/DataChannelInterceptor.java
@@ -24,7 +24,7 @@ package org.apache.cayenne.unit.di;
  */
 public interface DataChannelInterceptor {
 
-    void runWithQueriesBlocked(UnitTestClosure closure);
+    void runWithQueriesBlocked(Runnable task);
 
-    int runWithQueryCounter(UnitTestClosure closure);
+    int runWithQueryCounter(Runnable task);
 }
diff --git 
a/cayenne/src/test/java/org/apache/cayenne/unit/di/UnitTestClosure.java 
b/cayenne/src/test/java/org/apache/cayenne/unit/di/UnitTestClosure.java
deleted file mode 100644
index 80dfdf4f9..000000000
--- a/cayenne/src/test/java/org/apache/cayenne/unit/di/UnitTestClosure.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    https://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.unit.di;
-
-public interface UnitTestClosure {
-
-    void execute();
-}
diff --git 
a/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseDataChannelInterceptor.java
 
b/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseDataChannelInterceptor.java
index e1432629f..07bd733e1 100644
--- 
a/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseDataChannelInterceptor.java
+++ 
b/cayenne/src/test/java/org/apache/cayenne/unit/di/runtime/RuntimeCaseDataChannelInterceptor.java
@@ -22,7 +22,6 @@ import org.apache.cayenne.access.UnitTestDomain;
 import org.apache.cayenne.di.Provider;
 import org.apache.cayenne.runtime.CayenneRuntime;
 import org.apache.cayenne.unit.di.DataChannelInterceptor;
-import org.apache.cayenne.unit.di.UnitTestClosure;
 
 public class RuntimeCaseDataChannelInterceptor implements 
DataChannelInterceptor {
 
@@ -33,7 +32,7 @@ public class RuntimeCaseDataChannelInterceptor implements 
DataChannelInterceptor
     }
 
     @Override
-    public void runWithQueriesBlocked(UnitTestClosure closure) {
+    public void runWithQueriesBlocked(Runnable task) {
 
         UnitTestDomain channel = (UnitTestDomain) runtimeProvider
                 .get()
@@ -41,7 +40,7 @@ public class RuntimeCaseDataChannelInterceptor implements 
DataChannelInterceptor
 
         channel.setBlockingQueries(true);
         try {
-            closure.execute();
+            task.run();
         }
         finally {
             channel.setBlockingQueries(false);
@@ -49,14 +48,14 @@ public class RuntimeCaseDataChannelInterceptor implements 
DataChannelInterceptor
     }
 
     @Override
-    public int runWithQueryCounter(UnitTestClosure closure) {
+    public int runWithQueryCounter(Runnable task) {
         UnitTestDomain channel = (UnitTestDomain) 
runtimeProvider.get().getChannel();
         RuntimeCaseDataNode node = 
(RuntimeCaseDataNode)channel.getDataNodes().iterator().next();
 
         int start = node.getQueriesCount();
         int end;
         try {
-            closure.execute();
+            task.run();
         } finally {
             end = node.getQueriesCount();
         }
diff --git 
a/cayenne/src/test/java/org/apache/cayenne/util/ShallowMergeOperationIT.java 
b/cayenne/src/test/java/org/apache/cayenne/util/ShallowMergeOperationIT.java
index d7a00c835..97d01cbdd 100644
--- a/cayenne/src/test/java/org/apache/cayenne/util/ShallowMergeOperationIT.java
+++ b/cayenne/src/test/java/org/apache/cayenne/util/ShallowMergeOperationIT.java
@@ -30,16 +30,13 @@ import org.apache.cayenne.test.jdbc.TableHelper;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.testdo.testmap.Painting;
 import org.apache.cayenne.unit.di.DataChannelInterceptor;
-import org.apache.cayenne.unit.di.UnitTestClosure;
 import org.apache.cayenne.unit.di.runtime.CayenneProjects;
 import org.apache.cayenne.unit.di.runtime.CayenneTestsEnv;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.*;
 
 public class ShallowMergeOperationIT {
 
@@ -69,7 +66,7 @@ public class ShallowMergeOperationIT {
     }
 
     @Test
-    public void merge_Relationship() throws Exception {
+    public void merge_Relationship() {
 
         ObjectContext childContext = runtime.newContext(context);
         final ShallowMergeOperation op = new 
ShallowMergeOperation(childContext);
@@ -78,17 +75,14 @@ public class ShallowMergeOperationIT {
         final Painting _newP = context.newObject(Painting.class);
         _new.addToPaintingArray(_newP);
 
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
+        queryInterceptor.runWithQueriesBlocked(() -> {
+            Painting painting = op.merge(_newP);
 
-            public void execute() {
-                Painting painting = op.merge(_newP);
-
-                assertEquals(PersistenceState.COMMITTED, 
painting.getPersistenceState());
-                assertNotNull(painting.getToArtist());
-                assertEquals(PersistenceState.COMMITTED, painting
-                        .getToArtist()
-                        .getPersistenceState());
-            }
+            assertEquals(PersistenceState.COMMITTED, 
painting.getPersistenceState());
+            assertNotNull(painting.getToArtist());
+            assertEquals(PersistenceState.COMMITTED, painting
+                    .getToArtist()
+                    .getPersistenceState());
         });
     }
 
@@ -119,17 +113,14 @@ public class ShallowMergeOperationIT {
         assertEquals(PersistenceState.MODIFIED, 
modified.getPersistenceState());
         assertEquals(PersistenceState.MODIFIED, 
peerModified.getPersistenceState());
 
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                Persistent peerModified2 = op.merge(modified);
-                assertSame(peerModified, peerModified2);
-                assertEquals(
-                        PersistenceState.MODIFIED,
-                        peerModified2.getPersistenceState());
-                assertEquals("M2", peerModified.getArtistName());
-                assertEquals("M1", modified.getArtistName());
-            }
+        queryInterceptor.runWithQueriesBlocked(() -> {
+            Persistent peerModified2 = op.merge(modified);
+            assertSame(peerModified, peerModified2);
+            assertEquals(
+                    PersistenceState.MODIFIED,
+                    peerModified2.getPersistenceState());
+            assertEquals("M2", peerModified.getArtistName());
+            assertEquals("M1", modified.getArtistName());
         });
     }
 
@@ -160,49 +151,46 @@ public class ShallowMergeOperationIT {
         assertEquals(PersistenceState.NEW, _new.getPersistenceState());
 
         // now check how objects in different state behave
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                Persistent newPeer = op.merge(_new);
-
-                assertEquals(_new.getObjectId(), newPeer.getObjectId());
-                assertEquals(PersistenceState.COMMITTED, 
newPeer.getPersistenceState());
-
-                assertSame(childContext, newPeer.getObjectContext());
-                assertSame(context, _new.getObjectContext());
-
-                Persistent hollowPeer = op.merge(hollow);
-                assertEquals(PersistenceState.HOLLOW, 
hollowPeer.getPersistenceState());
-                assertEquals(hollow.getObjectId(), hollowPeer.getObjectId());
-                assertSame(childContext, hollowPeer.getObjectContext());
-                assertSame(context, hollow.getObjectContext());
-
-                Persistent committedPeer = op.merge(committed);
-                assertEquals(
-                        PersistenceState.COMMITTED,
-                        committedPeer.getPersistenceState());
-                assertEquals(committed.getObjectId(), 
committedPeer.getObjectId());
-                assertSame(childContext, committedPeer.getObjectContext());
-                assertSame(context, committed.getObjectContext());
-
-                Artist modifiedPeer = op.merge(modified);
-                assertEquals(
-                        PersistenceState.COMMITTED,
-                        modifiedPeer.getPersistenceState());
-                assertEquals(modified.getObjectId(), 
modifiedPeer.getObjectId());
-                assertEquals("M1", modifiedPeer.getArtistName());
-                assertSame(childContext, modifiedPeer.getObjectContext());
-                assertSame(context, modified.getObjectContext());
-
-                Persistent deletedPeer = op.merge(deleted);
-                assertEquals(
-                        PersistenceState.COMMITTED,
-                        deletedPeer.getPersistenceState());
-                assertEquals(deleted.getObjectId(), deletedPeer.getObjectId());
-                assertSame(childContext, deletedPeer.getObjectContext());
-                assertSame(context, deleted.getObjectContext());
-
-            }
+        queryInterceptor.runWithQueriesBlocked(() -> {
+            Persistent newPeer = op.merge(_new);
+
+            assertEquals(_new.getObjectId(), newPeer.getObjectId());
+            assertEquals(PersistenceState.COMMITTED, 
newPeer.getPersistenceState());
+
+            assertSame(childContext, newPeer.getObjectContext());
+            assertSame(context, _new.getObjectContext());
+
+            Persistent hollowPeer = op.merge(hollow);
+            assertEquals(PersistenceState.HOLLOW, 
hollowPeer.getPersistenceState());
+            assertEquals(hollow.getObjectId(), hollowPeer.getObjectId());
+            assertSame(childContext, hollowPeer.getObjectContext());
+            assertSame(context, hollow.getObjectContext());
+
+            Persistent committedPeer = op.merge(committed);
+            assertEquals(
+                    PersistenceState.COMMITTED,
+                    committedPeer.getPersistenceState());
+            assertEquals(committed.getObjectId(), committedPeer.getObjectId());
+            assertSame(childContext, committedPeer.getObjectContext());
+            assertSame(context, committed.getObjectContext());
+
+            Artist modifiedPeer = op.merge(modified);
+            assertEquals(
+                    PersistenceState.COMMITTED,
+                    modifiedPeer.getPersistenceState());
+            assertEquals(modified.getObjectId(), modifiedPeer.getObjectId());
+            assertEquals("M1", modifiedPeer.getArtistName());
+            assertSame(childContext, modifiedPeer.getObjectContext());
+            assertSame(context, modified.getObjectContext());
+
+            Persistent deletedPeer = op.merge(deleted);
+            assertEquals(
+                    PersistenceState.COMMITTED,
+                    deletedPeer.getPersistenceState());
+            assertEquals(deleted.getObjectId(), deletedPeer.getObjectId());
+            assertSame(childContext, deletedPeer.getObjectContext());
+            assertSame(context, deleted.getObjectContext());
+
         });
     }
 }

Reply via email to