/** * Gets the default replacers. * * @param progressBarWidth * the width of the progress bar * @return the configured replacers */ public static Set<Replacer> getDefaultReplacers(final int progressBarWidth) { return ImmutableSet.of( new BarReplacer(progressBarWidth), new PercentageReplacer(), new RemainingTimeReplacer(), new ElapsedTimeReplacer(), new TotalTimeReplacer() ); }
private String getActualProgressBar(final Progress progress) { String bar = outputFormat; for (final Replacer replacer : replacers) { final String identifier = replacer.getReplaceIdentifier(); if (!bar.contains(identifier)) { continue; } bar = bar.replace(identifier, replacer.getReplacementForProgress(progress)); } return bar; }
@Test(dataProvider = "getExampleTotalTimeContents") public final void testElapsedTimeReplacer(final Progress progress, final String expectedContent) { final ElapsedTimeReplacer replacer = new ElapsedTimeReplacer(); Assert.assertEquals(replacer.getReplacementForProgress(progress), expectedContent); } }
@Test(dataProvider = "getExampleRemainingTimeContents") public final void testRemaingingTimeReplacer(final Progress progress, final String expectedContent) { final RemainingTimeReplacer replacer = new RemainingTimeReplacer(); Assert.assertEquals(replacer.getReplacementForProgress(progress), expectedContent); } }
@Test(dataProvider = "getExamplePercentageContents") public final void testPercentageReplacer(final Progress progress, final String expectedContent) { final PercentageReplacer replacer = new PercentageReplacer(); Assert.assertEquals(replacer.getReplacementForProgress(progress), expectedContent); } }
@Test(dataProvider = "getExampleBarContents") public final void testBarReplacer(final Progress progress, final String expectedContent) { final BarReplacer replacer = new BarReplacer(5); Assert.assertEquals(replacer.getReplacementForProgress(progress), expectedContent); } }
@Test(dataProvider = "getExampleTotalTimeContents") public final void testTotalTimeReplacer(final Progress progress, final String expectedContent) { final TotalTimeReplacer replacer = new TotalTimeReplacer(); Assert.assertEquals(replacer.getReplacementForProgress(progress), expectedContent); } }
/** * Gets the default replacers. * * @param progressBarWidth * the width of the progress bar * @return the configured replacers */ public static Set<Replacer> getDefaultReplacers(final int progressBarWidth) { return ImmutableSet.of( new BarReplacer(progressBarWidth), new PercentageReplacer(), new RemainingTimeReplacer(), new ElapsedTimeReplacer(), new TotalTimeReplacer() ); }
private String getActualProgressBar(final Progress progress) { String bar = outputFormat; for (final Replacer replacer : replacers) { final String identifier = replacer.getReplaceIdentifier(); if (!bar.contains(identifier)) { continue; } bar = bar.replace(identifier, replacer.getReplacementForProgress(progress)); } return bar; }