@@ -157,40 +157,43 @@ private void assertMonotonicityOfIds(String prefix, List<XGoogSpannerRequestId>
157
157
+ String .join ("\n \t " , violations .toArray (new String [0 ])));
158
158
}
159
159
160
- public static class methodAndRequestId {
161
- String method ;
162
- String requestId ;
163
-
164
- public methodAndRequestId (String method , String requestId ) {
165
- this .method = method ;
166
- this .requestId = requestId ;
167
- }
168
-
169
- public String toString () {
170
- return "{" + this .method + ":" + this .requestId + "}" ;
171
- }
172
- }
173
-
174
- public methodAndRequestId [] accumulatedUnaryValues () {
175
- List <methodAndRequestId > accumulated = new ArrayList ();
160
+ public MethodAndRequestId [] accumulatedUnaryValues () {
161
+ List <MethodAndRequestId > accumulated = new ArrayList ();
176
162
this .unaryResults .forEach (
177
163
(String method , CopyOnWriteArrayList <XGoogSpannerRequestId > values ) -> {
178
164
for (int i = 0 ; i < values .size (); i ++) {
179
- accumulated .add (new methodAndRequestId (method , values .get (i ).toString ()));
165
+ accumulated .add (new MethodAndRequestId (method , values .get (i ).toString ()));
180
166
}
181
167
});
182
- return accumulated .toArray (new methodAndRequestId [0 ]);
168
+ return accumulated .toArray (new MethodAndRequestId [0 ]);
183
169
}
184
170
185
- public methodAndRequestId [] accumulatedStreamingValues () {
186
- List <methodAndRequestId > accumulated = new ArrayList ();
171
+ public MethodAndRequestId [] accumulatedStreamingValues () {
172
+ List <MethodAndRequestId > accumulated = new ArrayList ();
187
173
this .streamingResults .forEach (
188
174
(String method , CopyOnWriteArrayList <XGoogSpannerRequestId > values ) -> {
189
175
for (int i = 0 ; i < values .size (); i ++) {
190
- accumulated .add (new methodAndRequestId (method , values .get (i ).toString ()));
176
+ accumulated .add (new MethodAndRequestId (method , values .get (i ).toString ()));
191
177
}
192
178
});
193
- return accumulated .toArray (new methodAndRequestId [0 ]);
179
+ return accumulated .toArray (new MethodAndRequestId [0 ]);
180
+ }
181
+
182
+ public void checkExpectedUnaryXGoogRequestIds (MethodAndRequestId ... wantUnaryValues ) {
183
+ MethodAndRequestId [] gotUnaryValues = this .accumulatedUnaryValues ();
184
+ System .out .println ("\033 [34mUnary: " + gotUnaryValues + "\033 [00m" );
185
+ for (int i = 0 ; i < gotUnaryValues .length ; i ++) {
186
+ System .out .println ("ith: " + i + ":: " + gotUnaryValues [i ]);
187
+ }
188
+ assertEquals (wantUnaryValues , gotUnaryValues );
189
+ }
190
+
191
+ public void checkExpectedStreamingXGoogRequestIds (MethodAndRequestId ... wantStreamingValues ) {
192
+ MethodAndRequestId [] gotStreamingValues = this .accumulatedStreamingValues ();
193
+ for (int i = 0 ; i < gotStreamingValues .length ; i ++) {
194
+ System .out .println ("ith: " + i + ":: " + gotStreamingValues [i ]);
195
+ }
196
+ assertEquals (wantStreamingValues , gotStreamingValues );
194
197
}
195
198
196
199
public void reset () {
@@ -199,4 +202,27 @@ public void reset() {
199
202
this .streamingResults .clear ();
200
203
}
201
204
}
205
+
206
+ public static class MethodAndRequestId {
207
+ String method ;
208
+ String requestId ;
209
+
210
+ public MethodAndRequestId (String method , String requestId ) {
211
+ this .method = method ;
212
+ this .requestId = requestId ;
213
+ }
214
+
215
+ public String toString () {
216
+ return "{" + this .method + ":" + this .requestId + "}" ;
217
+ }
218
+ }
219
+
220
+ public static MethodAndRequestId ofMethodAndRequestId (String method , String reqId ) {
221
+ return new MethodAndRequestId (method , reqId );
222
+ }
223
+
224
+ public static MethodAndRequestId ofMethodAndRequestId (
225
+ String method , XGoogSpannerRequestId reqId ) {
226
+ return new MethodAndRequestId (method , reqId .toString ());
227
+ }
202
228
}
0 commit comments