72
72
import com .google .datastore .v1 .TransactionOptions ;
73
73
import com .google .datastore .v1 .TransactionOptions .ReadOnly ;
74
74
import java .util .ArrayList ;
75
+ import java .util .Arrays ;
75
76
import java .util .Collections ;
76
77
import java .util .HashSet ;
77
78
import java .util .Iterator ;
88
89
import org .junit .Rule ;
89
90
import org .junit .Test ;
90
91
import org .junit .rules .Timeout ;
92
+ import org .junit .runner .RunWith ;
93
+ import org .junit .runners .Parameterized ;
91
94
92
- // todo: combine this with ITDatastoreTestWithNamedDb once we resolve issues with parameterized
93
- // graalvm tests
95
+ @ RunWith (Parameterized .class )
94
96
public class ITDatastoreTest {
95
97
96
98
private static final RemoteDatastoreHelper HELPER = RemoteDatastoreHelper .create ();
@@ -102,8 +104,8 @@ public class ITDatastoreTest {
102
104
private static final DatastoreOptions OPTIONS_2 = HELPER2 .getOptions ();
103
105
private static final Datastore DATASTORE_2 = OPTIONS_2 .getService ();
104
106
105
- private final DatastoreOptions options = OPTIONS_1 ;
106
- private final Datastore datastore = DATASTORE_1 ;
107
+ private final DatastoreOptions options ;
108
+ private final Datastore datastore ;
107
109
108
110
private static String PROJECT_ID ;
109
111
private static String NAMESPACE ;
@@ -145,8 +147,14 @@ public static void afterClass() {
145
147
HELPER .deleteNamespace ();
146
148
}
147
149
148
- @ Before
149
- public void setUp () {
150
+ public ITDatastoreTest (
151
+ DatastoreOptions options ,
152
+ Datastore datastore ,
153
+ // databaseType is unused as a variable, but used as a parameterized label when running tests
154
+ String databaseType ) {
155
+ this .options = options ;
156
+ this .datastore = datastore ;
157
+
150
158
PROJECT_ID = this .options .getProjectId ();
151
159
NAMESPACE = this .options .getNamespace ();
152
160
@@ -215,7 +223,10 @@ public void setUp() {
215
223
.set ("partial1" , PARTIAL_ENTITY2 )
216
224
.set ("partial2" , ENTITY2 )
217
225
.build ();
226
+ }
218
227
228
+ @ Before
229
+ public void setUp () {
219
230
datastore .put (ENTITY1 , ENTITY2 );
220
231
}
221
232
@@ -228,6 +239,12 @@ public void tearDown() {
228
239
datastore .delete (keysToDelete );
229
240
}
230
241
242
+ @ Parameterized .Parameters (name = "database: {2}" )
243
+ public static Iterable <Object []> data () {
244
+ return Arrays .asList (
245
+ new Object [][] {{OPTIONS_1 , DATASTORE_1 , "default" }, {OPTIONS_2 , DATASTORE_2 , "test-db" }});
246
+ }
247
+
231
248
private <T > Iterator <T > getStronglyConsistentResults (Query scQuery , Query query )
232
249
throws InterruptedException {
233
250
// scQuery is equivalent to query, but with an ancestor filter in it
@@ -272,7 +289,7 @@ public void orQuery() {
272
289
.setNull ("null" )
273
290
.set ("age" , 19 )
274
291
.build ();
275
- DATASTORE .put (entity3 );
292
+ datastore .put (entity3 );
276
293
277
294
// age == 19 || age == 20
278
295
CompositeFilter orFilter =
0 commit comments