cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject cayenne git commit: cleanup
Date Sat, 07 Jul 2018 12:53:16 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 0bfc0f5e8 -> e980ed199


cleanup


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/e980ed19
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/e980ed19
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/e980ed19

Branch: refs/heads/master
Commit: e980ed19955e824a8a6b2a210cfffe569b4276d6
Parents: 0bfc0f5
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Sat Jul 7 15:53:03 2018 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Sat Jul 7 15:53:03 2018 +0300

----------------------------------------------------------------------
 .../cayenne/access/FlattenedPrefetchIT.java     | 144 +++++--------------
 .../cayenne/access/VerticalInheritanceIT.java   |  25 ++--
 2 files changed, 51 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/e980ed19/cayenne-server/src/test/java/org/apache/cayenne/access/FlattenedPrefetchIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/FlattenedPrefetchIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/access/FlattenedPrefetchIT.java
index 61d4c93..2541873 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/FlattenedPrefetchIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/FlattenedPrefetchIT.java
@@ -30,7 +30,6 @@ import org.apache.cayenne.testdo.testmap.ArtGroup;
 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.server.CayenneProjects;
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
@@ -115,108 +114,37 @@ public class FlattenedPrefetchIT extends ServerCase {
     public void testManyToMany() throws Exception {
         createPrefetchDataSet1();
 
-        SelectQuery q = new SelectQuery(Artist.class);
+        SelectQuery<Artist> q = new SelectQuery<>(Artist.class);
         q.addPrefetch(Artist.GROUP_ARRAY.disjoint());
 
-        final List<Artist> objects = context.performQuery(q);
+        List<Artist> objects = context.select(q);
 
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                assertEquals(3, objects.size());
-
-                for (Artist a : objects) {
-                    List<ArtGroup> list = a.getGroupArray();
-
-                    assertNotNull(list);
-                    assertFalse(
-                            "artist's groups not resolved: " + a,
-                            ((ValueHolder) list).isFault());
-                    assertTrue(list.size() > 0);
-
-                    for (ArtGroup g : list) {
-                        assertEquals(PersistenceState.COMMITTED, g.getPersistenceState());
-                    }
-
-                    // assert no duplicates
-                    Set<ArtGroup> s = new HashSet<ArtGroup>(list);
-                    assertEquals(s.size(), list.size());
-                }
-            }
-        });
+        queryInterceptor.runWithQueriesBlocked(() -> assertArtistResult(objects));
     }
 
     @Test
     public void testMultiPrefetch() throws Exception {
         createPrefetchDataSet2();
 
-        SelectQuery q = new SelectQuery(Painting.class);
+        SelectQuery<Painting> q = new SelectQuery<>(Painting.class);
         q.addPrefetch(Painting.TO_ARTIST.disjoint());
         q.addPrefetch(Painting.TO_ARTIST.dot(Artist.GROUP_ARRAY).disjoint());
 
-        final List<Painting> objects = context.performQuery(q);
-
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                assertEquals(3, objects.size());
-
-                for (Painting p : objects) {
-                    Artist a = p.getToArtist();
-                    assertEquals(PersistenceState.COMMITTED, a.getPersistenceState());
-
-                    List<ArtGroup> list = a.getGroupArray();
-                    assertNotNull(list);
-                    assertFalse(
-                            "artist's groups not resolved: " + a,
-                            ((ValueHolder) list).isFault());
-                    assertTrue(list.size() > 0);
-
-                    for (ArtGroup g : list) {
-                        assertEquals(PersistenceState.COMMITTED, g.getPersistenceState());
-                    }
+        List<Painting> objects = context.select(q);
 
-                    // assert no duplicates
-                    Set<ArtGroup> s = new HashSet<ArtGroup>(list);
-                    assertEquals(s.size(), list.size());
-                }
-            }
-        });
+        queryInterceptor.runWithQueriesBlocked(() -> assertPaintingResult(objects));
     }
 
     @Test
     public void testJointManyToMany() throws Exception {
         createPrefetchDataSet1();
 
-        SelectQuery q = new SelectQuery(Artist.class);
+        SelectQuery<Artist> q = new SelectQuery<>(Artist.class);
         q.addPrefetch(Artist.GROUP_ARRAY.joint());
 
-        final List<Artist> objects = context.performQuery(q);
+        List<Artist> objects = context.select(q);
 
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                assertEquals(3, objects.size());
-
-                for (Artist a : objects) {
-                    List<ArtGroup> list = a.getGroupArray();
-
-                    assertNotNull(list);
-                    assertFalse(
-                            "artist's groups not resolved: " + a,
-                            ((ValueHolder) list).isFault());
-                    assertTrue(list.size() > 0);
-
-                    for (ArtGroup g : list) {
-                        assertEquals(PersistenceState.COMMITTED, g.getPersistenceState());
-                    }
-
-                    // assert no duplicates
-                    Set<ArtGroup> s = new HashSet<ArtGroup>(list);
-                    assertEquals(s.size(), list.size());
-                }
-            }
-        });
+        queryInterceptor.runWithQueriesBlocked(() -> assertArtistResult(objects));
 
     }
 
