### Question:
HttpCopier implements PushToCloudCommand.Copier { int importStatusProgressEstimate( String databaseStatus, long elapsed, long importTimeEstimateMillis ) throws CommandFailed { switch ( databaseStatus ) { case "running": return 0; case "loading": int loadProgressEstimation = (int) Math.min( 98, (elapsed * 98) / importTimeEstimateMillis ); return 1 + loadProgressEstimation; default: throw new CommandFailed( String.format( "We're sorry, something has failed during the loading of your database. " + "Please try again and if this problem persists, please open up a support case. Database status: %s", databaseStatus ) ); } } HttpCopier( OutsideWorld outsideWorld );   HttpCopier( OutsideWorld outsideWorld, Sleeper sleeper, ProgressListenerFactory progressListenerFactory ); @Override void copy( boolean verbose, String consoleURL, String boltUri, Path source, boolean deleteSourceAfterImport, String bearerToken ); @Override String authenticate( boolean verbose, String consoleUrl, String username, char[] password, boolean consentConfirmed );  }### Answer:
@Test public void shouldEstimateImportProgressBased() throws IOException, InterruptedException, CommandFailed { HttpCopier.Sleeper sleeper = mock( HttpCopier.Sleeper.class ); HttpCopier copier = new HttpCopier( new ControlledOutsideWorld( fs ), sleeper, NO_OP_PROGRESS ); assertEquals( 0, copier.importStatusProgressEstimate( "running", 1234500000L, 6789000000L ) ); assertEquals( 1, copier.importStatusProgressEstimate( "loading", 0, 1234567890 ) ); assertEquals( 2, copier.importStatusProgressEstimate( "loading", 1, 98 ) ); assertEquals( 50, copier.importStatusProgressEstimate( "loading", 49, 98 ) ); assertEquals( 98, copier.importStatusProgressEstimate( "loading", 97, 98 ) ); assertEquals( 99, copier.importStatusProgressEstimate( "loading", 98, 98 ) ); assertEquals( 99, copier.importStatusProgressEstimate( "loading", 99, 98 ) ); assertEquals( 99, copier.importStatusProgressEstimate( "loading", 100, 98 ) ); assertEquals( 1, copier.importStatusProgressEstimate( "loading", 1, 196 ) ); assertEquals( 2, copier.importStatusProgressEstimate( "loading", 2, 196 ) ); assertEquals( 50, copier.importStatusProgressEstimate( "loading", 98, 196 ) ); }