MicrochipPotentiometerDeviceController { public int getValue(final DeviceControllerChannel channel, final boolean nonVolatile) throws IOException { if (channel == null) { throw new RuntimeException("null-channel is not allowed. For devices " + "knowing just one wiper Channel.A is mandatory for " + "parameter 'channel'"); } byte memAddr = nonVolatile ? channel.getNonVolatileMemoryAddress() : channel.getVolatileMemoryAddress(); int currentValue = read(memAddr); return currentValue; } MicrochipPotentiometerDeviceController(final I2CDevice i2cDevice); DeviceControllerDeviceStatus getDeviceStatus(); void increase(final DeviceControllerChannel channel, final int steps); void decrease(final DeviceControllerChannel channel, final int steps); int getValue(final DeviceControllerChannel channel, final boolean nonVolatile); void setValue(final DeviceControllerChannel channel, final int value,
			final boolean nonVolatile); DeviceControllerTerminalConfiguration getTerminalConfiguration(
			final DeviceControllerChannel channel); void setTerminalConfiguration(final DeviceControllerTerminalConfiguration config); void setWiperLock(final DeviceControllerChannel channel,
			final boolean locked); void setWriteProtection(final boolean enabled); @Override String toString(); @Override boolean equals(final Object obj); static final boolean VOLATILE_WIPER; static final boolean NONVOLATILE_WIPER; }
@Test public void testGetValue() throws IOException { try { controller.getValue(null, true); fail("Got no RuntimeException on calling 'getValue(null, ...)'!"); } catch (RuntimeException e) { } mockReadResult(i2cDevice, (byte) 0b00000000, (byte) 0b00000000, (int[]) null); int currentValue = controller.getValue(DeviceControllerChannel.A, false); assertEquals("Expected result of 'getCurrentValue(...)' as 0 " + "but got " + currentValue, 0, currentValue); testForWriteAndRead((byte) 0b0001100); reset(i2cDevice); mockReadResult(i2cDevice, (byte) 0b00000000, (byte) 0b10000000, (int[]) null); currentValue = controller.getValue(DeviceControllerChannel.B, false); assertEquals("Expected result of 'getCurrentValue(...)' as 128 " + "but got " + currentValue, 128, currentValue); testForWriteAndRead((byte) 0b0011100); reset(i2cDevice); mockReadResult(i2cDevice, (byte) 0b00000001, (byte) 0b00000001, (int[]) null); currentValue = controller.getValue(DeviceControllerChannel.A, true); assertEquals("Expected result of 'getCurrentValue(...)' as 257 " + "but got " + currentValue, 257, currentValue); testForWriteAndRead((byte) 0b0101100); reset(i2cDevice); mockReadResult(i2cDevice, (byte) 0b00000001, (byte) 0b00000001, (int[]) null); currentValue = controller.getValue(DeviceControllerChannel.B, true); assertEquals("Expected result of 'getCurrentValue(...)' as 257 " + "but got " + currentValue, 257, currentValue); testForWriteAndRead((byte) 0b0111100); }