@@ -224,38 +152,44 @@ public class FlattenedPrefetchIT extends ServerCase {
     public void testJointMultiPrefetch() throws Exception {
         createPrefetchDataSet2();
 
-        SelectQuery q = new SelectQuery(Painting.class);
+        SelectQuery<Painting> q = new SelectQuery<>(Painting.class);
         q.addPrefetch(Painting.TO_ARTIST.joint());
         q.addPrefetch(Painting.TO_ARTIST.dot(Artist.GROUP_ARRAY).joint());
 
-        final List<Painting> objects = context.performQuery(q);
+        List<Painting> objects = context.select(q);
 
-        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
-
-            public void execute() {
-                assertEquals(3, objects.size());
+        queryInterceptor.runWithQueriesBlocked(() -> assertPaintingResult(objects));
+    }
 
-                for (Painting p : objects) {
-                    Artist a = p.getToArtist();
-                    assertEquals(PersistenceState.COMMITTED, a.getPersistenceState());
+    private void assertArtistResult(List<Artist> objects) {
+        assertEquals(3, objects.size());
+        for (Artist a : objects) {
+            assertArtGroupResult(a.getGroupArray());
+        }
+    }
 
-                    List<ArtGroup> list = a.getGroupArray();
-                    assertNotNull(list);
-                    assertFalse(
-                            "artist's groups not resolved: " + a,
-                            ((ValueHolder) list).isFault());
-                    assertTrue(list.size() > 0);
+    private void assertPaintingResult(List<Painting> objects) {
+        assertEquals(3, objects.size());
+        for (Painting p : objects) {
+            Artist a = p.getToArtist();
+            assertEquals(PersistenceState.COMMITTED, a.getPersistenceState());
+            assertArtGroupResult(a.getGroupArray());
+        }
+    }
 
-                    for (ArtGroup g : list) {
-                        assertEquals(PersistenceState.COMMITTED, g.getPersistenceState());
-                    }
+    private void assertArtGroupResult(List<ArtGroup> list) {
+        assertNotNull(list);
+        assertFalse(
+                "artist's groups not resolved: ",
+                ((ValueHolder) list).isFault());
+        assertTrue(list.size() > 0);
 
-                    // assert no duplicates
+        for (ArtGroup g : list) {
+            assertEquals(PersistenceState.COMMITTED, g.getPersistenceState());
+        }
 
-                    Set<ArtGroup> s = new HashSet<ArtGroup>(list);
-                    assertEquals(s.size(), list.size());
-                }
-            }
-        });
+        // assert no duplicates
+        Set<ArtGroup> s = new HashSet<>(list);
+        assertEquals(s.size(), list.size());
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e980ed19/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
index cbdd8d4..c8d2077 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
@@ -31,7 +31,6 @@ import org.apache.cayenne.testdo.inheritance_vertical.*;
 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.Ignore;
 import org.junit.Test;
 
 import java.sql.SQLException;
