11package de .bytefish .pgbulkinsert .test ;
22
3- import de .bytefish .pgbulkinsert .PgBulkInsert ;
43import org .junit .jupiter .api .AfterAll ;
54import org .junit .jupiter .api .BeforeAll ;
65import org .junit .jupiter .api .Test ;
2524
2625import static org .junit .jupiter .api .Assertions .assertEquals ;
2726import static org .junit .jupiter .api .Assertions .assertTrue ;
27+ import static de .bytefish .pgbulkinsert .PgBulkInsert .*;
2828
2929public class IntegrationTest {
3030
@@ -82,30 +82,30 @@ public record TestEntity(
8282 LocalDate dateVal ,
8383 LocalTime timeVal ,
8484 Instant timestampTzVal ,
85- PgBulkInsert . PgRange <Integer > intRange ,
86- PgBulkInsert . PgRange <LocalDateTime > tsRange ,
85+ PgRange <Integer > intRange ,
86+ PgRange <LocalDateTime > tsRange ,
8787 List <String > tags
8888 ) {}
8989
9090 @ Test
9191 public void testBulkInsertSavesDataCorrectly () throws Exception {
9292
9393 // Build the Test Subject
94- PgBulkInsert . PgMapper <TestEntity > mapper = PgBulkInsert . PgMapper .forClass (TestEntity .class )
95- .map ("id" , PgBulkInsert . PostgresTypes .INT8 .primitive (TestEntity ::id ))
96- .map ("text_val" , PgBulkInsert . PostgresTypes .TEXT .removeNullCharacters ().from (TestEntity ::textVal ))
97- .map ("numeric_val" , PgBulkInsert . PostgresTypes .NUMERIC .from (TestEntity ::numericVal ))
98- .map ("numeric_int_val" , PgBulkInsert . PostgresTypes .NUMERIC_INTEGER .from (TestEntity ::numericIntVal ))
99- .map ("is_active" , PgBulkInsert . PostgresTypes .BOOLEAN .primitive (TestEntity ::isActive ))
100- .map ("created_at" , PgBulkInsert . PostgresTypes .TIMESTAMP .localDateTime (TestEntity ::createdAt ))
101- .map ("date_val" , PgBulkInsert . PostgresTypes .DATE .from (TestEntity ::dateVal ))
102- .map ("time_val" , PgBulkInsert . PostgresTypes .TIME .from (TestEntity ::timeVal ))
103- .map ("timestamptz_val" , PgBulkInsert . PostgresTypes .TIMESTAMPTZ .instant (TestEntity ::timestampTzVal ))
104- .map ("int_range" , PgBulkInsert . PostgresTypes .range (PgBulkInsert . PostgresTypes .INT4 ).from (TestEntity ::intRange ))
105- .map ("ts_range" , PgBulkInsert . PostgresTypes .range (PgBulkInsert . PostgresTypes .TIMESTAMP ).from (TestEntity ::tsRange ))
106- .map ("tags" , PgBulkInsert . PostgresTypes .array (PgBulkInsert . PostgresTypes .TEXT ).from (TestEntity ::tags ));
107-
108- PgBulkInsert . PgBulkWriter <TestEntity > writer = new PgBulkInsert . PgBulkWriter <>(mapper );
94+ PgMapper <TestEntity > mapper = PgMapper .forClass (TestEntity .class )
95+ .map ("id" , PostgresTypes .INT8 .primitive (TestEntity ::id ))
96+ .map ("text_val" , PostgresTypes .TEXT .removeNullCharacters ().from (TestEntity ::textVal ))
97+ .map ("numeric_val" , PostgresTypes .NUMERIC .from (TestEntity ::numericVal ))
98+ .map ("numeric_int_val" , PostgresTypes .NUMERIC_INTEGER .from (TestEntity ::numericIntVal ))
99+ .map ("is_active" , PostgresTypes .BOOLEAN .primitive (TestEntity ::isActive ))
100+ .map ("created_at" , PostgresTypes .TIMESTAMP .localDateTime (TestEntity ::createdAt ))
101+ .map ("date_val" , PostgresTypes .DATE .from (TestEntity ::dateVal ))
102+ .map ("time_val" , PostgresTypes .TIME .from (TestEntity ::timeVal ))
103+ .map ("timestamptz_val" , PostgresTypes .TIMESTAMPTZ .instant (TestEntity ::timestampTzVal ))
104+ .map ("int_range" , PostgresTypes .range (PostgresTypes .INT4 ).from (TestEntity ::intRange ))
105+ .map ("ts_range" , PostgresTypes .range (PostgresTypes .TIMESTAMP ).from (TestEntity ::tsRange ))
106+ .map ("tags" , PostgresTypes .array (PostgresTypes .TEXT ).from (TestEntity ::tags ));
107+
108+ PgBulkWriter <TestEntity > writer = new PgBulkWriter <>(mapper );
109109
110110 // Arrange
111111 LocalDateTime now = LocalDateTime .now ().truncatedTo (ChronoUnit .MICROS ); // Postgres speichert auf Mikrosekunden genau
@@ -117,16 +117,16 @@ public void testBulkInsertSavesDataCorrectly() throws Exception {
117117 new TestEntity (
118118 1L , "Normaler Text" , new BigDecimal ("42.1234" ), new BigInteger ("98765432101234567890987654321" ), true , now ,
119119 today , timeNow , instantNow ,
120- PgBulkInsert . PgRange .closedOpen (1 , 100 ),
121- PgBulkInsert . PgRange .closed (now .minusDays (1 ), now ),
120+ PgRange .closedOpen (1 , 100 ),
121+ PgRange .closed (now .minusDays (1 ), now ),
122122 List .of ("java" , "postgres" )
123123 ),
124124 // Invalid Null to be removed
125125 new TestEntity (
126126 2L , "Fieser \u0000 Text" , new BigDecimal ("-99.99" ), new BigInteger ("-12345678909876543210123456789" ), false , now .minusDays (1 ),
127127 today .minusDays (1 ), timeNow .minusHours (1 ), instantNow .minus (1 , ChronoUnit .DAYS ),
128- PgBulkInsert . PgRange .emptyRange (),
129- PgBulkInsert . PgRange .atLeast (now ),
128+ PgRange .emptyRange (),
129+ PgRange .atLeast (now ),
130130 Arrays .asList ("test" , null , "array" )
131131 )
132132 );
0 commit comments