Skip to content

Commit 70a2134

Browse files
committed
Extract helper for export+import
1 parent 7273d25 commit 70a2134

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePathImportDataTest.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,7 @@ void importComprehensiveData() {
125125
context.commit();
126126
}
127127

128-
// Export the data
129-
final List<DataInKeySpacePath> exportedData = getExportedData(root.path("company"));
130-
131-
// Clear the data and import it back
132-
clearPath(database, root.path("company"));
133-
134-
// Import the data
135-
importData(database, root.path("company"), exportedData);
128+
copyData(root.path("company"));
136129

137130
// Verify all different KeyType values were handled correctly during import
138131
try (FDBRecordContext context = database.openContext()) {
@@ -211,11 +204,7 @@ void importDataWithDirectoryLayer() {
211204
final KeySpacePath dataPath = root.path("tenant").add("user_id", 999L);
212205
setSingleKey(dataPath, Tuple.from("data"), Tuple.from("directory_test"));
213206

214-
List<DataInKeySpacePath> exportedData = getExportedData(root.path("tenant"));
215-
216-
clearPath(database, root.path("tenant"));
217-
218-
importData(database, root.path("tenant"), exportedData);
207+
copyData(root.path("tenant"));
219208

220209
verifySingleKey(dataPath, Tuple.from("data"), Tuple.from("directory_test"));
221210
}
@@ -341,11 +330,9 @@ void importDataWithWrapperClasses() {
341330
final EnvironmentKeySpace keySpace = EnvironmentKeySpace.setupSampleData(database);
342331

343332
EnvironmentKeySpace.DataPath dataStore = keySpace.root().userid(100L).application("app1").dataStore();
344-
List<DataInKeySpacePath> exportedData = getExportedData(dataStore);
345333

346-
clearPath(database, keySpace.root());
334+
copyData(keySpace.root());
347335

348-
importData(database, keySpace.root(), exportedData);
349336
verifySingleKey(dataStore, Tuple.from("record2", 0), Tuple.from("user100_app1_data2_0"));
350337
}
351338

@@ -404,6 +391,17 @@ private static Tuple getTuple(final FDBRecordContext context, final byte[] key)
404391
return Tuple.fromBytes(context.ensureActive().get(key).join());
405392
}
406393

394+
private void copyData(final KeySpacePath path) {
395+
// Export the data
396+
final List<DataInKeySpacePath> exportedData = getExportedData(path);
397+
398+
// Clear the data and import it back
399+
clearPath(database, path);
400+
401+
// Import the data
402+
importData(database, path, exportedData);
403+
}
404+
407405
private static void importData(final FDBDatabase database, final KeySpacePath path, final List<DataInKeySpacePath> exportedData) {
408406
try (FDBRecordContext context = database.openContext()) {
409407
path.importData(context, exportedData).join();

0 commit comments

Comments
 (0)