### Question:
ButtonMonitor { public void update() { boolean down = isDown(); pressed = !wasDown && down; released = wasDown && !down; holded = down && !pressed; wasDown = down; }  void update(); boolean isPressed(); boolean isReleased(); boolean isHolded(); boolean status(Status status);  }### Answer:
@Test public void keepReleased() { monitor.down = false; monitor.update(); monitor.down = true; monitor.update(); monitor.down = true; monitor.update(); monitor.down = false; monitor.update(); monitor.down = false; monitor.update(); assertThat(monitor, MonitorMatcher.monitor(false, false, false)); }
@Test public void pressReleaseWithoutHold() { monitor.down = false; monitor.update(); monitor.down = true; monitor.update(); monitor.down = false; monitor.update(); assertThat(monitor, MonitorMatcher.monitor(false, true, false)); }
@Test public void bugWithPressedAndReleasedAtTheSameTime() { monitor.down = true; monitor.update(); assertThat(monitor, MonitorMatcher.monitor(true, false, false)); monitor.down = false; monitor.update(); assertThat(monitor, MonitorMatcher.monitor(false, true, false)); monitor.down = true; monitor.update(); assertThat(monitor, MonitorMatcher.monitor(true, false, false)); }
@Test public void nothingEverPressed() { monitor.down = false; monitor.update(); assertThat(monitor, MonitorMatcher.monitor(false, false, false)); }
@Test public void whenFirstPresed() { monitor.down = false; monitor.update(); monitor.down = true; monitor.update(); assertThat(monitor, MonitorMatcher.monitor(true, false, false)); }
@Test public void holding() { monitor.down = false; monitor.update(); monitor.down = true; monitor.update(); monitor.down = true; monitor.update(); assertThat(monitor, MonitorMatcher.monitor(false, false, true)); }
@Test public void released() { monitor.down = false; monitor.update(); monitor.down = true; monitor.update(); monitor.down = true; monitor.update(); monitor.down = false; monitor.update(); assertThat(monitor, MonitorMatcher.monitor(false, true, false)); }