Pin { public void enable() throws PinCommandException { command.enable(this); this.enabled = true; } Pin(String code, Mode mode, PinCommand command);  Pin(String code, File path, Mode mode, PinCommand command);  Pin(String code, PinCommand command);  Pin(String code, File path, PinCommand command); String getCode(); File getPath(); Mode getMode(); void setMode(Mode mode); void write(boolean value); boolean read(); void enable(); void disable(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean isEnabled();  }
@Test public void testEnable() throws Exception { Pin a = new Pin("P1", new TestPinCommand() { @Override public Pin.Mode getMode(Pin pin) throws PinCommandException { return Pin.Mode.OUT; } @Override public boolean read(Pin pin) throws PinCommandException { return true; } }); a.write(false); a.disable(); try { a.write(false); assert false; } catch (PinCommandException e) { assert true; } }