You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StrictWorkMonitor.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (C) 2017 Google Inc. and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.junit;
  11. import static org.junit.Assert.assertEquals;
  12. import org.eclipse.jgit.lib.ProgressMonitor;
  13. /**
  14. * Strict work monitor
  15. */
  16. public final class StrictWorkMonitor implements ProgressMonitor {
  17. private int lastWork, totalWork;
  18. /** {@inheritDoc} */
  19. @Override
  20. public void start(int totalTasks) {
  21. // empty
  22. }
  23. /** {@inheritDoc} */
  24. @Override
  25. public void beginTask(String title, int total) {
  26. this.totalWork = total;
  27. lastWork = 0;
  28. }
  29. /** {@inheritDoc} */
  30. @Override
  31. public void update(int completed) {
  32. lastWork += completed;
  33. }
  34. /** {@inheritDoc} */
  35. @Override
  36. public void endTask() {
  37. assertEquals("Units of work recorded", totalWork, lastWork);
  38. }
  39. /** {@inheritDoc} */
  40. @Override
  41. public boolean isCancelled() {
  42. return false;
  43. }
  44. }