|
| 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.annotations.DisableFor; |
| 9 | +import org.hibernate.reactive.annotations.DisableForGroup; |
| 10 | +import org.hibernate.reactive.annotations.EnableFor; |
| 11 | +import org.hibernate.reactive.annotations.EnableForGroup; |
| 12 | + |
| 13 | +import org.junit.jupiter.api.Test; |
| 14 | + |
| 15 | +import static org.assertj.core.api.Assertions.assertThat; |
| 16 | +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.DB2; |
| 17 | +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.MYSQL; |
| 18 | +import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; |
| 19 | +import static org.hibernate.reactive.containers.DatabaseConfiguration.dbType; |
| 20 | + |
| 21 | +public class FilterByDbTypeOnMethodTest { |
| 22 | + |
| 23 | + @Test |
| 24 | + @DisableFor(POSTGRESQL) |
| 25 | + public void testDisableOneDb() { |
| 26 | + // Throw exception if this test is run with POSTGRESQL database |
| 27 | + assertThat( dbType() ).isNotEqualTo( POSTGRESQL ); |
| 28 | + } |
| 29 | + |
| 30 | + @Test |
| 31 | + @DisableFor(value = {POSTGRESQL, MYSQL, DB2}, reason = "some reason") |
| 32 | + public void testDisableMultipleDbs() { |
| 33 | + // Throw exception if this test is run with POSTGRESQL database |
| 34 | + assertThat( dbType() ).isNotIn( POSTGRESQL, MYSQL, DB2 ); |
| 35 | + } |
| 36 | + |
| 37 | + @Test |
| 38 | + @DisableFor(value = MYSQL, reason = "some reason") |
| 39 | + @DisableFor(value = POSTGRESQL, reason = "some reason") |
| 40 | + public void testDisabledRepeatable() { |
| 41 | + // Throw exception if this test is run with POSTGRESQL or MYSQL database |
| 42 | + assertThat( dbType() ).isNotIn( POSTGRESQL, MYSQL ); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + @DisableForGroup({ |
| 47 | + @DisableFor(MYSQL), |
| 48 | + @DisableFor(POSTGRESQL) |
| 49 | + }) |
| 50 | + public void testDisabledForGroup() { |
| 51 | + // Throw exception if this test is run with POSTGRESQL or MYSQL database |
| 52 | + assertThat( dbType() ).isNotIn( POSTGRESQL, MYSQL ); |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + @EnableFor(POSTGRESQL) |
| 57 | + public void testEnableForOneDb() { |
| 58 | + assertThat( dbType() ).isEqualTo( POSTGRESQL ); |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + @EnableFor(value = {POSTGRESQL, MYSQL, DB2}, reason = "some reason") |
| 63 | + public void testEnableMultipleDbs() { |
| 64 | + assertThat( dbType() ).isIn( POSTGRESQL, MYSQL, DB2 ); |
| 65 | + } |
| 66 | + |
| 67 | + @Test |
| 68 | + @EnableFor(value = MYSQL, reason = "some reason") |
| 69 | + @EnableFor(value = POSTGRESQL, reason = "some reason") |
| 70 | + public void testEnableRepeatable() { |
| 71 | + assertThat( dbType() ).isIn( POSTGRESQL, MYSQL ); |
| 72 | + } |
| 73 | + |
| 74 | + @Test |
| 75 | + @EnableForGroup({ |
| 76 | + @EnableFor(MYSQL), |
| 77 | + @EnableFor(POSTGRESQL) |
| 78 | + }) |
| 79 | + public void testEnableForGroup() { |
| 80 | + assertThat( dbType() ).isIn( POSTGRESQL, MYSQL ); |
| 81 | + } |
| 82 | +} |
0 commit comments