File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed
Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 2525 * {@link CallStreamObserver}.
2626 */
2727public final class StreamObservers {
28+ // Prevent instantiation
29+ private StreamObservers () { }
30+
2831 /**
2932 * Utility method to call {@link StreamObserver#onNext(Object)} and
3033 * {@link StreamObserver#onCompleted()} on the specified responseObserver.
3134 */
3235 @ ExperimentalApi ("https://github.com/grpc/grpc-java/issues/10957" )
3336 public static <T > void nextAndComplete (StreamObserver <T > responseObserver , T response ) {
34- Preconditions .checkNotNull (response , "response" );
35-
3637 responseObserver .onNext (response );
3738 responseObserver .onCompleted ();
3839 }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2025 The gRPC 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+ * http://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 .grpc .stub ;
18+
19+ import org .junit .Test ;
20+ import org .mockito .InOrder ;
21+ import org .mockito .Mockito ;
22+
23+ public class StreamObserversTest {
24+
25+ @ Test
26+ public void nextAndComplete () {
27+ StreamObserver <String > observer = Mockito .mock (StreamObserver .class );
28+ InOrder inOrder = Mockito .inOrder (observer );
29+ StreamObservers .nextAndComplete (observer , "TEST" );
30+ inOrder .verify (observer ).onNext ("TEST" );
31+ inOrder .verify (observer ).onCompleted ();
32+ inOrder .verifyNoMoreInteractions ();
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments