You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2021/11/19 14:57:01 UTC

[cayenne] branch master updated: CAY-2723 Phantom update of a to-dependent-pk relationship fix test

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 94503e5  CAY-2723 Phantom update of a to-dependent-pk relationship  fix test
94503e5 is described below

commit 94503e596845e95b98087a5f946223cad6d34b6d
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Fri Nov 19 17:56:55 2021 +0300

    CAY-2723 Phantom update of a to-dependent-pk relationship
     fix test
---
 .../test/java/org/apache/cayenne/access/CAY2723IT.java   | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/CAY2723IT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/CAY2723IT.java
index b337792..6444304 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/CAY2723IT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/CAY2723IT.java
@@ -25,6 +25,7 @@ import org.apache.cayenne.unit.di.DataChannelInterceptor;
 import org.apache.cayenne.unit.di.server.CayenneProjects;
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
+import org.junit.Before;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -37,6 +38,16 @@ public class CAY2723IT extends ServerCase {
     @Inject
     private DataChannelInterceptor queryInterceptor;
 
+    /**
+     * need to run this to ensure that PK generation doesn't affect main test
+     */
+    @Before
+    public void warmup() {
+        Painting painting = context.newObject(Painting.class);
+        painting.setPaintingTitle("test_warmup");
+        context.commitChanges();
+    }
+
     @Test
     public void phantomToDepPKUpdate() {
         Painting painting = context.newObject(Painting.class);
@@ -50,9 +61,8 @@ public class CAY2723IT extends ServerCase {
 
         context.deleteObject(paintingInfo);
 
-        // here should be only single insert of the painting object, but there will be 3 queries in total
-        // (2 for the PK generation + insert)
+        // here should be only single insert of the painting object
         int queryCounter = queryInterceptor.runWithQueryCounter(() -> context.commitChanges());
-        assertEquals(3, queryCounter);
+        assertEquals(1, queryCounter);
     }
 }