### Question:
ProgressHandler { public void postSteps(final int steps) { currentStep.postSteps(steps); } ProgressHandler(AbstractTask<?> t,
            double begin,
            double end,
            int steps);  ProgressHandler(AbstractTask<?> t, int steps);  ProgressHandler(final AbstractTask<?> task,
        final double begin, 
        final double end);  ProgressHandler(AbstractTask<?> t); void setMinProgressIncrement(final double minInc); void setMinTimeIncrement(final long ms); void postMessage(final String msg); void postFraction(final double fraction); void postStep(); void postSteps(final int steps); void postEnd(); void postIndeterminate(); void subsection(final double fraction); void subsection(final double fraction, final int steps); void subsection(final int steps); void subsection(); void postBegin(); double getCurrentProgress(); static final double DEFAULT_START_VALUE; static final double DEFAULT_END_VALUE; static final double DEFAULT_MIN_PROGRESS_INC; static final long DEFAULT_MIN_TIME_INC; }### Answer:
@Test public void testPostSteps() throws InterruptedException { final List<Integer> stepsToPost = Arrays.asList(2, 4, 5, 7, 3, 2, 6); final Integer totalSteps = stepsToPost.stream().mapToInt(n -> n.intValue()).sum(); final List<Double> expectedProgress = new ArrayList<>(); stepsToPost.forEach(n -> { double d = ((double) n.intValue())/totalSteps; if (expectedProgress.size() > 0) { d += expectedProgress.get(expectedProgress.size() - 1); } expectedProgress.add(d); }); Task<Void> task = new AbstractTask<Void> () { @Override protected Void doTask() throws Exception { ProgressHandler ph = new ProgressHandler(this, 0.0, 1.0, totalSteps); ph.postBegin(); stepsToPost.forEach(ph::postSteps); ph.postEnd(); return null; } @Override public String taskName() { return "testPostSteps() task"; } }; final List<Double> progressReceived = new ArrayList<>(); task.addTaskListener(new TaskAdapter() { @Override public void taskProgress(TaskEvent evt) { progressReceived.add(evt.getProgress()); } }); Thread t = new Thread(task); t.start(); t.join(); assertThat(progressReceived.size(), is(equalTo(expectedProgress.size() + 2))); for (int i=0; i<expectedProgress.size(); i++) { assertEquals(expectedProgress.get(i), progressReceived.get(i+1), 1.0e-10); } }