| 1 |
|
package guru.mikelue.foxglove.setting; |
| 2 |
|
|
| 3 |
|
import java.sql.JDBCType; |
| 4 |
|
import java.util.EnumSet; |
| 5 |
|
import java.util.Set; |
| 6 |
|
|
| 7 |
|
import org.junit.jupiter.api.AfterEach; |
| 8 |
|
import org.junit.jupiter.api.BeforeEach; |
| 9 |
|
import org.junit.jupiter.params.ParameterizedTest; |
| 10 |
|
import org.junit.jupiter.params.provider.Arguments; |
| 11 |
|
import org.junit.jupiter.params.provider.MethodSource; |
| 12 |
|
|
| 13 |
|
import guru.mikelue.misc.testlib.AbstractTestBase; |
| 14 |
|
|
| 15 |
|
import guru.mikelue.foxglove.ColumnMeta; |
| 16 |
|
|
| 17 |
|
import static guru.mikelue.foxglove.ColumnMeta.Property.*; |
| 18 |
|
import static guru.mikelue.foxglove.ColumnMetaTestUtils.newColumnMeta; |
| 19 |
|
import static org.assertj.core.api.Assertions.assertThat; |
| 20 |
|
import static org.junit.jupiter.params.provider.Arguments.arguments; |
| 21 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 5 |
Complexity Density: 1.25 |
|
| 22 |
|
public class GeneratingUtilsTest extends AbstractTestBase { |
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 23 |
9 |
public GeneratingUtilsTest() {}... |
| 24 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 25 |
9 |
@BeforeEach... |
| 26 |
|
void setup() {} |
| 27 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 28 |
9 |
@AfterEach... |
| 29 |
|
void tearDown() {} |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
4-
|
|
| 35 |
9 |
@ParameterizedTest... |
| 36 |
|
@MethodSource |
| 37 |
|
void checkAutoGenerating( |
| 38 |
|
EnumSet<ColumnMeta.Property> columnProperties, |
| 39 |
|
Set<ColumnMeta.Property> autoGenerateProperties, |
| 40 |
|
boolean expectedResult |
| 41 |
|
) { |
| 42 |
9 |
var sampleColumnMeta = newColumnMeta( |
| 43 |
|
"any_column", JDBCType.VARCHAR, columnProperties |
| 44 |
|
); |
| 45 |
|
|
| 46 |
9 |
var testedResult = GeneratingUtils.checkAutoGenerating( |
| 47 |
|
sampleColumnMeta, autoGenerateProperties |
| 48 |
|
); |
| 49 |
|
|
| 50 |
9 |
assertThat(testedResult) |
| 51 |
|
.isEqualTo(expectedResult); |
| 52 |
|
} |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 53 |
1 |
static Arguments[] checkAutoGenerating()... |
| 54 |
|
{ |
| 55 |
1 |
return new Arguments[] { |
| 56 |
|
arguments( |
| 57 |
|
EnumSet.noneOf(ColumnMeta.Property.class), |
| 58 |
|
EnumSet.noneOf(ColumnMeta.Property.class), |
| 59 |
|
true |
| 60 |
|
), |
| 61 |
|
arguments( |
| 62 |
|
EnumSet.of(GENERATED), Set.of(GENERATED), |
| 63 |
|
true |
| 64 |
|
), |
| 65 |
|
arguments( |
| 66 |
|
EnumSet.of(AUTO_INCREMENT), Set.of(AUTO_INCREMENT), |
| 67 |
|
true |
| 68 |
|
), |
| 69 |
|
arguments( |
| 70 |
|
EnumSet.of(NULLABLE), Set.of(NULLABLE), |
| 71 |
|
true |
| 72 |
|
), |
| 73 |
|
arguments( |
| 74 |
|
EnumSet.of(DEFAULT_VALUE), Set.of(DEFAULT_VALUE), |
| 75 |
|
true |
| 76 |
|
), |
| 77 |
|
arguments( |
| 78 |
|
EnumSet.of(GENERATED, AUTO_INCREMENT), Set.of(AUTO_INCREMENT), |
| 79 |
|
false |
| 80 |
|
), |
| 81 |
|
arguments( |
| 82 |
|
EnumSet.of(AUTO_INCREMENT, NULLABLE), Set.of(NULLABLE), |
| 83 |
|
false |
| 84 |
|
), |
| 85 |
|
arguments( |
| 86 |
|
EnumSet.of(NULLABLE, DEFAULT_VALUE), Set.of(DEFAULT_VALUE), |
| 87 |
|
false |
| 88 |
|
), |
| 89 |
|
arguments( |
| 90 |
|
EnumSet.of(DEFAULT_VALUE), Set.of(NULLABLE), |
| 91 |
|
false |
| 92 |
|
), |
| 93 |
|
}; |
| 94 |
|
} |
| 95 |
|
} |