@@ -164,20 +164,15 @@ void charPrimitive() {
164164
165165 @ Test
166166 void blob () {
167- BiConsumer <Blob , Blob > equality = (actual , expected ) -> Flux .zip (
168- Flux .from (actual .stream ()).reduce (TEST .heapBuffer (), ByteBuf ::writeBytes ),
169- Flux .from (expected .stream ()).reduce (TEST .heapBuffer (), ByteBuf ::writeBytes )
170- )
171- .as (StepVerifier ::create )
172- .assertNext (t -> {
173- try {
174- assertThat (t .getT1 ()).isEqualTo (t .getT2 ());
175- } finally {
176- t .getT1 ().release ();
177- t .getT2 ().release ();
178- }
179- })
180- .verifyComplete ();
167+ BiConsumer <Blob , Blob > equality = (actual , expected ) -> Flux .zip (Flux .from (actual .stream ()).reduce (TEST .heapBuffer (), ByteBuf ::writeBytes ),
168+ Flux .from (expected .stream ()).reduce (TEST .heapBuffer (), ByteBuf ::writeBytes )).as (StepVerifier ::create ).assertNext (t -> {
169+ try {
170+ assertThat (t .getT1 ()).isEqualTo (t .getT2 ());
171+ } finally {
172+ t .getT1 ().release ();
173+ t .getT2 ().release ();
174+ }
175+ }).verifyComplete ();
181176
182177 Function <byte [], Blob > byteToBlob = (bytes ) -> new Blob () {
183178
@@ -209,33 +204,25 @@ void circle() {
209204
210205 @ Test
211206 void circleTwoDimensionalArray () {
212- testCodec (Circle [][].class , new Circle [][]{{Circle .of (Point .of (1.12 , 2.12 ), 3.12 ), Circle .of (Point .of (Double .MIN_VALUE , Double .MIN_VALUE ), Double .MAX_VALUE )},
213- { Circle . of ( Point . of (- 2.4 , -456.2 ), 20 ), null }}, "CIRCLE[][]" );
207+ testCodec (Circle [][].class , new Circle [][]{{Circle .of (Point .of (1.12 , 2.12 ), 3.12 ), Circle .of (Point .of (Double .MIN_VALUE , Double .MIN_VALUE ), Double .MAX_VALUE )}, { Circle . of ( Point . of (- 2.4 ,
208+ -456.2 ), 20 ), null }}, "CIRCLE[][]" );
214209 }
215210
216211 @ Test
217212 void clob () {
218- testCodec (Clob .class ,
219- new Clob () {
213+ testCodec (Clob .class , new Clob () {
220214
221- @ Override
222- public Publisher <Void > discard () {
223- return Mono .empty ();
224- }
215+ @ Override
216+ public Publisher <Void > discard () {
217+ return Mono .empty ();
218+ }
225219
226- @ Override
227- public Publisher <CharSequence > stream () {
228- return Mono .just ("test-value" );
229- }
230- },
231- (actual , expected ) -> Flux .zip (
232- Flux .from (actual .stream ()).reduce (new StringBuilder (), StringBuilder ::append ).map (StringBuilder ::toString ),
233- Flux .from (expected .stream ()).reduce (new StringBuilder (), StringBuilder ::append ).map (StringBuilder ::toString )
234- )
235- .as (StepVerifier ::create )
236- .assertNext (t -> assertThat (t .getT1 ()).isEqualToIgnoringWhitespace (t .getT2 ()))
237- .verifyComplete ()
238- , "TEXT" );
220+ @ Override
221+ public Publisher <CharSequence > stream () {
222+ return Mono .just ("test-value" );
223+ }
224+ }, (actual , expected ) -> Flux .zip (Flux .from (actual .stream ()).reduce (new StringBuilder (), StringBuilder ::append ).map (StringBuilder ::toString ),
225+ Flux .from (expected .stream ()).reduce (new StringBuilder (), StringBuilder ::append ).map (StringBuilder ::toString )).as (StepVerifier ::create ).assertNext (t -> assertThat (t .getT1 ()).isEqualToIgnoringWhitespace (t .getT2 ())).verifyComplete (), "TEXT" );
239226 }
240227
241228 @ Test
@@ -468,11 +455,22 @@ void localDateTime() {
468455 }, "TIMESTAMPTZ" , "$1" , null );
469456 }
470457
458+ @ Test
459+ void localDateTimeArray () {
460+ testCodec (LocalDateTime [].class , new LocalDateTime []{LocalDateTime .now ().truncatedTo (ChronoUnit .MICROS )}, "TIMESTAMP[]" );
461+ testCodec (LocalDateTime [].class , new LocalDateTime []{LocalDateTime .now ().truncatedTo (ChronoUnit .MICROS )}, "TIMESTAMPTZ[]" );
462+ }
463+
471464 @ Test
472465 void localTime () {
473466 testCodec (LocalTime .class , LocalTime .now ().truncatedTo (ChronoUnit .MICROS ), "TIME" );
474467 }
475468
469+ @ Test
470+ void localTimeArray () {
471+ testCodec (LocalTime [].class , new LocalTime []{LocalTime .now ().truncatedTo (ChronoUnit .MICROS )}, "TIME[]" );
472+ }
473+
476474 @ Test
477475 void longArray () {
478476 testCodec (Long [].class , new Long []{100L , 200L , 300L }, "INT8[]" );
@@ -672,8 +670,8 @@ void pathTwoDimensionalArray() {
672670
673671 @ Test
674672 void polygonArray () {
675- testCodec (Polygon [].class , new Polygon []{Polygon .of (Point .of (1.1 , 2.2 ), Point .of (10.10 , 10.10 ), Point .of (.42 , 5.3 )),
676- Polygon . of ( Point . of ( 1.1 , 2.2 ), Point . of ( 10.10 , 10.10 ), Point . of ( .42 , 5.3 ), Point .of (-3.5 , 0. ))}, "POLYGON[]" );
673+ testCodec (Polygon [].class , new Polygon []{Polygon .of (Point .of (1.1 , 2.2 ), Point .of (10.10 , 10.10 ), Point .of (.42 , 5.3 )), Polygon . of ( Point . of ( 1.1 , 2.2 ), Point . of ( 10.10 , 10.10 ), Point . of ( .42 ,
674+ 5.3 ), Point .of (-3.5 , 0. ))}, "POLYGON[]" );
677675 }
678676
679677 @ Test
@@ -689,9 +687,7 @@ void polygonTwoDimensionalArray() {
689687 }
690688
691689 private static <T > Mono <T > close (Connection connection ) {
692- return Mono .from (connection
693- .close ())
694- .then (Mono .empty ());
690+ return Mono .from (connection .close ()).then (Mono .empty ());
695691 }
696692
697693 private <T > void testCodec (Class <T > javaType , T value , String sqlType ) {
@@ -750,94 +746,64 @@ private <IN, OUT> void testCodec(Class<IN> javaType, IN value, Class<OUT> outTyp
750746
751747 if (parameterType == null ) {
752748
753- this .connectionFactory .create ()
754- .flatMapMany (connection -> connection
749+ this .connectionFactory .create ().flatMapMany (connection -> connection
755750
756- .createStatement ("INSERT INTO test VALUES (" + insertPlaceholder + ")" )
757- .bindNull ("$1" , javaType )
758- .execute ()
751+ .createStatement ("INSERT INTO test VALUES (" + insertPlaceholder + ")" ).bindNull ("$1" , javaType ).execute ()
759752
760- .flatMap (PostgresqlResult ::getRowsUpdated )
753+ .flatMap (PostgresqlResult ::getRowsUpdated )
761754
762- .concatWith (close (connection )))
763- .as (StepVerifier ::create )
764- .expectNext (1L )
765- .verifyComplete ();
755+ .concatWith (close (connection ))).as (StepVerifier ::create ).expectNext (1L ).verifyComplete ();
766756
767757 SERVER .getJdbcOperations ().execute ("DELETE FROM test" );
768758
769- this .connectionFactory .create ()
770- .flatMapMany (connection -> connection
759+ this .connectionFactory .create ().flatMapMany (connection -> connection
771760
772- .createStatement ("INSERT INTO test VALUES (" + insertPlaceholder + ")" )
773- .bind ("$1" , value )
774- .execute ()
761+ .createStatement ("INSERT INTO test VALUES (" + insertPlaceholder + ")" ).bind ("$1" , value ).execute ()
775762
776- .flatMap (PostgresqlResult ::getRowsUpdated )
763+ .flatMap (PostgresqlResult ::getRowsUpdated )
777764
778- .concatWith (close (connection )))
779- .as (StepVerifier ::create )
780- .expectNext (1L )
781- .verifyComplete ();
765+ .concatWith (close (connection ))).as (StepVerifier ::create ).expectNext (1L ).verifyComplete ();
782766 } else {
783767
784- this .connectionFactory .create ()
785- .flatMapMany (connection -> connection
768+ this .connectionFactory .create ().flatMapMany (connection -> connection
786769
787- .createStatement ("INSERT INTO test VALUES (" + insertPlaceholder + ")" )
788- .bind ("$1" , Parameters .in (parameterType ))
789- .execute ()
770+ .createStatement ("INSERT INTO test VALUES (" + insertPlaceholder + ")" ).bind ("$1" , Parameters .in (parameterType )).execute ()
790771
791- .flatMap (PostgresqlResult ::getRowsUpdated )
772+ .flatMap (PostgresqlResult ::getRowsUpdated )
792773
793- .concatWith (close (connection )))
794- .as (StepVerifier ::create )
795- .expectNext (1L )
796- .verifyComplete ();
774+ .concatWith (close (connection ))).as (StepVerifier ::create ).expectNext (1L ).verifyComplete ();
797775
798776 SERVER .getJdbcOperations ().execute ("DELETE FROM test" );
799777
800- this .connectionFactory .create ()
801- .flatMapMany (connection -> connection
778+ this .connectionFactory .create ().flatMapMany (connection -> connection
802779
803- .createStatement ("INSERT INTO test VALUES (" + insertPlaceholder + ")" )
804- .bind ("$1" , Parameters .in (parameterType , value ))
805- .execute ()
780+ .createStatement ("INSERT INTO test VALUES (" + insertPlaceholder + ")" ).bind ("$1" , Parameters .in (parameterType , value )).execute ()
806781
807- .flatMap (PostgresqlResult ::getRowsUpdated )
782+ .flatMap (PostgresqlResult ::getRowsUpdated )
808783
809- .concatWith (close (connection )))
810- .as (StepVerifier ::create )
811- .expectNext (1L )
812- .verifyComplete ();
784+ .concatWith (close (connection ))).as (StepVerifier ::create ).expectNext (1L ).verifyComplete ();
813785 }
814786
815787 if (value instanceof Buffer ) {
816788 ((Buffer ) value ).rewind ();
817789 }
818790
819- this .connectionFactory .create ()
820- .flatMapMany (connection -> {
821-
822- PostgresqlStatement statement ;
823- if (insertPlaceholder .equals ("$1" )) {
824- statement = connection
825- // where clause added to force using extended query instead of simple query
826- .createStatement ("SELECT value FROM test WHERE " + insertPlaceholder + " <> 1" )
827- .bind ("$1" , 2 );
828- } else {
829- statement = connection .createStatement ("SELECT value FROM test" );
830- }
831- return statement .execute ()
832-
833- .map (result -> result .map ((row , metadata ) -> row .get ("value" , outType )))
834- .flatMap (Function .identity ())
835-
836- .concatWith (close (connection ));
837- })
838- .as (StepVerifier ::create )
839- .assertNext (r2dbc -> equality .accept (r2dbc , value ))
840- .verifyComplete ();
791+ this .connectionFactory .create ().flatMapMany (connection -> {
792+
793+ PostgresqlStatement statement ;
794+ if (insertPlaceholder .equals ("$1" )) {
795+ statement = connection
796+ // where clause added to force using extended query instead of simple query
797+ .createStatement ("SELECT value FROM test WHERE " + insertPlaceholder + " <> 1" ).bind ("$1" , 2 );
798+ } else {
799+ statement = connection .createStatement ("SELECT value FROM test" );
800+ }
801+ return statement .execute ()
802+
803+ .map (result -> result .map ((row , metadata ) -> row .get ("value" , outType ))).flatMap (Function .identity ())
804+
805+ .concatWith (close (connection ));
806+ }).as (StepVerifier ::create ).assertNext (r2dbc -> equality .accept (r2dbc , value )).verifyComplete ();
841807 } finally {
842808 SERVER .getJdbcOperations ().execute ("DROP TABLE test" );
843809 }
@@ -868,32 +834,21 @@ private <W, R> void testCodecReadAs(W toWrite, Class<R> javaTypeToRead, Consumer
868834 SERVER .getJdbcOperations ().execute (String .format ("CREATE TABLE test (value %s)" , sqlType ));
869835
870836 try {
871- this .connectionFactory .create ()
872- .flatMapMany (connection -> connection
837+ this .connectionFactory .create ().flatMapMany (connection -> connection
873838
874- .createStatement ("INSERT INTO test VALUES ($1)" )
875- .bind ("$1" , toWrite )
876- .execute ()
839+ .createStatement ("INSERT INTO test VALUES ($1)" ).bind ("$1" , toWrite ).execute ()
877840
878- .flatMap (PostgresqlResult ::getRowsUpdated )
841+ .flatMap (PostgresqlResult ::getRowsUpdated )
879842
880- .concatWith (close (connection )))
881- .as (StepVerifier ::create )
882- .expectNext (1L )
883- .verifyComplete ();
843+ .concatWith (close (connection ))).as (StepVerifier ::create ).expectNext (1L ).verifyComplete ();
884844
885- this .connectionFactory .create ()
886- .flatMapMany (connection -> {
887- return connection .createStatement ("SELECT value FROM test" ).execute ()
845+ this .connectionFactory .create ().flatMapMany (connection -> {
846+ return connection .createStatement ("SELECT value FROM test" ).execute ()
888847
889- .map (result -> result .map ((row , metadata ) -> row .get ("value" , javaTypeToRead )))
890- .flatMap (Function .identity ())
848+ .map (result -> result .map ((row , metadata ) -> row .get ("value" , javaTypeToRead ))).flatMap (Function .identity ())
891849
892- .concatWith (close (connection ));
893- })
894- .as (StepVerifier ::create )
895- .assertNext (equality )
896- .verifyComplete ();
850+ .concatWith (close (connection ));
851+ }).as (StepVerifier ::create ).assertNext (equality ).verifyComplete ();
897852 } finally {
898853 SERVER .getJdbcOperations ().execute ("DROP TABLE test" );
899854 }
0 commit comments