| 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-mysql") |
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 1 |
|
| 21 |
|
public class MysqlTest extends AbstractVendorTestBase { |
| 22 |
|
private final static int RANDOM_ROWS = gen().ints().range(5, 10).get(); |
| 23 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 24 |
0 |
public MysqlTest() {}... |
| 25 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 26 |
0 |
@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:mysql-types.sql", appContext); |
| 34 |
|
} |
| 35 |
|
|
| 36 |
|
@TableFacetsSource |
| 37 |
|
TableFacet[] defaultData = new JdbcTableFacet[] { |
| 38 |
|
|
| 39 |
|
JdbcTableFacet.builder("ap_types") |
| 40 |
|
.numberOfRows(RANDOM_ROWS) |
| 41 |
|
.column("tp_color").fixed("green") |
| 42 |
|
.column("tp_json_data").fixed("[2, 4, 6, 8, 10]") |
| 43 |
|
.column("tp_year").fixed((short)2000) |
| 44 |
|
.column("tp_date").fixed(Instant.now()) |
| 45 |
|
.column("tp_time").fixed(Instant.now()) |
| 46 |
|
.column("tp_datetime").fixed(Instant.now()) |
| 47 |
|
.column("tp_timestamp").fixed(Instant.now()) |
| 48 |
|
.build(), |
| 49 |
|
|
| 50 |
|
JdbcTableFacet.builder("ap_types") |
| 51 |
|
.numberOfRows(RANDOM_ROWS) |
| 52 |
|
.column("tp_color").fixed("green") |
| 53 |
|
.column("tp_json_data").fixed("[2, 4, 6, 8, 10]") |
| 54 |
|
.column("tp_year").fixed((short)2000) |
| 55 |
|
.column("tp_date").fixed(OffsetDateTime.now()) |
| 56 |
|
.column("tp_time").fixed(OffsetTime.now()) |
| 57 |
|
.column("tp_datetime").fixed(OffsetDateTime.now()) |
| 58 |
|
.column("tp_timestamp").fixed(OffsetDateTime.now()) |
| 59 |
|
.build(), |
| 60 |
|
|
| 61 |
|
JdbcTableFacet.builder("ap_types") |
| 62 |
|
.numberOfRows(RANDOM_ROWS) |
| 63 |
|
.column("tp_color").fixed("green") |
| 64 |
|
.column("tp_json_data").fixed("[2, 4, 6, 8, 10]") |
| 65 |
|
.column("tp_year").fixed((short)2000) |
| 66 |
|
.column("tp_date").fixed(ZonedDateTime.now()) |
| 67 |
|
.column("tp_time").fixed(ZonedDateTime.now()) |
| 68 |
|
.column("tp_datetime").fixed(ZonedDateTime.now()) |
| 69 |
|
.column("tp_timestamp").fixed(ZonedDateTime.now()) |
| 70 |
|
.build(), |
| 71 |
|
|
| 72 |
|
JdbcTableFacet.builder("ap_types") |
| 73 |
|
.numberOfRows(RANDOM_ROWS) |
| 74 |
|
.column("tp_color").fixed("green") |
| 75 |
|
.column("tp_json_data").fixed("[2, 4, 6, 8, 10]") |
| 76 |
|
.column("tp_year").fixed((short)2000) |
| 77 |
|
.column("tp_date").fixed(java.sql.Date.from(Instant.now())) |
| 78 |
|
.column("tp_time").fixed(java.sql.Time.from(Instant.now())) |
| 79 |
|
.column("tp_datetime").fixed(java.sql.Timestamp.from(Instant.now())) |
| 80 |
|
.column("tp_timestamp").fixed(java.sql.Timestamp.from(Instant.now())) |
| 81 |
|
.build(), |
| 82 |
|
|
| 83 |
|
JdbcTableFacet.builder("ap_types") |
| 84 |
|
.numberOfRows(RANDOM_ROWS) |
| 85 |
|
.column("tp_color").fixed("green") |
| 86 |
|
.column("tp_json_data").fixed("[2, 4, 6, 8, 10]") |
| 87 |
|
.column("tp_year").fixed((short)2000) |
| 88 |
|
.column("tp_date").fixed(LocalDate.now()) |
| 89 |
|
.column("tp_time").fixed(LocalTime.now()) |
| 90 |
|
.column("tp_datetime").fixed(LocalDateTime.now()) |
| 91 |
|
.column("tp_timestamp").fixed(LocalDateTime.now()) |
| 92 |
|
.build(), |
| 93 |
|
|
| 94 |
|
JdbcTableFacet.builder("ap_types") |
| 95 |
|
.numberOfRows(RANDOM_ROWS) |
| 96 |
|
.column("tp_color").fixed("green") |
| 97 |
|
.column("tp_json_data").fixed("[2, 4, 6, 8, 10]") |
| 98 |
|
.column("tp_year").fixed((short)2000) |
| 99 |
|
.column("tp_date").fixed("2026-07-16") |
| 100 |
|
.column("tp_time").fixed("12:34:56") |
| 101 |
|
.column("tp_datetime").fixed("2026-07-16 12:34:56") |
| 102 |
|
.column("tp_timestamp").fixed("2026-07-16 12:34:56") |
| 103 |
|
.build(), |
| 104 |
|
}; |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
4-
|
|
| 109 |
0 |
@Test... |
| 110 |
|
@GenData @Transactional |
| 111 |
|
void basic() |
| 112 |
|
{ |
| 113 |
0 |
assertNumberOfRows( |
| 114 |
|
"ap_types", "tp_color = 'green'" |
| 115 |
|
) |
| 116 |
|
.isEqualTo(RANDOM_ROWS * defaultData.length); |
| 117 |
|
} |
| 118 |
|
} |