1. Project Clover database Fri Jul 17 2026 06:10:26 UTC
  2. Package guru.mikelue.foxglove.vendor

File SqliteTest.java

 

Code metrics

0
3
3
1
107
88
3
1
1
3
1

Classes

Class Line # Actions
SqliteTest 22 3 0% 3 6
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package guru.mikelue.foxglove.vendor;
2   
3    import java.io.IOException;
4    import java.time.*;
5   
6    import org.springframework.beans.factory.annotation.Autowired;
7    import org.springframework.context.ApplicationContext;
8    import org.springframework.jdbc.core.JdbcTemplate;
9    import org.springframework.transaction.annotation.Transactional;
10   
11    import org.junit.jupiter.api.BeforeAll;
12    import org.junit.jupiter.api.Tag;
13    import org.junit.jupiter.api.Test;
14   
15    import guru.mikelue.foxglove.TableFacet;
16    import guru.mikelue.foxglove.annotation.GenData;
17    import guru.mikelue.foxglove.annotation.TableFacetsSource;
18    import guru.mikelue.foxglove.jdbc.JdbcTableFacet;
19    import guru.mikelue.foxglove.test.AbstractVendorTestBase;
20   
21    @Tag("vendor-sqlite")
 
22    public class SqliteTest extends AbstractVendorTestBase {
23    private final static int RANDOM_ROWS = gen().ints().range(5, 10).get();
24   
 
25  0 toggle public SqliteTest() {}
26   
 
27  0 toggle @BeforeAll
28    static void globalSetup(
29    @Autowired ApplicationContext appContext,
30    @Autowired JdbcTemplate jdbcTemplate
31    ) throws IOException {
32  0 dropTables(jdbcTemplate, "ap_types");
33   
34  0 build("classpath:sqlite-types.sql", appContext);
35    }
36   
37    @TableFacetsSource
38    TableFacet[] defaultData = new JdbcTableFacet[] {
39    // Uses java.time.Instant as values for SQLite temporal columns
40    JdbcTableFacet.builder("ap_types")
41    .numberOfRows(RANDOM_ROWS)
42    .column("tp_color").fixed("green")
43    .column("tp_date").fixed(Instant.now())
44    .column("tp_time").fixed(Instant.now())
45    .column("tp_datetime").fixed(Instant.now())
46    .column("tp_timestamp").fixed(Instant.now())
47    .build(),
48    // Uses java.time.OffsetXXX as values for SQLite temporal columns
49    JdbcTableFacet.builder("ap_types")
50    .numberOfRows(RANDOM_ROWS)
51    .column("tp_color").fixed("green")
52    .column("tp_date").fixed(OffsetDateTime.now())
53    .column("tp_time").fixed(OffsetTime.now())
54    .column("tp_datetime").fixed(OffsetDateTime.now())
55    .column("tp_timestamp").fixed(OffsetDateTime.now())
56    .build(),
57    // Uses java.time.ZonedDateTime as values for SQLite temporal columns
58    JdbcTableFacet.builder("ap_types")
59    .numberOfRows(RANDOM_ROWS)
60    .column("tp_color").fixed("green")
61    .column("tp_date").fixed(ZonedDateTime.now())
62    .column("tp_time").fixed(ZonedDateTime.now())
63    .column("tp_datetime").fixed(ZonedDateTime.now())
64    .column("tp_timestamp").fixed(ZonedDateTime.now())
65    .build(),
66    // Uses java.sql temporal types as values for SQLite temporal columns
67    JdbcTableFacet.builder("ap_types")
68    .numberOfRows(RANDOM_ROWS)
69    .column("tp_color").fixed("green")
70    .column("tp_date").fixed(java.sql.Date.from(Instant.now()))
71    .column("tp_time").fixed(java.sql.Time.from(Instant.now()))
72    .column("tp_datetime").fixed(java.sql.Timestamp.from(Instant.now()))
73    .column("tp_timestamp").fixed(java.sql.Timestamp.from(Instant.now()))
74    .build(),
75    // Uses local java.time types as values for SQLite temporal columns
76    JdbcTableFacet.builder("ap_types")
77    .numberOfRows(RANDOM_ROWS)
78    .column("tp_color").fixed("green")
79    .column("tp_date").fixed(LocalDate.now())
80    .column("tp_time").fixed(LocalTime.now())
81    .column("tp_datetime").fixed(LocalDateTime.now())
82    .column("tp_timestamp").fixed(LocalDateTime.now())
83    .build(),
84    // Uses strings as values for SQLite temporal columns
85    JdbcTableFacet.builder("ap_types")
86    .numberOfRows(RANDOM_ROWS)
87    .column("tp_color").fixed("green")
88    .column("tp_date").fixed("2026-07-16")
89    .column("tp_time").fixed("12:34:56")
90    .column("tp_datetime").fixed("2026-07-16 12:34:56")
91    .column("tp_timestamp").fixed("2026-07-16 12:34:56")
92    .build(),
93    };
94   
95    /**
96    * Tests basic functionality for Sqlite.
97    */
 
98  0 toggle @Test
99    @GenData @Transactional
100    void basic()
101    {
102  0 assertNumberOfRows(
103    "ap_types", "tp_color = 'green'"
104    )
105    .isEqualTo(RANDOM_ROWS * defaultData.length);
106    }
107    }