### Question:
LogVersionUpgradeChecker { public static void check( LogTailScanner tailScanner, Config config ) throws UpgradeNotAllowedByConfigurationException { if ( !config.get( GraphDatabaseSettings.allow_upgrade ) ) { LogEntryVersion latestLogEntryVersion = tailScanner.getTailInformation().latestLogEntryVersion; if ( latestLogEntryVersion != null && LogEntryVersion.moreRecentVersionExists( latestLogEntryVersion ) ) { String message = "The version you're upgrading to is using a new transaction log format. This is a " + "non-reversible upgrade and you wont be able to downgrade after starting"; throw new UpgradeNotAllowedByConfigurationException( message ); } } } private  LogVersionUpgradeChecker(); static void check( LogTailScanner tailScanner, Config config );  }### Answer:
@Test public void noThrowWhenLatestVersionAndUpgradeIsNotAllowed() { when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.CURRENT ) ); LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "false") ); }
@Test public void throwWhenVersionIsOlderAndUpgradeIsNotAllowed() { when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.V2_3 ) ); expect.expect( UpgradeNotAllowedByConfigurationException.class ); LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "false") ); }
@Test public void stillAcceptLatestVersionWhenUpgradeIsAllowed() { when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.CURRENT ) ); LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "true") ); }
@Test public void acceptOlderLogsWhenUpgradeIsAllowed() { when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.V2_3 ) ); LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "true") ); }