|
| 1 | +/* |
| 2 | + * Copyright 2023 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package io.r2dbc.postgresql; |
| 18 | + |
| 19 | +import io.r2dbc.spi.Result; |
| 20 | +import org.junit.jupiter.api.Test; |
| 21 | +import reactor.core.publisher.Mono; |
| 22 | +import reactor.test.StepVerifier; |
| 23 | + |
| 24 | +/** |
| 25 | + * Integration tests {@link Result.Segment}. |
| 26 | + */ |
| 27 | +final class SegmentIntegrationTests extends AbstractIntegrationTests { |
| 28 | + |
| 29 | + @Test |
| 30 | + void shouldConsumeNotice() { |
| 31 | + |
| 32 | + this.connection.createStatement("DO language plpgsql $$\n" + |
| 33 | + "BEGIN\n" + |
| 34 | + " RAISE NOTICE 'hello, world!';\n" + |
| 35 | + "END\n" + |
| 36 | + "$$;").execute().flatMap(it -> it.flatMap(segment -> { |
| 37 | + if (segment instanceof Result.Message) { |
| 38 | + return Mono.just(((Result.Message) segment).message()); |
| 39 | + } |
| 40 | + return Mono.empty(); |
| 41 | + })).as(StepVerifier::create) |
| 42 | + .expectNext("hello, world!") |
| 43 | + .verifyComplete(); |
| 44 | + } |
| 45 | + |
| 46 | +} |
0 commit comments