CommDeviceBuilder { public CommDeviceBuilder setMaxRange(double range) { checkRangeIsPositive(range); deviceMaxRange = Optional.of(range); return this; } CommDeviceBuilder(CommModel m, CommUser u); CommDeviceBuilder setReliability(double reliability); CommDeviceBuilder setMaxRange(double range); CommDevice build();  }
@Test public void testSetMaxRange() { boolean fail = false; try { builder.setMaxRange(-.0000001); } catch (final IllegalArgumentException e) { fail = true; } assertTrue(fail); assertEquals(10d, builder.setMaxRange(10).build().getMaxRange().get(), 0); setUp(); assertEquals(Optional.absent(), builder.build().getMaxRange()); }