@@ -201,7 +200,7 @@ public class VerticalInheritanceIT extends ServerCase {
 	 * @link https://issues.apache.org/jira/browse/CAY-2146
 	 */
     @Test(expected = org.apache.cayenne.validation.ValidationException.class)
-    public void testValidationOnInsert_Sub3_Exception() throws Exception {
+    public void testValidationOnInsert_Sub3_Exception() {
 
         TableHelper ivRootTable = new TableHelper(dbHelper, "IV_ROOT");
         ivRootTable.setColumns("ID", "NAME", "DISCRIMINATOR");
@@ -326,8 +325,8 @@ public class VerticalInheritanceIT extends ServerCase {
 		ivRootTable.insert(2, "xSUB1_ROOT", "IvSub1");
 		ivSub1Table.insert(2, "xSUB1");
 
-		SelectQuery query = new SelectQuery(IvRoot.class);
-		List<IvRoot> results = context.performQuery(query);
+		SelectQuery<IvRoot> query = new SelectQuery<>(IvRoot.class);
+		List<IvRoot> results = context.select(query);
 
 		assertEquals(2, results.size());
 
@@ -382,8 +381,8 @@ public class VerticalInheritanceIT extends ServerCase {
 		ivRootTable.insert(4, "xROOT_SUB2", "IvSub2");
 		ivSub2Table.insert(4, "xSUB2");
 
-		SelectQuery query = new SelectQuery(IvRoot.class);
-		List<IvRoot> results = context.performQuery(query);
+		SelectQuery<IvRoot> query = new SelectQuery<>(IvRoot.class);
+		List<IvRoot> results = context.select(query);
 
 		assertEquals(4, results.size());
 
@@ -452,8 +451,8 @@ public class VerticalInheritanceIT extends ServerCase {
 		ivRootTable.insert(4, "xROOT_SUB2", "IvSub2");
 		ivSub2Table.insert(4, "xSUB2");
 
-		SelectQuery query = new SelectQuery(IvSub1.class);
-		List<IvRoot> results = context.performQuery(query);
+		SelectQuery<IvSub1> query = new SelectQuery<>(IvSub1.class);
+		List<IvSub1> results = context.select(query);
 
 		assertEquals(2, results.size());
 
@@ -511,9 +510,9 @@ public class VerticalInheritanceIT extends ServerCase {
 		ivRootTable.insert(4, "xROOT_SUB2", "IvSub2");
 		ivSub2Table.insert(4, "xSUB2");
 
-		SelectQuery query = new SelectQuery(IvRoot.class);
+		SelectQuery<IvRoot> query = new SelectQuery<>(IvRoot.class);
 
-		List<IvRoot> results = context.performQuery(query);
+		List<IvRoot> results = context.select(query);
 
 		assertEquals(4, results.size());
 		Map<String, IvRoot> resultTypes = new HashMap<>();
@@ -537,7 +536,7 @@ public class VerticalInheritanceIT extends ServerCase {
 		assertEquals(1, ivSub1Sub1Table.getRowCount());
 		assertEquals(1, ivSub2Table.getRowCount());
 
-		results = context.performQuery(query);
+		results = context.select(query);
 		assertEquals(2, results.size());
 	}
 
@@ -556,8 +555,8 @@ public class VerticalInheritanceIT extends ServerCase {
 		iv1RootTable.insert(2, "xSUB1_ROOT", "Iv1Sub1");
 		iv1Sub1Table.insert(2, "xSUB1");
 
-		SelectQuery query = new SelectQuery(Iv1Root.class);
-		List<Iv1Root> results = context.performQuery(query);
+		SelectQuery<Iv1Root> query = new SelectQuery<>(Iv1Root.class);
+		List<Iv1Root> results = context.select(query);
 
 		assertEquals(2, results.size());
 


Mime
View raw message