cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abulat...@apache.org
Subject [cayenne] branch master updated: CAY-2541 Add test.
Date Wed, 19 Jun 2019 08:22:49 GMT
This is an automated email from the ASF dual-hosted git repository.

abulatski 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 362c9bf  CAY-2541 Add test.
362c9bf is described below

commit 362c9bfa1e667ce871e1de83651fbd172995338d
Author: Arseni Bulatski <ancarseni@gmail.com>
AuthorDate: Wed Jun 19 11:17:48 2019 +0300

    CAY-2541 Add test.
---
 .../java/org/apache/cayenne/query/CAY2541IT.java   | 85 ++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/CAY2541IT.java b/cayenne-server/src/test/java/org/apache/cayenne/query/CAY2541IT.java
new file mode 100644
index 0000000..f996901
--- /dev/null
+++ b/cayenne-server/src/test/java/org/apache/cayenne/query/CAY2541IT.java
@@ -0,0 +1,85 @@
+/*****************************************************************
+ *   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.query;
+
+import java.util.List;
+
+import org.apache.cayenne.ObjectId;
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.exp.parser.ASTDbPath;
+import org.apache.cayenne.exp.parser.ASTEqual;
+import org.apache.cayenne.exp.parser.ASTScalar;
+import org.apache.cayenne.test.jdbc.DBHelper;
+import org.apache.cayenne.test.jdbc.TableHelper;
+import org.apache.cayenne.testdo.testmap.Artist;
+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;
+
+@UseServerRuntime(CayenneProjects.TESTMAP_PROJECT)
+public class CAY2541IT extends ServerCase {
+
+    @Inject
+    private DataContext context;
+
+    @Inject
+    private DBHelper dbHelper;
+
+    @Before
+    public void createArtistsDataSet() throws Exception {
+        TableHelper tArtist = new TableHelper(dbHelper, "ARTIST");
+        tArtist.setColumns("ARTIST_ID", "ARTIST_NAME", "DATE_OF_BIRTH");
+
+        long dateBase = System.currentTimeMillis();
+        for (int i = 1; i <= 20; i++) {
+            tArtist.insert(i, "artist" + i, new java.sql.Date(dateBase + 10000 * i));
+        }
+
+        TableHelper tGallery = new TableHelper(dbHelper, "GALLERY");
+        tGallery.setColumns("GALLERY_ID", "GALLERY_NAME");
+        tGallery.insert(1, "tate modern");
+
+        TableHelper tPaintings = new TableHelper(dbHelper, "PAINTING");
+        tPaintings.setColumns("PAINTING_ID", "PAINTING_TITLE", "ARTIST_ID", "GALLERY_ID");
+        for (int i = 1; i <= 20; i++) {
+            tPaintings.insert(i, "painting" + i, i % 5 + 1, 1);
+        }
+    }
+
+    @Test
+    public void testCay2541() {
+        ObjectId id = ObjectId.of("ARTIST", "ARTIST_ID", 1);
+        ASTDbPath astDbPath = new ASTDbPath("ARTIST_ID");
+        ASTScalar astScalar = new ASTScalar(id);
+        ASTEqual astEqual = new ASTEqual();
+        astEqual.setOperand(0, astDbPath);
+        astEqual.setOperand(1, astScalar);
+        List<Artist> artistList = ObjectSelect.query(Artist.class)
+                .where(astEqual)
+                .select(context);
+        assertEquals(1, artistList.size());
+        assertEquals("artist1", artistList.get(0).getArtistName());
+    }
+}


Mime
View raw message