| 1 |
|
package guru.mikelue.foxglove.jdbc; |
| 2 |
|
|
| 3 |
|
import org.junit.jupiter.api.BeforeEach; |
| 4 |
|
import org.junit.jupiter.api.Test; |
| 5 |
|
|
| 6 |
|
import java.sql.JDBCType; |
| 7 |
|
import java.sql.PreparedStatement; |
| 8 |
|
import java.sql.SQLException; |
| 9 |
|
import java.util.LinkedHashMap; |
| 10 |
|
|
| 11 |
|
import guru.mikelue.foxglove.ColumnMeta; |
| 12 |
|
import guru.mikelue.foxglove.setting.DataSetting; |
| 13 |
|
import mockit.Mocked; |
| 14 |
|
import mockit.Verifications; |
| 15 |
|
|
| 16 |
|
import static guru.mikelue.foxglove.ColumnMetaTestUtils.newColumnMeta; |
| 17 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 4 |
Complexity Density: 0.29 |
|
| 18 |
|
public class WorkerAssistanceMockTest { |
| 19 |
|
@Mocked |
| 20 |
|
private PreparedStatement mockStat; |
| 21 |
|
|
| 22 |
|
private WorkerAssistance testedAssistance; |
| 23 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 24 |
1 |
@BeforeEach... |
| 25 |
|
void setup() |
| 26 |
|
{ |
| 27 |
1 |
var dataSetting = new DataSetting() |
| 28 |
|
.addStatementSetter( |
| 29 |
|
meta -> meta.name().equals("col_3"), |
| 30 |
|
(stmt, index, meta, value) -> stmt.setInt(index, (Integer)value) |
| 31 |
|
); |
| 32 |
|
|
| 33 |
1 |
testedAssistance = new WorkerAssistance( |
| 34 |
|
mockStat, |
| 35 |
|
new GeneratedValueLoader(new String[0]), |
| 36 |
|
values -> {}, dataSetting |
| 37 |
|
); |
| 38 |
|
} |
| 39 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 40 |
1 |
public WorkerAssistanceMockTest() {}... |
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 45 |
1 |
@Test... |
| 46 |
|
void setParams() throws SQLException |
| 47 |
|
{ |
| 48 |
1 |
var sampleParams = new LinkedHashMap<ColumnMeta, Object>(); |
| 49 |
1 |
sampleParams.put( |
| 50 |
|
newColumnMeta("col_1", "varchar", JDBCType.VARCHAR), "str_v1" |
| 51 |
|
); |
| 52 |
1 |
sampleParams.put( |
| 53 |
|
newColumnMeta("col_2", "bigint", JDBCType.BIGINT), null |
| 54 |
|
); |
| 55 |
1 |
sampleParams.put( |
| 56 |
|
newColumnMeta("col_3", "int", JDBCType.INTEGER), 1900 |
| 57 |
|
); |
| 58 |
|
|
| 59 |
1 |
testedAssistance.setParams(sampleParams); |
| 60 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 61 |
1 |
new Verifications() {{... |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
1 |
mockStat.setObject(1, "str_v1", JDBCType.VARCHAR.getVendorTypeNumber()); |
| 66 |
1 |
times = 1; |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
1 |
mockStat.setNull(2, JDBCType.BIGINT.getVendorTypeNumber()); |
| 73 |
1 |
times = 1; |
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
1 |
mockStat.setInt(3, 1900); |
| 80 |
1 |
times = 1; |
| 81 |
|
|
| 82 |
|
}}; |
| 83 |
|
} |
| 84 |
|
} |