This commit is contained in:
Timo Westkämper 2010-09-08 20:37:25 +00:00
parent 9679bd4be8
commit 76ee2d6690
5 changed files with 36 additions and 7 deletions

View File

@ -17,6 +17,8 @@ object Conversions {
def not(b: EBoolean): EBoolean = b.not()
implicit def _simple(s: Object): PSimple[_] = $(s);
implicit def _boolean(b: Boolean): PBoolean = $(b);
implicit def _string(s: String): PString = $(s);

View File

@ -2,6 +2,7 @@ package com.mysema.query.scala
import com.mysema.query.alias.Alias._
import com.mysema.query.types.path._
import com.mysema.query.sql.SQLSubQuery
import com.mysema.query.scala.Conversions._
@ -14,12 +15,12 @@ class AliasTest {
var domainType = alias(classOf[DomainType])
@Test
def test(){
def Explicit_Cast(){
assertEquals("domainType.firstName", $(domainType.firstName).toString);
}
@Test
def implicitDefs1(){
def Implicit_Cast1(){
var path: PString = domainType.firstName;
assertEquals("domainType.firstName like Hello", (path like "Hello").toString());
assertEquals("domainType.firstName ASC", (path asc).toString());
@ -28,7 +29,7 @@ class AliasTest {
}
@Test
def implicitDefs2(){
def Implicit_Cast2(){
assertEquals("domainType.firstName like Hello", (domainType.firstName like "Hello").toString());
assertEquals("domainType.firstName ASC", (domainType.firstName asc).toString());
@ -52,6 +53,32 @@ class AliasTest {
// assertEquals("domainType.firstName != Hello", (domainType.firstName ne "Hello").toString());
}
//@Test
def Expression_in_SubQuery(){
// list
query().from (domainType)
.where (domainType.firstName like "Rob%")
.orderBy (domainType.firstName asc)
.list ($(domainType)); // FIXME
// unique result
query().from (domainType)
.where (domainType.firstName like "Rob%")
.orderBy (domainType.firstName asc)
.unique ($(domainType)); // FIXME
// long where
query().from (domainType)
.where (
domainType.firstName like "Rob%",
domainType.lastName like "An%"
)
.orderBy (domainType.firstName asc)
.list ($(domainType)); // FIXME
}
def query() = new SQLSubQuery();
}
class DomainType {

View File

@ -11,7 +11,7 @@ class ExpressionTest {
var num = new PNumber(classOf[Integer],"num");
@Test
def operations(){
def Operations(){
// string
assertEquals("str = a", (str eq "a").toString);
assertEquals("str != a", (str ne "a").toString);

View File

@ -7,7 +7,7 @@ import org.junit.Assert._
class QuerySyntaxTest {
@Test
def querySyntax(){
def Query_Syntax(){
// select()
// .from(Category as "c" join (Book as "b"), Category as "c1")
// .where("c1.name" like "a%")
@ -29,7 +29,7 @@ class QuerySyntaxTest {
}
@Test
def keyUsage(){
def Key_Usage(){
val user = new QUser("user");
val user2 = new QUser("user2");
val department = new QDepartment("department");

View File

@ -50,7 +50,7 @@ class ScalaBeanSerializerTest {
@Test
@throws(classOf[java.io.IOException])
def test(){
def Print(){
var serializer = new ScalaBeanSerializer();
serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new ScalaWriter(writer));
var str = writer.toString();