Skip to content

Commit 9d9dada

Browse files
committed
HHH-19916 More drop JUnit 4 usage work
1 parent 514fdfa commit 9d9dada

File tree

5 files changed

+1048
-1172
lines changed

5 files changed

+1048
-1172
lines changed

hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/DerbyDialectTestCase.java

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,22 @@
44
*/
55
package org.hibernate.community.dialect;
66

7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.GeneratedValue;
9+
import jakarta.persistence.Id;
10+
import jakarta.persistence.Table;
11+
import jakarta.persistence.UniqueConstraint;
712
import org.hibernate.orm.test.dialect.LimitQueryOptions;
813
import org.hibernate.query.spi.Limit;
9-
10-
import static org.junit.Assert.assertEquals;
11-
1214
import org.hibernate.testing.orm.junit.DomainModel;
1315
import org.hibernate.testing.orm.junit.JiraKey;
1416
import org.hibernate.testing.orm.junit.RequiresDialect;
1517
import org.hibernate.testing.orm.junit.SessionFactory;
1618
import org.hibernate.testing.orm.junit.SessionFactoryScope;
17-
1819
import org.junit.jupiter.api.Assertions;
1920
import org.junit.jupiter.api.Test;
2021

21-
import jakarta.persistence.Entity;
22-
import jakarta.persistence.GeneratedValue;
23-
import jakarta.persistence.Id;
24-
import jakarta.persistence.Table;
25-
import jakarta.persistence.UniqueConstraint;
22+
import static org.assertj.core.api.Assertions.assertThat;
2623

2724
/**
2825
* Testing of patched support for Derby limit and offset queries; see HHH-3972
@@ -34,69 +31,74 @@
3431
public class DerbyDialectTestCase {
3532

3633
@Test
37-
@JiraKey( value = "HHH-3972" )
34+
@JiraKey(value = "HHH-3972")
3835
public void testInsertLimitClause(SessionFactoryScope scope) {
3936
final int limit = 50;
4037
final String input = "select * from tablename t where t.cat = 5";
4138
final String expected = "select * from tablename t where t.cat = 5 fetch first ? rows only";
4239

4340
final String actual = withLimit( input, toRowSelection( 0, limit ) );
44-
assertEquals( expected, actual );
41+
assertThat( actual ).isEqualTo( expected );
4542
}
4643

4744
@Test
48-
@JiraKey( value = "HHH-3972" )
45+
@JiraKey(value = "HHH-3972")
4946
public void testInsertLimitWithOffsetClause(SessionFactoryScope scope) {
5047
final int limit = 50;
5148
final int offset = 200;
5249
final String input = "select * from tablename t where t.cat = 5";
5350
final String expected = "select * from tablename t where t.cat = 5 offset ? rows fetch next ? rows only";
5451

5552
final String actual = withLimit( input, toRowSelection( offset, limit ) );
56-
assertEquals( expected, actual );
53+
assertThat( actual ).isEqualTo( expected );
5754
}
5855

5956
@Test
60-
@JiraKey( value = "HHH-3972" )
57+
@JiraKey(value = "HHH-3972")
6158
public void testInsertLimitWithForUpdateClause(SessionFactoryScope scope) {
6259
final int limit = 50;
6360
final int offset = 200;
6461
final String input = "select c11 as col1, c12 as col2, c13 as col13 from t1 for update of c11, c13";
6562
final String expected = "select c11 as col1, c12 as col2, c13 as col13 from t1 offset ? rows fetch next ? rows only for update of c11, c13";
6663

6764
final String actual = withLimit( input, toRowSelection( offset, limit ) );
68-
assertEquals( expected, actual );
65+
assertThat( actual ).isEqualTo( expected );
6966
}
7067

7168
@Test
72-
@JiraKey( value = "HHH-3972" )
69+
@JiraKey(value = "HHH-3972")
7370
public void testInsertLimitWithWithClause(SessionFactoryScope scope) {
7471
final int limit = 50;
7572
final int offset = 200;
7673
final String input = "select c11 as col1, c12 as col2, c13 as col13 from t1 where flight_id between 'AA1111' and 'AA1112' with rr";
7774
final String expected = "select c11 as col1, c12 as col2, c13 as col13 from t1 where flight_id between 'AA1111' and 'AA1112' offset ? rows fetch next ? rows only with rr";
7875

7976
final String actual = withLimit( input, toRowSelection( offset, limit ) );
80-
assertEquals( expected, actual );
77+
assertThat( actual ).isEqualTo( expected );
8178
}
8279

8380
@Test
84-
@JiraKey( value = "HHH-3972" )
81+
@JiraKey(value = "HHH-3972")
8582
public void testInsertLimitWithForUpdateAndWithClauses(SessionFactoryScope scope) {
8683
final int limit = 50;
8784
final int offset = 200;
8885
final String input = "select c11 as col1, c12 as col2, c13 as col13 from t1 where flight_id between 'AA1111' and 'AA1112' for update of c11,c13 with rr";
8986
final String expected = "select c11 as col1, c12 as col2, c13 as col13 from t1 where flight_id between 'AA1111' and 'AA1112' offset ? rows fetch next ? rows only for update of c11,c13 with rr";
9087

9188
final String actual = withLimit( input, toRowSelection( offset, limit ) );
92-
assertEquals( expected, actual );
89+
assertThat( actual ).isEqualTo( expected );
9390
}
94-
@RequiresDialect( DerbyDialect.class )
95-
@Test void testInsertConflictOnConstraintDoNothing(SessionFactoryScope scope) {
91+
92+
@RequiresDialect(DerbyDialect.class)
93+
@Test
94+
void testInsertConflictOnConstraintDoNothing(SessionFactoryScope scope) {
9695
scope.getSessionFactory().getSchemaManager().truncateMappedObjects();
97-
scope.inTransaction( s -> s.persist(new Constrained()));
98-
scope.inTransaction( s -> s.createMutationQuery("insert into Constrained(id, name, count) values (4,'Gavin',69) on conflict on constraint count_name_key do nothing").executeUpdate());
99-
scope.inSession( s -> Assertions.assertEquals( 69, s.createSelectionQuery( "select count from Constrained", int.class).getSingleResult()));
96+
scope.inTransaction( s -> s.persist( new Constrained() ) );
97+
scope.inTransaction( s -> s.createMutationQuery(
98+
"insert into Constrained(id, name, count) values (4,'Gavin',69) on conflict on constraint count_name_key do nothing" )
99+
.executeUpdate() );
100+
scope.inSession( s -> Assertions.assertEquals( 69,
101+
s.createSelectionQuery( "select count from Constrained", int.class ).getSingleResult() ) );
100102
}
101103

102104
private String withLimit(String sql, Limit limit) {
@@ -111,7 +113,7 @@ private Limit toRowSelection(int firstRow, int maxRows) {
111113
}
112114

113115
@Entity(name = "Constrained")
114-
@Table(uniqueConstraints = @UniqueConstraint(name = "count_name_key", columnNames = {"count","name"}))
116+
@Table(uniqueConstraints = @UniqueConstraint(name = "count_name_key", columnNames = {"count", "name"}))
115117
static class Constrained {
116118
@Id
117119
@GeneratedValue

0 commit comments

Comments
 (0)