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

File OracleTest.java

 

Code metrics

0
3
3
1
106
88
3
1
1
3
1

Classes

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