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

File RowParamsGeneratorTest.java

 

Code metrics

0
5
4
1
64
41
4
0.8
1.25
4
1

Classes

Class Line # Actions
RowParamsGeneratorTest 18 5 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    package guru.mikelue.foxglove.jdbc;
2   
3    import java.util.List;
4   
5    import org.junit.jupiter.api.AfterEach;
6    import org.junit.jupiter.api.BeforeEach;
7    import org.junit.jupiter.api.Test;
8   
9    import guru.mikelue.misc.testlib.AbstractTestBase;
10   
11    import guru.mikelue.foxglove.setting.DataSetting;
12   
13    import static guru.mikelue.foxglove.ColumnMetaTestUtils.newColumnMeta;
14    import static java.sql.JDBCType.INTEGER;
15    import static java.sql.JDBCType.VARCHAR;
16    import static org.assertj.core.api.Assertions.assertThat;
17   
 
18    public class RowParamsGeneratorTest extends AbstractTestBase {
 
19  1 toggle public RowParamsGeneratorTest() {}
20   
 
21  1 toggle @BeforeEach
22    void setup() {}
23   
 
24  1 toggle @AfterEach
25    void tearDown() {}
26   
27    /**
28    * Tests the cases of resolving suppliers provided by {@link JdbcTableFacet} or {@link DataSetting}.
29    */
 
30  1 toggle @Test
31    void resolveSupplier()
32    {
33  1 var settings = new DataSetting()
34    .givenType(VARCHAR)
35    .useSupplier(() -> "v2")
36    .givenType(INTEGER)
37    .useSupplier(() -> 40);
38   
39  1 var tableFacet = JdbcTableFacet.builder("any_table")
40    .column("st_col2").fixed("v1")
41    .build();
42   
43  1 var sampleMetaOfColumns = List.of(
44    // Overridden by table facet
45    newColumnMeta("st_col2"),
46    // Resolved by setting
47    newColumnMeta("st_col1", INTEGER),
48    // Resolved by setting
49    newColumnMeta("st_col3")
50    );
51   
52  1 var testedRow= new RowParamsGenerator(
53    tableFacet, sampleMetaOfColumns, settings
54    )
55    .generateRowParams();
56   
57    /*
58    * Ensures the sequence of columns in the row(map key is ordered)
59    */
60  1 assertThat(testedRow.values())
61    .containsExactly("v1", 40, "v2");
62    // :~)
63    }
64    }