From c3d954af42daedd9b172bb0a204294eb71c7d9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Westk=C3=A4mper?= Date: Tue, 21 Sep 2010 16:38:09 +0000 Subject: [PATCH] fixed tests --- .../mysema/query/scala/DumpClassTest.scala | 52 ++++------- .../query/scala/JPAIntegrationTest.scala | 89 ++++++++----------- 2 files changed, 53 insertions(+), 88 deletions(-) diff --git a/querydsl-scala/src/test/scala/com/mysema/query/scala/DumpClassTest.scala b/querydsl-scala/src/test/scala/com/mysema/query/scala/DumpClassTest.scala index 1de7e0584..5f7edf4ee 100644 --- a/querydsl-scala/src/test/scala/com/mysema/query/scala/DumpClassTest.scala +++ b/querydsl-scala/src/test/scala/com/mysema/query/scala/DumpClassTest.scala @@ -3,6 +3,8 @@ package com.mysema.query.scala import com.mysema.query.jpa.impl.JPAQuery import com.mysema.query.scala.Conversions._ +import com.mysema.query.annotations._ + import javax.persistence._; import org.junit.{Test,Before,After}; import org.junit.Assert._ @@ -15,7 +17,7 @@ class DumpClassTest { @Test def test(){ - List(classOf[U], classOf[D], classOf[C]).foreach(cl => + List(classOf[Class1], classOf[Class2]).foreach(cl => { println(cl.getName); cl.getDeclaredFields.foreach( f => { @@ -33,39 +35,17 @@ class DumpClassTest { } } -@Entity -class U( @BeanProperty @Id var id: Integer, - @BeanProperty var userName: String, - @BeanProperty @ManyToOne var department: Department) - -@Entity -class D( - - @BeanProperty - @Id - var id: Integer, - - @BeanProperty - var name: String, - - @ManyToOne - @BeanProperty - var company: C +@QueryEntity +class Class1( + @BeanProperty @Id var id: Integer, + @BeanProperty var str: String, + @BeanProperty @ManyToOne var manyToOne: Class1 ) - -@Entity -class C ( - - @BeanProperty - @Id - var id : Integer, - - @BeanProperty - var name: String, - - @BeanProperty - @OneToMany(mappedBy="company") - var departments: java.util.Set[D] - - -) \ No newline at end of file + + +@QueryEntity +class Class2 { + @BeanProperty @Id var id: Integer = _; + @BeanProperty var str: Class2 = _; + @BeanProperty @ManyToOne var manyToOne: Class2 = _ +} diff --git a/querydsl-scala/src/test/scala/com/mysema/query/scala/JPAIntegrationTest.scala b/querydsl-scala/src/test/scala/com/mysema/query/scala/JPAIntegrationTest.scala index a50b07fd4..e0f06f15a 100644 --- a/querydsl-scala/src/test/scala/com/mysema/query/scala/JPAIntegrationTest.scala +++ b/querydsl-scala/src/test/scala/com/mysema/query/scala/JPAIntegrationTest.scala @@ -18,27 +18,27 @@ class JPAIntegrationTest { var entityManagerFactory = Persistence.createEntityManagerFactory("hsqldb"); entityManager = entityManagerFactory.createEntityManager(); - val company = new Company(1, "Example", null); -// company.name = "Example"; -// company.id = 1; + val company = new Company(); + company.name = "Example"; + company.id = 1; - val department1 = new Department(2, "HR", company); -// department1.id = 2; -// department1.name = "HR"; -// department1.company = company; - val department2 = new Department(3, "Sales", company); -// department2.id = 3; -// department2.name = "Sales"; -// department2.company = company; + val department1 = new Department(); + department1.id = 2; + department1.name = "HR"; + department1.company = company; + val department2 = new Department(); + department2.id = 3; + department2.name = "Sales"; + department2.company = company; - val user1 = new User(4, "Bob", department1); - val user2 = new User(5, "Ann", department2); -// user1.id = 4; -// user2.id = 5; -// user1.userName = "Bob"; -// user2.userName = "Ann"; -// user1.department = department1; -// user2.department = department2; + val user1 = new User(); + val user2 = new User(); + user1.id = 4; + user2.id = 5; + user1.userName = "Bob"; + user2.userName = "Ann"; + user1.department = department1; + user2.department = department2; entityManager.getTransaction().begin(); @@ -67,8 +67,8 @@ class JPAIntegrationTest { entityManager.flush(); assertEquals(2, query from user list user size); - assertEquals(2, query from department list user size); - assertEquals(1, query from company list user size); + assertEquals(2, query from department list department size); + assertEquals(1, query from company list company size); assertEquals("Bob", query from user where (user.userName $eq "Bob") uniqueResult user.userName); assertEquals("Bob", query from user where (user.userName $like "Bo%") uniqueResult user.userName); @@ -80,38 +80,23 @@ class JPAIntegrationTest { } @Entity -class User(@BeanProperty @Id var id: Integer, - @BeanProperty var userName: String, - @BeanProperty @ManyToOne var department: Department) +class User { + @BeanProperty @Id var id: Integer = _; + @BeanProperty var userName: String = _; + @BeanProperty @ManyToOne var department: Department = _; +} @Entity -class Department( - - @BeanProperty - @Id - var id: Integer, - - @BeanProperty - var name: String, - - @ManyToOne - @BeanProperty - var company: Company -) +class Department { + @BeanProperty @Id var id: Integer = _; + @BeanProperty var name: String = _; + @BeanProperty @ManyToOne var company: Company = _; +} @Entity -class Company ( - - @BeanProperty - @Id - var id : Integer, - - @BeanProperty - var name: String, - - @BeanProperty - @OneToMany(mappedBy="company") - var departments: java.util.Set[Department] - - -) \ No newline at end of file +class Company { + @BeanProperty @Id var id : Integer = _; + @BeanProperty var name: String = _; + @BeanProperty @OneToMany(mappedBy="company") + var departments: java.util.Set[Department] = _; +}