Skip to content

Commit 4fc1715

Browse files
author
Philipp Wagner
committed
Initial Test (may not be working yet)
1 parent 713f0f1 commit 4fc1715

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

PgBulkInsert/src/main/java/de/bytefish/pgbulkinsert/pgsql/model/interval/Interval.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ public class Interval {
66
private final int days;
77
private final long time;
88

9-
109
public Interval(int months, int days, long time) {
1110
this.months = months;
1211
this.days = days;

PgBulkInsert/src/test/java/de/bytefish/pgbulkinsert/test/pgsql/handlers/PgBulkInsertTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,34 @@ public SampleEntityMapping() {
158158
mapDoubleArray("col_double_array", SampleEntity::getCol_double_array);
159159
mapJsonb("col_jsonb", SampleEntity::getCol_jsonb);
160160
mapNumeric("col_numeric", SampleEntity::getCol_numeric);
161+
mapInterval("col_interval", SampleEntity::get_col_interval);
162+
}
163+
}
164+
165+
@Test
166+
public void saveAll_interval_Test() throws SQLException {
167+
168+
// This list will be inserted.
169+
List<SampleEntity> entities = new ArrayList<>();
170+
171+
// Create the Entity to insert:
172+
SampleEntity entity = new SampleEntity();
173+
174+
// 2 mons 15 days 02:03:04.005
175+
entity.col_interval = new Interval(2, 15, 7384005000L);
176+
177+
entities.add(entity);
178+
179+
PgBulkInsert<SampleEntity> pgBulkInsert = new PgBulkInsert<>(new SampleEntityMapping());
180+
181+
pgBulkInsert.saveAll(PostgreSqlUtils.getPGConnection(connection), entities.stream());
182+
183+
ResultSet rs = getAll();
184+
185+
while (rs.next()) {
186+
Object v = rs.getObject("col_interval");
187+
188+
Assert.assertEquals("2 mons 15 days 02:03:04.005", v);
161189
}
162190
}
163191

0 commit comments

Comments
 (0)