Pin { @Override public String toString() { final StringBuilder sb = new StringBuilder("Pin{"); sb.append("code='").append(code).append('\''); sb.append(", path=").append(path.getPath()); sb.append(", mode=").append(mode); sb.append(", enabled=").append(enabled); sb.append('}'); return sb.toString(); } 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 testToString() throws Exception { Pin a = new Pin("P1", new TestPinCommand() { @Override public Pin.Mode getMode(Pin pin) throws PinCommandException { return Pin.Mode.IN; } @Override public boolean read(Pin pin) throws PinCommandException { return true; } }); String expectedStr = "Pin{code='P1', path=/sample/P1, mode=IN, enabled=true}"; if (OperatingSystem.getType() == OperatingSystem.Type.WINDOWS) { expectedStr = expectedStr.replace('/', '\\'); } assert expectedStr.equals(a.toString()); }