### Question:
DashboardLayoutService { public static TransferDashboardLayout layoutDashboard( final Transfer transfer) { if (transfer == null) { throw new IllegalArgumentException("null transfer"); } TransferDashboardLayout layout = new TransferDashboardLayout(); layout.setTotalMilliseconds(transfer.computeTotalTransferTime()); if (transfer.getTransferAttempts().isEmpty()) { return layout; } float totalWidth = 0; float totalFiles = transfer.getTransferAttempts().get(0) .getTotalFilesCount(); DashboardAttempt dashboardAttempt; List<DashboardAttempt> dashboardAttempts = new ArrayList<DashboardAttempt>(); for (TransferAttempt attempt : transfer.getTransferAttempts()) { dashboardAttempt = new DashboardAttempt(); dashboardAttempt.setTransferAttempt(attempt); dashboardAttempt.setPercentWidth(60000 + attempt .computeTotalTimeInMillis()); dashboardAttempts.add(dashboardAttempt); totalWidth += dashboardAttempt.getPercentWidth(); float skipHeight = attempt.getTotalFilesSkippedSoFar() / totalFiles; float successHeight = (attempt.getTotalFilesTransferredSoFar() - attempt .getTotalFilesSkippedSoFar()) / totalFiles; float errorHeight = attempt.getTotalFilesErrorSoFar() / totalFiles; int percentHeightError = Math.round(errorHeight * 100); if (errorHeight > 0 && percentHeightError == 0) { percentHeightError = 2; } dashboardAttempt.setPercentHeightError(percentHeightError); int percentHeightSkip = Math.round(skipHeight * 100); if (skipHeight > 0 && percentHeightSkip == 0) { percentHeightSkip = 2; } dashboardAttempt.setPercentHeightSkipped(percentHeightSkip); int percentHeightTransferred = Math.round(successHeight * 100); if (successHeight > 0 && percentHeightTransferred == 0) { percentHeightTransferred = 2; } dashboardAttempt .setPercentHeightTransferred(percentHeightTransferred); } for (DashboardAttempt attempt : dashboardAttempts) { if (totalWidth == 0) { attempt.setPercentWidth(transfer.getTransferAttempts().size() / 100); } else { float computed = (attempt.getPercentWidth() / totalWidth); log.info("width this:{}", attempt.getPercentWidth()); log.info("total:{}", totalWidth); attempt.setPercentWidth(Math.round(computed * 100)); log.info("computed pct width()", computed); } } layout.setDashboardAttempts(dashboardAttempts); return layout; }  static TransferDashboardLayout layoutDashboard(
            final Transfer transfer); static org.slf4j.Logger log; }### Answer:
@Test public void testLayoutDashboard() throws Exception { System.out.println("layoutDashboard"); Transfer transfer = new Transfer(); TransferAttempt attempt = new TransferAttempt(); attempt.setAttemptStart(new Date()); attempt.setTotalFilesCount(100); Thread.sleep(1000); attempt.setAttemptEnd(new Date()); attempt.setTotalFilesErrorSoFar(10); attempt.setTotalFilesSkippedSoFar(20); attempt.setTotalFilesTransferredSoFar(30); long millis = attempt.getAttemptEnd().getTime() - attempt.getAttemptStart().getTime(); transfer.getTransferAttempts().add(attempt); attempt = new TransferAttempt(); attempt.setAttemptStart(new Date()); Thread.sleep(1000); attempt.setAttemptEnd(new Date()); transfer.getTransferAttempts().add(attempt); millis += attempt.getAttemptEnd().getTime() - attempt.getAttemptStart().getTime(); TransferDashboardLayout result = DashboardLayoutService.layoutDashboard(transfer); Assert.assertNotNull("null result", result); Assert.assertEquals("did not compute total time", millis, result.getTotalMilliseconds()); }