forked from playframework/play1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[playframework#878] Add OrderBy support in simplified queries
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package play.db.jpa; | ||
|
||
|
||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.util.Properties; | ||
import java.util.Set; | ||
|
||
import static play.db.jpa.JPQL.extractProp; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class JPQLTest { | ||
|
||
static JPQL jpql; | ||
|
||
@BeforeClass | ||
public static void setup(){ | ||
jpql = new JPQL(null); | ||
} | ||
|
||
@Test | ||
public void testOrder() { | ||
|
||
String query = "ByNameOrderByName"; | ||
String result = jpql.findByToJPQL(query); | ||
assertTrue(result.endsWith(" ORDER BY name")); | ||
|
||
query = "ByNameOrderByNameAndAge"; | ||
result = jpql.findByToJPQL(query); | ||
assertTrue(result.endsWith(" ORDER BY name, age")); | ||
|
||
query = "ByNameOrderByNameDesc"; | ||
result = jpql.findByToJPQL(query); | ||
assertTrue(result.endsWith(" ORDER BY name DESC")); | ||
|
||
query = "ByNameOrderByNameDescAndAge"; | ||
result = jpql.findByToJPQL(query); | ||
assertTrue(result.endsWith(" ORDER BY name DESC, age")); | ||
|
||
query = "ByNameOrderByNameAndAgeDesc"; | ||
result = jpql.findByToJPQL(query); | ||
assertTrue(result.endsWith(" ORDER BY name, age DESC")); | ||
|
||
query = "ByNameOrderByNameDescAndAgeDesc"; | ||
result = jpql.findByToJPQL(query); | ||
assertTrue(result.endsWith(" ORDER BY name DESC, age DESC")); | ||
|
||
} | ||
|
||
} |