@@ -2222,7 +2222,7 @@ private synchronized String setupTestDocuments() {
22222222
22232223 WaitFor .Condition collectionAvailable =
22242224 new WaitForCollectionAvailable (environmentId , collectionId );
2225- WaitFor .waitFor (collectionAvailable , 10 , TimeUnit .SECONDS , 500 );
2225+ WaitFor .waitFor (collectionAvailable , 1 , TimeUnit .MINUTES , 500 );
22262226
22272227 return collectionId ;
22282228 }
@@ -2316,9 +2316,20 @@ private class WaitForCollectionAvailable implements WaitFor.Condition {
23162316
23172317 @ Override
23182318 public boolean isSatisfied () {
2319- GetCollectionOptions getOptions =
2320- new GetCollectionOptions .Builder (environmentId , collectionId ).build ();
2321- String status = discovery .getCollection (getOptions ).execute ().getResult ().getStatus ();
2319+ String status = "" ;
2320+ try {
2321+ // In a successful case, you can grab the ID with the following code.
2322+ GetCollectionOptions getOptions =
2323+ new GetCollectionOptions .Builder (environmentId , collectionId ).build ();
2324+ Collection collectionResult = discovery .getCollection (getOptions ).execute ().getResult ();
2325+ status = collectionResult .getStatus ();
2326+ } catch (ServiceResponseException e ) {
2327+ // This is how you get the ID from a failed request.
2328+ // Make sure to use the ServiceResponseException class or one of its subclasses!
2329+ String transactionId = e .getHeaders ().values ("x-global-transaction-id" ).get (0 );
2330+ System .out .println ("x-global-transcation-id: " +transactionId );
2331+ System .err .println ("x-global-transcation-id: " +transactionId );
2332+ }
23222333 return status .equals (Collection .Status .ACTIVE );
23232334 }
23242335
0 commit comments