1. Project Clover database Wed Nov 12 2025 05:07:35 UTC
  2. Package guru.mikelue.foxglove.jdbc

File ValueTombTest.java

 

Code metrics

0
15
6
1
90
62
6
0.4
2.5
6
1

Classes

Class Line # Actions
ValueTombTest 17 15 0% 6 0
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

Source view

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   
 
17    public class ValueTombTest extends AbstractTestBase {
 
18  2 toggle public ValueTombTest() {}
19   
 
20  2 toggle @BeforeEach
21    void setup() {}
22   
 
23  2 toggle @AfterEach
24    void tearDown() {}
25   
26    /**
27    * Tests the preserving of values by proto-data.
28    */
 
29  1 toggle @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    * Tests the preserving of values by proto-data.
49    */
 
50  1 toggle @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    * Doesn't get preserved since 'col2' is preserved in proto-data
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   
 
79  7 toggle 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    }