@@ -29,7 +29,6 @@ public class FooServiceSortingTests {
2929
3030 @ BeforeClass
3131 public static void before () {
32-
3332 emf = Persistence .createEntityManagerFactory ("punit" );
3433 entityManager = emf .createEntityManager ();
3534 entityTransaction = entityManager .getTransaction ();
@@ -39,43 +38,36 @@ public static void before() {
3938
4039 @ Test
4140 public final void whenSortingByOneAttributeDefaultOrder_thenPrintSortedResult () {
42-
4341 final String jql = "Select f from Foo as f order by f.id" ;
4442 final Query sortQuery = entityManager .createQuery (jql );
4543 final List <Foo > fooList = sortQuery .getResultList ();
4644 for (final Foo foo : fooList ) {
4745 System .out .println ("Name:" + foo .getName () + "-------Id:" + foo .getId ());
4846 }
49-
5047 }
5148
5249 @ Test
5350 public final void whenSortingByOneAttributeSetOrder_thenSortedPrintResult () {
54-
5551 final String jql = "Select f from Foo as f order by f.id desc" ;
5652 final Query sortQuery = entityManager .createQuery (jql );
5753 final List <Foo > fooList = sortQuery .getResultList ();
5854 for (final Foo foo : fooList ) {
5955 System .out .println ("Name:" + foo .getName () + "-------Id:" + foo .getId ());
6056 }
61-
6257 }
6358
6459 @ Test
6560 public final void whenSortingByTwoAttributes_thenPrintSortedResult () {
66-
6761 final String jql = "Select f from Foo as f order by f.name asc, f.id desc" ;
6862 final Query sortQuery = entityManager .createQuery (jql );
6963 final List <Foo > fooList = sortQuery .getResultList ();
7064 for (final Foo foo : fooList ) {
7165 System .out .println ("Name:" + foo .getName () + "-------Id:" + foo .getId ());
7266 }
73-
7467 }
7568
7669 @ Test
7770 public final void whenSortingFooByBar_thenBarsSorted () {
78-
7971 final String jql = "Select f from Foo as f order by f.name, f.bar.id" ;
8072 final Query barJoinQuery = entityManager .createQuery (jql );
8173 final List <Foo > fooList = barJoinQuery .getResultList ();
@@ -86,7 +78,6 @@ public final void whenSortingFooByBar_thenBarsSorted() {
8678
8779 @ Test
8880 public final void whenSortinfBar_thenPrintBarsSortedWithFoos () {
89-
9081 final String jql = "Select b from Bar as b order by b.id" ;
9182 final Query barQuery = entityManager .createQuery (jql );
9283 final List <Bar > barList = barQuery .getResultList ();
@@ -96,12 +87,10 @@ public final void whenSortinfBar_thenPrintBarsSortedWithFoos() {
9687 System .out .println ("FooName:" + foo .getName ());
9788 }
9889 }
99-
10090 }
10191
10292 @ Test
10393 public final void whenSortingByStringNullLast_thenLastNull () {
104-
10594 final String jql = "Select f from Foo as f order by f.name desc NULLS LAST" ;
10695 final Query sortQuery = entityManager .createQuery (jql );
10796 final List <Foo > fooList = sortQuery .getResultList ();
@@ -113,7 +102,6 @@ public final void whenSortingByStringNullLast_thenLastNull() {
113102
114103 @ Test
115104 public final void whenSortingByStringNullFirst_thenFirstNull () {
116-
117105 final Foo nullNameFoo = new Foo ();
118106 nullNameFoo .setName (null );
119107
@@ -137,7 +125,6 @@ public final void whenSortingByStringNullFirst_thenFirstNull() {
137125
138126 @ Test
139127 public final void whenSortingFooWithCriteria_thenPrintSortedFoos () {
140-
141128 criteriaBuilder = entityManager .getCriteriaBuilder ();
142129 final CriteriaQuery <Foo > criteriaQuery = criteriaBuilder .createQuery (Foo .class );
143130 final Root <Foo > from = criteriaQuery .from (Foo .class );
@@ -148,12 +135,10 @@ public final void whenSortingFooWithCriteria_thenPrintSortedFoos() {
148135 for (final Foo foo : fooList ) {
149136 System .out .println ("Name:" + foo .getName () + "--------Id:" + foo .getId ());
150137 }
151-
152138 }
153139
154140 @ Test
155141 public final void whenSortingFooWithCriteriaAndMultipleAttributes_thenPrintSortedFoos () {
156-
157142 criteriaBuilder = entityManager .getCriteriaBuilder ();
158143 final CriteriaQuery <Foo > criteriaQuery = criteriaBuilder .createQuery (Foo .class );
159144 final Root <Foo > from = criteriaQuery .from (Foo .class );
0 commit comments