| 1 |
|
package guru.mikelue.foxglove.jdbc; |
| 2 |
|
|
| 3 |
|
import java.sql.JDBCType; |
| 4 |
|
import java.util.List; |
| 5 |
|
import java.util.Map; |
| 6 |
|
|
| 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.foxglove.TupleAccessor; |
| 12 |
|
import guru.mikelue.misc.testlib.AbstractTestBase; |
| 13 |
|
|
| 14 |
|
import static guru.mikelue.foxglove.ColumnMetaTestUtils.newColumnMeta; |
| 15 |
|
import static org.assertj.core.api.Assertions.assertThat; |
| 16 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 6 |
Complexity Density: 0.4 |
|
| 17 |
|
public class ValueTombTest extends AbstractTestBase { |
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 18 |
2 |
public ValueTombTest() {}... |
| 19 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 20 |
2 |
@BeforeEach... |
| 21 |
|
void setup() {} |
| 22 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 23 |
2 |
@AfterEach... |
| 24 |
|
void tearDown() {} |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
| 29 |
1 |
@Test... |
| 30 |
|
void preserveProtoData() |
| 31 |
|
{ |
| 32 |
1 |
var testedTomb = new ValueTomb("sample_table"); |
| 33 |
|
|
| 34 |
1 |
testedTomb.keepColumn("col1"); |
| 35 |
|
|
| 36 |
1 |
testedTomb.preserveProtoData( |
| 37 |
|
newTuple("col1", 20) |
| 38 |
|
); |
| 39 |
1 |
testedTomb.preserveProtoData( |
| 40 |
|
newTuple("col1", 30) |
| 41 |
|
); |
| 42 |
|
|
| 43 |
1 |
assertThat(testedTomb.getValues("col1")) |
| 44 |
|
.containsExactly(20, 30); |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 50 |
1 |
@Test... |
| 51 |
|
void preserveAfterData() |
| 52 |
|
{ |
| 53 |
1 |
var testedTomb = new ValueTomb("sample_table"); |
| 54 |
|
|
| 55 |
1 |
testedTomb.keepColumn("col1"); |
| 56 |
1 |
testedTomb.keepColumn("col2"); |
| 57 |
|
|
| 58 |
1 |
testedTomb.preserveProtoData( |
| 59 |
|
newTuple("col2", 99) |
| 60 |
|
); |
| 61 |
|
|
| 62 |
1 |
testedTomb.preserveAfterData(List.of( |
| 63 |
|
newTuple("col1", 37), |
| 64 |
|
newTuple("col1", 38), |
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
newTuple("col2", 57), |
| 69 |
|
newTuple("col2", 58) |
| 70 |
|
|
| 71 |
|
)); |
| 72 |
|
|
| 73 |
1 |
assertThat(testedTomb.getValues("col1")) |
| 74 |
|
.containsExactly(37, 38); |
| 75 |
1 |
assertThat(testedTomb.getValues("col2")) |
| 76 |
|
.containsExactly(99); |
| 77 |
|
} |
| 78 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 79 |
7 |
private static TupleAccessor newTuple(String columnName, Object value)... |
| 80 |
|
{ |
| 81 |
7 |
var column = newColumnMeta(columnName, JDBCType.INTEGER); |
| 82 |
7 |
var tupleSchema = new TupleAccessorImpl.TupleSchema( |
| 83 |
|
List.of(column) |
| 84 |
|
); |
| 85 |
|
|
| 86 |
7 |
return tupleSchema.createTupleAccessor( |
| 87 |
|
Map.of(column, value), 0 |
| 88 |
|
); |
| 89 |
|
} |
| 90 |
|
} |