Motor extends Observable { public synchronized void setRPM(int rpm) { if (rpm < 0 || rpm > SimulationConstants.MAX_MOTOR_SPEED) { throw new IllegalArgumentException("Motor RPM needs to be in range 0 to 3000"); } this.rpm = rpm; setChanged(); notifyObservers(); } Motor(int initialRpm); synchronized void setRPM(int rpm); int getRPM(); synchronized void reset();  }
@Test(expected = IllegalArgumentException.class) public void testTooBig() { motor.setRPM(SimulationConstants.MAX_MOTOR_SPEED + 1); }
@Test(expected = IllegalArgumentException.class) public void testNegative() { motor.setRPM(-1); }
@Test public void testObserver() { motor.addObserver(this); motor.setRPM(5); assertTrue(observed); }