FileSystemDataStorage implements DataStorage<R> { @Override public DataAndId<R> getCurrentData() { loadInitialFactory(); StoredDataMetadata storedDataMetadata = migrationManager.readStoredFactoryMetadata(readFile(currentFactoryPathMetadata)); return new DataAndId<>(migrationManager.read(readFile(currentFactoryPath),storedDataMetadata.dataStorageMetadataDictionary), storedDataMetadata.id); } FileSystemDataStorage(Path basePath, R initialData, MigrationManager<R> migrationManager, FileSystemFactoryStorageHistory<R> fileSystemFactoryStorageHistory, SimpleObjectMapper objectMapper);  FileSystemDataStorage(Path basePath, R initialData, MigrationManager<R> migrationManager, SimpleObjectMapper objectMapper);  FileSystemDataStorage(Path basePath, R initialData, MigrationManager<R> migrationManager, SimpleObjectMapper objectMapper, int maxConfigurationHistory); @Override R getHistoryData(String id); @Override Collection<StoredDataMetadata> getHistoryDataList(); @Override Collection<ScheduledUpdateMetadata> getFutureDataList(); @Override void deleteFutureData(String id); @Override R getFutureData(String id); @Override void addFutureData(ScheduledUpdate<R> futureFactory); @Override DataAndId<R> getCurrentData(); @Override void updateCurrentData(DataUpdate<R> update, UpdateSummary changeSummary); @Override void patchAll(DataStoragePatcher consumer); @Override void patchCurrentData(DataStoragePatcher consumer);  }
@Test public void test_init_no_existing_factory() { FileSystemDataStorage<ExampleDataA> fileSystemFactoryStorage = new FileSystemDataStorage<>(Paths.get(folder.toFile().toURI()), createInitialExampleDataA(), createDataMigrationManager(),ObjectMapperBuilder.build()); fileSystemFactoryStorage.getCurrentData(); Assertions.assertTrue(new File(folder.toFile().getAbsolutePath()+"/currentFactory.json").exists()); }
@Test public void test_init_existing_factory() { FileSystemDataStorage<ExampleDataA> fileSystemFactoryStorage = new FileSystemDataStorage<>(Paths.get(folder.toFile().toURI()), createInitialExampleDataA(), createDataMigrationManager(),ObjectMapperBuilder.build()); String id=fileSystemFactoryStorage.getCurrentData().id; Assertions.assertTrue(new File(folder.toFile().getAbsolutePath()+"/currentFactory.json").exists()); FileSystemDataStorage<ExampleDataA> restored = new FileSystemDataStorage<>(Paths.get(folder.toFile().toURI()),null, createDataMigrationManager(),ObjectMapperBuilder.build()); Assertions.assertEquals(id,restored.getCurrentData().id); }