File tree 10 files changed +313
-0
lines changed
hibernate-reactive-core/src/test/java/org/hibernate/reactive/annotations/tests 10 files changed +313
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* Hibernate, Relational Persistence for Idiomatic Java
2
+ *
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ * Copyright: Red Hat Inc. and Hibernate Authors
5
+ */
6
+ package org .hibernate .reactive .annotations .tests ;
7
+
8
+
9
+ import org .hibernate .reactive .BaseReactiveTest ;
10
+ import org .hibernate .reactive .annotations .DisableFor ;
11
+ import org .hibernate .reactive .containers .DatabaseConfiguration ;
12
+
13
+ import org .junit .jupiter .api .Test ;
14
+
15
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .POSTGRESQL ;
16
+ import static org .junit .jupiter .api .Assertions .assertNotEquals ;
17
+
18
+ @ DisableFor (value = POSTGRESQL , reason = "Reason #1" )
19
+ public class DisableForClassTest extends BaseReactiveTest {
20
+
21
+ @ Test
22
+ public void test () {
23
+ // Throw exception if this test is run with POSTGRESQL database
24
+ assertNotEquals ( POSTGRESQL , DatabaseConfiguration .dbType () );
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ /* Hibernate, Relational Persistence for Idiomatic Java
2
+ *
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ * Copyright: Red Hat Inc. and Hibernate Authors
5
+ */
6
+ package org .hibernate .reactive .annotations .tests ;
7
+
8
+ import org .hibernate .reactive .BaseReactiveTest ;
9
+ import org .hibernate .reactive .annotations .DisableFor ;
10
+ import org .hibernate .reactive .containers .DatabaseConfiguration ;
11
+
12
+ import org .junit .jupiter .api .Test ;
13
+
14
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .POSTGRESQL ;
15
+ import static org .junit .jupiter .api .Assertions .assertNotEquals ;
16
+
17
+ public class DisableForMethodTest extends BaseReactiveTest {
18
+
19
+ @ Test
20
+ @ DisableFor (value = POSTGRESQL , reason = "Reason #2" )
21
+ public void test () {
22
+ // Throw exception if this test is run with POSTGRESQL database
23
+ assertNotEquals ( POSTGRESQL , DatabaseConfiguration .dbType () );
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ /* Hibernate, Relational Persistence for Idiomatic Java
2
+ *
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ * Copyright: Red Hat Inc. and Hibernate Authors
5
+ */
6
+ package org .hibernate .reactive .annotations .tests ;
7
+
8
+ import org .hibernate .reactive .BaseReactiveTest ;
9
+ import org .hibernate .reactive .annotations .DisableFor ;
10
+ import org .hibernate .reactive .containers .DatabaseConfiguration ;
11
+
12
+ import org .junit .jupiter .api .Test ;
13
+
14
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .MYSQL ;
15
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .POSTGRESQL ;
16
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
17
+
18
+ @ DisableFor (value = MYSQL , reason = "Reason #1" )
19
+ @ DisableFor (value = POSTGRESQL , reason = "Reason #2" )
20
+ public class DisableForMultipleClassTest extends BaseReactiveTest {
21
+
22
+ @ Test
23
+ public void test () {
24
+ // Throw exception if this test is run with POSTGRESQL or MYSQL database
25
+ assertTrue ( DatabaseConfiguration .dbType () != MYSQL && DatabaseConfiguration .dbType () != POSTGRESQL );
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ /* Hibernate, Relational Persistence for Idiomatic Java
2
+ *
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ * Copyright: Red Hat Inc. and Hibernate Authors
5
+ */
6
+ package org .hibernate .reactive .annotations .tests ;
7
+
8
+
9
+
10
+ import org .hibernate .reactive .BaseReactiveTest ;
11
+ import org .hibernate .reactive .annotations .DisableFor ;
12
+ import org .hibernate .reactive .containers .DatabaseConfiguration ;
13
+
14
+ import org .junit .jupiter .api .Test ;
15
+
16
+
17
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .POSTGRESQL ;
18
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .MYSQL ;
19
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
20
+
21
+ public class DisableForMultipleMethodTest extends BaseReactiveTest {
22
+
23
+ @ Test
24
+ @ DisableFor (value = MYSQL , reason = "Reason #1" )
25
+ @ DisableFor (value = POSTGRESQL , reason = "Reason #2" )
26
+ public void test () {
27
+ // Throw exception if this test is run with POSTGRESQL or MYSQL database
28
+ assertTrue ( DatabaseConfiguration .dbType () != POSTGRESQL &&
29
+ DatabaseConfiguration .dbType () != MYSQL );
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ /* Hibernate, Relational Persistence for Idiomatic Java
2
+ *
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ * Copyright: Red Hat Inc. and Hibernate Authors
5
+ */
6
+ package org .hibernate .reactive .annotations .tests ;
7
+
8
+ import org .hibernate .reactive .BaseReactiveTest ;
9
+ import org .hibernate .reactive .annotations .EnableFor ;
10
+ import org .hibernate .reactive .containers .DatabaseConfiguration ;
11
+
12
+ import org .junit .jupiter .api .Test ;
13
+
14
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .POSTGRESQL ;
15
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
16
+
17
+ @ EnableFor (value = POSTGRESQL )
18
+ public class EnableForClassTest extends BaseReactiveTest {
19
+
20
+ @ Test
21
+ public void test () {
22
+ // Throw exception if this test is database is NOT POSTGRESQL
23
+ assertEquals ( POSTGRESQL , DatabaseConfiguration .dbType () );
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ /* Hibernate, Relational Persistence for Idiomatic Java
2
+ *
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ * Copyright: Red Hat Inc. and Hibernate Authors
5
+ */
6
+ package org .hibernate .reactive .annotations .tests ;
7
+
8
+ import org .hibernate .reactive .BaseReactiveTest ;
9
+ import org .hibernate .reactive .annotations .EnableFor ;
10
+ import org .hibernate .reactive .annotations .EnableForGroup ;
11
+ import org .hibernate .reactive .containers .DatabaseConfiguration ;
12
+
13
+ import org .junit .jupiter .api .Test ;
14
+
15
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .MYSQL ;
16
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .POSTGRESQL ;
17
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
18
+
19
+ @ EnableForGroup ({
20
+ @ EnableFor (value = MYSQL ),
21
+ @ EnableFor (value = POSTGRESQL )
22
+ })
23
+ public class EnableForGroupClassTest extends BaseReactiveTest {
24
+
25
+ @ Test
26
+ public void test () {
27
+ // Throw exception if this test is run with POSTGRESQL or MYSQL database
28
+ assertTrue ( DatabaseConfiguration .dbType () == POSTGRESQL ||
29
+ DatabaseConfiguration .dbType () == MYSQL );
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ /* Hibernate, Relational Persistence for Idiomatic Java
2
+ *
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ * Copyright: Red Hat Inc. and Hibernate Authors
5
+ */
6
+ package org .hibernate .reactive .annotations .tests ;
7
+
8
+ import org .hibernate .reactive .BaseReactiveTest ;
9
+ import org .hibernate .reactive .annotations .EnableFor ;
10
+ import org .hibernate .reactive .containers .DatabaseConfiguration ;
11
+
12
+ import org .junit .jupiter .api .Test ;
13
+
14
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .POSTGRESQL ;
15
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
16
+
17
+ public class EnableForMethodTest extends BaseReactiveTest {
18
+
19
+ @ Test
20
+ @ EnableFor (value = POSTGRESQL )
21
+ public void test () {
22
+ // Throw exception if this test is database is NOT POSTGRESQL
23
+ assertEquals ( POSTGRESQL , DatabaseConfiguration .dbType () );
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ /* Hibernate, Relational Persistence for Idiomatic Java
2
+ *
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ * Copyright: Red Hat Inc. and Hibernate Authors
5
+ */
6
+ package org .hibernate .reactive .annotations .tests ;
7
+
8
+ import org .hibernate .reactive .BaseReactiveTest ;
9
+ import org .hibernate .reactive .annotations .EnableFor ;
10
+ import org .hibernate .reactive .containers .DatabaseConfiguration ;
11
+
12
+ import org .junit .jupiter .api .Test ;
13
+
14
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .MYSQL ;
15
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .POSTGRESQL ;
16
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
17
+
18
+ @ EnableFor (value = MYSQL )
19
+ @ EnableFor (value = POSTGRESQL )
20
+ public class EnableForMultipleClassTest extends BaseReactiveTest {
21
+
22
+ @ Test
23
+ public void test () {
24
+ // Throw exception if this test is run with POSTGRESQL or MYSQL database
25
+ assertTrue ( DatabaseConfiguration .dbType () == POSTGRESQL ||
26
+ DatabaseConfiguration .dbType () == MYSQL );
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ /* Hibernate, Relational Persistence for Idiomatic Java
2
+ *
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ * Copyright: Red Hat Inc. and Hibernate Authors
5
+ */
6
+ package org .hibernate .reactive .annotations .tests ;
7
+
8
+
9
+ import org .hibernate .reactive .annotations .EnableFor ;
10
+ import org .hibernate .reactive .containers .DatabaseConfiguration ;
11
+
12
+ import org .junit .jupiter .api .Test ;
13
+
14
+
15
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .POSTGRESQL ;
16
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .MYSQL ;
17
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
18
+
19
+ public class EnableForMultipleMethodTest {
20
+
21
+ @ Test
22
+ @ EnableFor (value = POSTGRESQL )
23
+ @ EnableFor (value = MYSQL )
24
+ public void test () {
25
+ // Throw exception if this test is run with POSTGRESQL or MYSQL database
26
+ assertTrue ( DatabaseConfiguration .dbType () == POSTGRESQL ||
27
+ DatabaseConfiguration .dbType () == MYSQL );
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ /* Hibernate, Relational Persistence for Idiomatic Java
2
+ *
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ * Copyright: Red Hat Inc. and Hibernate Authors
5
+ */
6
+ package org .hibernate .reactive .annotations .tests ;
7
+
8
+ import java .util .Objects ;
9
+
10
+ import jakarta .persistence .Entity ;
11
+ import jakarta .persistence .Id ;
12
+ import jakarta .persistence .Table ;
13
+
14
+ @ Entity (name = "GuineaPig" )
15
+ @ Table (name = "pig" )
16
+ public class GuineaPig {
17
+ @ Id
18
+ private Integer id ;
19
+ private String name ;
20
+
21
+ public GuineaPig () {
22
+ }
23
+
24
+ public GuineaPig (Integer id , String name ) {
25
+ this .id = id ;
26
+ this .name = name ;
27
+ }
28
+
29
+ public Integer getId () {
30
+ return id ;
31
+ }
32
+
33
+ public void setId (Integer id ) {
34
+ this .id = id ;
35
+ }
36
+
37
+ public String getName () {
38
+ return name ;
39
+ }
40
+
41
+ public void setName (String name ) {
42
+ this .name = name ;
43
+ }
44
+
45
+ @ Override
46
+ public String toString () {
47
+ return id + ": " + name ;
48
+ }
49
+
50
+ @ Override
51
+ public boolean equals (Object o ) {
52
+ if ( this == o ) {
53
+ return true ;
54
+ }
55
+ if ( o == null || getClass () != o .getClass () ) {
56
+ return false ;
57
+ }
58
+ GuineaPig guineaPig = (GuineaPig ) o ;
59
+ return Objects .equals ( name , guineaPig .name );
60
+ }
61
+
62
+ @ Override
63
+ public int hashCode () {
64
+ return Objects .hash ( name );
65
+ }
66
+ }
You can’t perform that action at this time.
0 commit comments