1
1
package com .authenteq ;
2
2
3
+ import com .authenteq .api .StatusException ;
3
4
import com .authenteq .api .StatusesApi ;
4
5
import com .authenteq .model .Status ;
6
+ import com .authenteq .model .StatusCode ;
5
7
import com .authenteq .model .Transaction ;
6
8
7
9
import java .io .FileInputStream ;
15
17
import java .util .UUID ;
16
18
17
19
/**
18
- * Test scafolding and configuration
20
+ * Test scaffolding and configuration
19
21
*
20
- * With reespect to test.properties:
22
+ * With respect to test.properties:
21
23
*
22
24
* There is a default test.properties file in test/resources
23
25
* If you wish to use different properties you can set the environment variable "BDB_DRIVER_PROPERTIES" to point to a file, the
@@ -131,7 +133,7 @@ protected static String getEnv( final String envKey, final String otherwise )
131
133
* @return the status
132
134
* @throws IOException network error
133
135
*/
134
- protected Status getStatus ( final Transaction transaction ) throws IOException
136
+ protected Status getStatus ( final Transaction transaction ) throws IOException , StatusException
135
137
{
136
138
return getStatus ( transaction , getInt ( "test.status.retries" , 60 ) );
137
139
}
@@ -144,17 +146,30 @@ protected Status getStatus( final Transaction transaction ) throws IOException
144
146
* @return the status
145
147
* @throws IOException network error
146
148
*/
147
- protected Status getStatus ( final Transaction transaction , final int attempts ) throws IOException
149
+ protected Status getStatus ( final Transaction transaction , final int attempts ) throws IOException , StatusException
148
150
{
151
+ return getStatus ( transaction , attempts , StatusCode .VALID );
152
+ }
153
+
154
+ /**
155
+ * Poll for transaction status
156
+ *
157
+ * @param transaction transaction to check the status of
158
+ * @param attempts how many tries while waiting for validation
159
+ * @return the status
160
+ * @throws IOException network error
161
+ */
162
+ protected Status getStatus ( final Transaction transaction , final int attempts , final StatusCode expectedStatus ) throws IOException , StatusException
163
+ {
164
+ Status status = null ;
149
165
for ( int idx = 0 ; idx < attempts ; idx ++ ) {
150
- Status status = StatusesApi .getTransactionStatus ( transaction .getId () );
151
- if ( status .getStatus ().equalsIgnoreCase ( "valid" ) )
166
+ status = StatusesApi .getTransactionStatus ( transaction .getId () );
167
+ System .err .println ( " status " + status );
168
+ if ( status .getStatus ().equals ( expectedStatus ) )
152
169
return status ;
153
170
}
154
171
155
- Status invalid = new Status ();
156
- invalid .setStatus ( "timeout" );
157
- return invalid ;
172
+ throw new RuntimeException ( "Could not get valid status, last status " + status + " after " + attempts + " attempts " );
158
173
}
159
174
160
175
/**
0 commit comments