@ -37,7 +37,6 @@ import org.mockito.junit.MockitoJUnitRunner;
@RunWith ( MockitoJUnitRunner . class )
@RunWith ( MockitoJUnitRunner . class )
public class RocksDBKeyValuePrivacyStorageFactoryTest {
public class RocksDBKeyValuePrivacyStorageFactoryTest {
// private static final String METADATA_FILENAME = "DATABASE_METADATA.json";
private static final int DEFAULT_VERSION = 1 ;
private static final int DEFAULT_VERSION = 1 ;
private static final int DEFAULT_PRIVACY_VERSION = 1 ;
private static final int DEFAULT_PRIVACY_VERSION = 1 ;
@ -55,8 +54,6 @@ public class RocksDBKeyValuePrivacyStorageFactoryTest {
final Path tempPrivateDatabaseDir = tempDatabaseDir . resolve ( "private" ) ;
final Path tempPrivateDatabaseDir = tempDatabaseDir . resolve ( "private" ) ;
Files . createDirectories ( tempPrivateDatabaseDir ) ;
Files . createDirectories ( tempPrivateDatabaseDir ) ;
Files . createDirectories ( tempDataDir ) ;
Files . createDirectories ( tempDataDir ) ;
Files . createFile ( tempPrivateDatabaseDir . resolve ( "IDENTITY" ) ) ;
Files . createFile ( tempDatabaseDir . resolve ( "IDENTITY" ) ) ;
when ( commonConfiguration . getStoragePath ( ) ) . thenReturn ( tempDatabaseDir ) ;
when ( commonConfiguration . getStoragePath ( ) ) . thenReturn ( tempDatabaseDir ) ;
when ( commonConfiguration . getDataPath ( ) ) . thenReturn ( tempDataDir ) ;
when ( commonConfiguration . getDataPath ( ) ) . thenReturn ( tempDataDir ) ;
@ -70,21 +67,14 @@ public class RocksDBKeyValuePrivacyStorageFactoryTest {
// Side effect is creation of the Metadata version file
// Side effect is creation of the Metadata version file
storageFactory . create ( segment , commonConfiguration , metricsSystem ) ;
storageFactory . create ( segment , commonConfiguration , metricsSystem ) ;
assertThat (
assertThat ( DatabaseMetadata . lookUpFrom ( commonConfiguration . getDataPath ( ) ) . maybePrivacyVersion ( ) )
DatabaseMetadata . lookUpFrom (
commonConfiguration . getStoragePath ( ) , commonConfiguration . getDataPath ( ) )
. maybePrivacyVersion ( ) )
. isNotEmpty ( ) ;
. isNotEmpty ( ) ;
assertThat (
assertThat ( DatabaseMetadata . lookUpFrom ( commonConfiguration . getDataPath ( ) ) . getVersion ( ) )
DatabaseMetadata . lookUpFrom (
commonConfiguration . getStoragePath ( ) , commonConfiguration . getDataPath ( ) )
. getVersion ( ) )
. isEqualTo ( 0 ) ;
. isEqualTo ( 0 ) ;
assertThat (
assertThat (
DatabaseMetadata . lookUpFrom (
DatabaseMetadata . lookUpFrom ( commonConfiguration . getDataPath ( ) )
commonConfiguration . getStoragePath ( ) , commonConfiguration . getDataPath ( ) )
. maybePrivacyVersion ( )
. maybePrivacyVersion ( )
. get ( ) )
. get ( ) )
. isEqualTo ( 0 ) ;
. isEqualTo ( 0 ) ;
@ -107,21 +97,14 @@ public class RocksDBKeyValuePrivacyStorageFactoryTest {
// Side effect is creation of the Metadata version file
// Side effect is creation of the Metadata version file
storageFactory . create ( segment , commonConfiguration , metricsSystem ) ;
storageFactory . create ( segment , commonConfiguration , metricsSystem ) ;
assertThat (
assertThat ( DatabaseMetadata . lookUpFrom ( commonConfiguration . getDataPath ( ) ) . maybePrivacyVersion ( ) )
DatabaseMetadata . lookUpFrom (
commonConfiguration . getStoragePath ( ) , commonConfiguration . getDataPath ( ) )
. maybePrivacyVersion ( ) )
. isNotEmpty ( ) ;
. isNotEmpty ( ) ;
assertThat (
assertThat ( DatabaseMetadata . lookUpFrom ( commonConfiguration . getDataPath ( ) ) . getVersion ( ) )
DatabaseMetadata . lookUpFrom (
commonConfiguration . getStoragePath ( ) , commonConfiguration . getDataPath ( ) )
. getVersion ( ) )
. isEqualTo ( DEFAULT_VERSION ) ;
. isEqualTo ( DEFAULT_VERSION ) ;
assertThat (
assertThat (
DatabaseMetadata . lookUpFrom (
DatabaseMetadata . lookUpFrom ( commonConfiguration . getDataPath ( ) )
commonConfiguration . getStoragePath ( ) , commonConfiguration . getDataPath ( ) )
. maybePrivacyVersion ( )
. maybePrivacyVersion ( )
. get ( ) )
. get ( ) )
. isEqualTo ( DEFAULT_PRIVACY_VERSION ) ;
. isEqualTo ( DEFAULT_PRIVACY_VERSION ) ;
@ -140,16 +123,10 @@ public class RocksDBKeyValuePrivacyStorageFactoryTest {
storageFactory . create ( segment , commonConfiguration , metricsSystem ) ;
storageFactory . create ( segment , commonConfiguration , metricsSystem ) ;
assertThat (
assertThat ( DatabaseMetadata . lookUpFrom ( commonConfiguration . getDataPath ( ) ) . maybePrivacyVersion ( ) )
DatabaseMetadata . lookUpFrom (
commonConfiguration . getStoragePath ( ) , commonConfiguration . getDataPath ( ) )
. maybePrivacyVersion ( ) )
. isEmpty ( ) ;
. isEmpty ( ) ;
assertThat (
assertThat ( DatabaseMetadata . lookUpFrom ( commonConfiguration . getDataPath ( ) ) . getVersion ( ) )
DatabaseMetadata . lookUpFrom (
commonConfiguration . getStoragePath ( ) , commonConfiguration . getDataPath ( ) )
. getVersion ( ) )
. isEqualTo ( DEFAULT_VERSION ) ;
. isEqualTo ( DEFAULT_VERSION ) ;
final RocksDBKeyValuePrivacyStorageFactory privacyStorageFactory =
final RocksDBKeyValuePrivacyStorageFactory privacyStorageFactory =
@ -157,15 +134,11 @@ public class RocksDBKeyValuePrivacyStorageFactoryTest {
privacyStorageFactory . create ( segment , commonConfiguration , metricsSystem ) ;
privacyStorageFactory . create ( segment , commonConfiguration , metricsSystem ) ;
assertThat (
assertThat ( DatabaseMetadata . lookUpFrom ( commonConfiguration . getDataPath ( ) ) . maybePrivacyVersion ( ) )
DatabaseMetadata . lookUpFrom (
commonConfiguration . getStoragePath ( ) , commonConfiguration . getDataPath ( ) )
. maybePrivacyVersion ( ) )
. isNotEmpty ( ) ;
. isNotEmpty ( ) ;
assertThat (
assertThat (
DatabaseMetadata . lookUpFrom (
DatabaseMetadata . lookUpFrom ( commonConfiguration . getDataPath ( ) )
commonConfiguration . getStoragePath ( ) , commonConfiguration . getDataPath ( ) )
. maybePrivacyVersion ( )
. maybePrivacyVersion ( )
. get ( ) )
. get ( ) )
. isEqualTo ( DEFAULT_PRIVACY_VERSION ) ;
. isEqualTo ( DEFAULT_PRIVACY_VERSION ) ;