### Question:
VersionedDatabaseFactory implements DatabaseFactory { @Override public Database createDatabase() { LOG.info("Data directory set to: {}", dataDirectory.getAbsolutePath()); validateDataPaths(); final DatabaseVersion dbVersion = getDatabaseVersion(); createDirectories(); saveDatabaseVersion(dbVersion); Database database; switch (dbVersion) { case NOOP: database = new NoOpDatabase(); LOG.trace("Created no-op database"); break; case V3: database = createV3Database(); LOG.trace( "Created V3 database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); break; case V4: database = createV4Database(); LOG.trace( "Created V4 Hot database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); LOG.trace( "Created V4 Finalized database ({}) at {}", dbVersion.getValue(), archiveDirectory.getAbsolutePath()); break; case V5: database = createV5Database(); LOG.trace( "Created V5 Hot database ({}) at {}", dbVersion.getValue(), dbDirectory.getAbsolutePath()); LOG.trace( "Created V5 Finalized database ({}) at {}", dbVersion.getValue(), archiveDirectory.getAbsolutePath()); break; default: throw new UnsupportedOperationException("Unhandled database version " + dbVersion); } return database; } VersionedDatabaseFactory(
      final MetricsSystem metricsSystem,
      final String dataPath,
      final StateStorageMode dataStorageMode,
      final Eth1Address depositContractAddress);  VersionedDatabaseFactory(
      final MetricsSystem metricsSystem,
      final String dataPath,
      final StateStorageMode dataStorageMode,
      final String createDatabaseVersion,
      final long stateStorageFrequency,
      final Eth1Address eth1Address); @Override Database createDatabase(); static final long DEFAULT_STORAGE_FREQUENCY; }### Answer:
@Test public void createDatabase_fromEmptyDataDir() throws Exception { final DatabaseFactory dbFactory = new VersionedDatabaseFactory( new StubMetricsSystem(), dataDir.toString(), DATA_STORAGE_MODE, eth1Address); try (final Database db = dbFactory.createDatabase()) { assertThat(db).isNotNull(); assertDbVersionSaved(dataDir, DatabaseVersion.DEFAULT_VERSION); } }
@Test public void createDatabase_asV4Database() throws Exception { final DatabaseFactory dbFactory = new VersionedDatabaseFactory( new StubMetricsSystem(), dataDir.toString(), DATA_STORAGE_MODE, "4", 1L, eth1Address); try (final Database db = dbFactory.createDatabase()) { assertThat(db).isNotNull(); assertDbVersionSaved(dataDir, DatabaseVersion.V4); } final File dbDirectory = new File(dataDir.toFile(), VersionedDatabaseFactory.DB_PATH); final File archiveDirectory = new File(dataDir.toFile(), VersionedDatabaseFactory.ARCHIVE_PATH); assertThat(dbDirectory).exists(); assertThat(archiveDirectory).exists(); }
@Test public void createDatabase_asV5Database() throws Exception { final DatabaseFactory dbFactory = new VersionedDatabaseFactory( new StubMetricsSystem(), dataDir.toString(), DATA_STORAGE_MODE, "5", 1L, eth1Address); try (final Database db = dbFactory.createDatabase()) { assertThat(db).isNotNull(); assertDbVersionSaved(dataDir, DatabaseVersion.V5); } final File dbDirectory = new File(dataDir.toFile(), VersionedDatabaseFactory.DB_PATH); final File archiveDirectory = new File(dataDir.toFile(), VersionedDatabaseFactory.ARCHIVE_PATH); final File metadataFile = new File(dataDir.toFile(), VersionedDatabaseFactory.METADATA_FILENAME); assertThat(dbDirectory).exists(); assertThat(archiveDirectory).exists(); assertThat(metadataFile).exists(); }