Pipe extends Observable { public synchronized void setValveThreshold(byte threshold) { if (threshold > 100 || threshold < 0) { throw new IllegalArgumentException("Valve threshold needs to be in range 0 to 100"); } this.threshold = threshold; setChanged(); notifyObservers(); } Pipe(float crosssection, int length, byte defaultThreshold); synchronized Liquid putIn(Liquid liquid); synchronized void setValveThreshold(byte threshold); byte getValveThreshold(); float getMaxInput(); synchronized void reset(); boolean isLiquidEntering();  }
@Test(expected = IllegalArgumentException.class) public void tooHighThreshold() { pipe.setValveThreshold((byte) 101); }
@Test(expected = IllegalArgumentException.class) public void tooLowThreshold() { pipe.setValveThreshold((byte) -1); }