@@ -157,40 +157,43 @@ private void assertMonotonicityOfIds(String prefix, List<XGoogSpannerRequestId>
157157 + String .join ("\n \t " , violations .toArray (new String [0 ])));
158158 }
159159
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 ();
176162 this .unaryResults .forEach (
177163 (String method , CopyOnWriteArrayList <XGoogSpannerRequestId > values ) -> {
178164 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 ()));
180166 }
181167 });
182- return accumulated .toArray (new methodAndRequestId [0 ]);
168+ return accumulated .toArray (new MethodAndRequestId [0 ]);
183169 }
184170
185- public methodAndRequestId [] accumulatedStreamingValues () {
186- List <methodAndRequestId > accumulated = new ArrayList ();
171+ public MethodAndRequestId [] accumulatedStreamingValues () {
172+ List <MethodAndRequestId > accumulated = new ArrayList ();
187173 this .streamingResults .forEach (
188174 (String method , CopyOnWriteArrayList <XGoogSpannerRequestId > values ) -> {
189175 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 ()));
191177 }
192178 });
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 );
194197 }
195198
196199 public void reset () {
@@ -199,4 +202,27 @@ public void reset() {
199202 this .streamingResults .clear ();
200203 }
201204 }
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+ }
202228}
0 commit comments