| 1 |
|
package guru.mikelue.foxglove.setting; |
| 2 |
|
|
| 3 |
|
import java.sql.JDBCType; |
| 4 |
|
import java.util.function.Supplier; |
| 5 |
|
|
| 6 |
|
import org.assertj.core.api.InstanceOfAssertFactories; |
| 7 |
|
import org.junit.jupiter.api.AfterEach; |
| 8 |
|
import org.junit.jupiter.api.BeforeEach; |
| 9 |
|
import org.junit.jupiter.api.Test; |
| 10 |
|
|
| 11 |
|
import guru.mikelue.misc.testlib.AbstractTestBase; |
| 12 |
|
|
| 13 |
|
import guru.mikelue.foxglove.ColumnMeta; |
| 14 |
|
|
| 15 |
|
import static guru.mikelue.foxglove.ColumnMetaTestUtils.newColumnMeta; |
| 16 |
|
import static org.assertj.core.api.Assertions.assertThat; |
| 17 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 18 |
|
public class LayeredDataSettingTest extends AbstractTestBase { |
| 19 |
|
private final static DataSettingInfo firstSetting = new DataSetting() |
| 20 |
|
.setDefaultNumberOfRows(34) |
| 21 |
|
.<String>givenType(JDBCType.VARCHAR) |
| 22 |
|
.useSupplier(gen().string().length(16)); |
| 23 |
|
private final static DataSettingInfo secondSetting = new DataSetting() |
| 24 |
|
.<Integer>givenType(JDBCType.INTEGER) |
| 25 |
|
.useSupplier(gen().ints().range(1, 100)) |
| 26 |
|
.<String>givenType(JDBCType.VARCHAR) |
| 27 |
|
.useSupplier(gen().string().length(4)); |
| 28 |
|
|
| 29 |
|
private DataSettingInfo testedSetting = null; |
| 30 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 31 |
1 |
public LayeredDataSettingTest() {}... |
| 32 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 33 |
1 |
@BeforeEach... |
| 34 |
|
void setup() |
| 35 |
|
{ |
| 36 |
1 |
testedSetting = new LayeredDataSetting( |
| 37 |
|
firstSetting, secondSetting |
| 38 |
|
); |
| 39 |
|
} |
| 40 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 41 |
1 |
@AfterEach... |
| 42 |
|
void tearDown() {} |
| 43 |
|
|
| 44 |
|
|
| 45 |
|
@link |
| 46 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 47 |
1 |
@Test... |
| 48 |
|
void resolveSupplier() |
| 49 |
|
{ |
| 50 |
1 |
var varcharColumnMeta = newColumnMeta( |
| 51 |
|
"cl_varchar", JDBCType.VARCHAR, 12 |
| 52 |
|
); |
| 53 |
1 |
var intColumnMeta = newColumnMeta( |
| 54 |
|
"cl_int", JDBCType.INTEGER |
| 55 |
|
); |
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
1 |
var testedSupplier = testedSetting |
| 61 |
|
.<String>resolveSupplier(varcharColumnMeta); |
| 62 |
|
|
| 63 |
1 |
assertThat(testedSupplier) |
| 64 |
|
.isPresent() |
| 65 |
|
.get().extracting(Supplier::get, InstanceOfAssertFactories.STRING) |
| 66 |
|
.hasSize(16); |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
1 |
var testedFallbackSupplier = testedSetting |
| 73 |
|
.<Integer>resolveSupplier(intColumnMeta); |
| 74 |
|
|
| 75 |
1 |
assertThat(testedFallbackSupplier) |
| 76 |
|
.isPresent(); |
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
1 |
assertThat(testedSetting.getDefaultNumberOfRows()) |
| 83 |
|
.isEqualTo(34); |
| 84 |
|
|
| 85 |
|
} |
| 86 |
|
} |