1. Project Clover database Wed Nov 12 2025 05:07:35 UTC
  2. Package guru.mikelue.foxglove.setting

File GeneratingUtilsTest.java

 

Code metrics

0
4
5
1
95
80
5
1.25
0.8
5
1

Classes

Class Line # Actions
GeneratingUtilsTest 22 4 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 9 tests. .

Source view

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   
 
22    public class GeneratingUtilsTest extends AbstractTestBase {
 
23  9 toggle public GeneratingUtilsTest() {}
24   
 
25  9 toggle @BeforeEach
26    void setup() {}
27   
 
28  9 toggle @AfterEach
29    void tearDown() {}
30   
31    /**
32    * Tests the checking for whether or not to
33    * generate value for a column automatically.
34    */
 
35  9 toggle @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    }
 
53  1 toggle static Arguments[] checkAutoGenerating()
54    {
55  1 return new Arguments[] {
56    arguments( // Empty properties of a column
57    EnumSet.noneOf(ColumnMeta.Property.class),
58    EnumSet.noneOf(ColumnMeta.Property.class),
59    true
60    ),
61    arguments( // [TRUE case] generated column
62    EnumSet.of(GENERATED), Set.of(GENERATED),
63    true
64    ),
65    arguments( // [TRUE case] auto-increment column
66    EnumSet.of(AUTO_INCREMENT), Set.of(AUTO_INCREMENT),
67    true
68    ),
69    arguments( // [TRUE case] nullable column
70    EnumSet.of(NULLABLE), Set.of(NULLABLE),
71    true
72    ),
73    arguments( // [TRUE case] column having default value
74    EnumSet.of(DEFAULT_VALUE), Set.of(DEFAULT_VALUE),
75    true
76    ),
77    arguments( // [FALSE case] generated column
78    EnumSet.of(GENERATED, AUTO_INCREMENT), Set.of(AUTO_INCREMENT),
79    false
80    ),
81    arguments( // [FALSE case] auto_increment column
82    EnumSet.of(AUTO_INCREMENT, NULLABLE), Set.of(NULLABLE),
83    false
84    ),
85    arguments( // [FALSE case] nullable column
86    EnumSet.of(NULLABLE, DEFAULT_VALUE), Set.of(DEFAULT_VALUE),
87    false
88    ),
89    arguments( // [FALSE case] column having default value
90    EnumSet.of(DEFAULT_VALUE), Set.of(NULLABLE),
91    false
92    ),
93    };
94    }
95    }