PinManager { public Pin createPin(PinCode pinCode, Pin.Mode mode) throws PinException { if (!pinCodeClass.isInstance(pinCode)) throw new PinException("Pin code is not suitable with this board Please use " + pinCodeClass.getName()); String code = pinCode.getCode(); if (pins.containsKey(code)) { Pin pin = pins.get(code); if (!pin.getMode().equals(mode)) throw new PinException("Pin already created with a different mode " + pin.getMode().name()); if (!pin.isEnabled()) pin.enable(); return pins.get(code); } Pin pin = new Pin(code, mode, getPinCommand()); pins.put(code, pin); return pin; } private  PinManager(BoardType boardType); Class<ChipPinCode> getPinCodeClass(); static PinManager getInstance(); Pin createPin(PinCode pinCode, Pin.Mode mode); Pin getPin(String code);  }
@Test public void testCreatePin() throws Exception { try { Pin pin = PinManager.getInstance().createPin(TestPinCode.TEST_PIN, Pin.Mode.IN); } catch (PinException e) { assert e.getMessage().startsWith("Pin code is not suitable with this board"); } }