SystemOffsetProfile implements StateProfile { @Override public void onCommandFromItem(Command command) { callback.handleCommand((Command) applyOffset(command, false)); } SystemOffsetProfile(ProfileCallback callback, ProfileContext context); @Override ProfileTypeUID getProfileTypeUID(); @Override void onStateUpdateFromItem(State state); @Override void onCommandFromItem(Command command); @Override void onCommandFromHandler(Command command); @Override void onStateUpdateFromHandler(State state);  }
@Test public void testDecimalTypeOnCommandFromItem() { ProfileCallback callback = mock(ProfileCallback.class); SystemOffsetProfile offsetProfile = createProfile(callback, "3"); Command cmd = new DecimalType(23); offsetProfile.onCommandFromItem(cmd); ArgumentCaptor<Command> capture = ArgumentCaptor.forClass(Command.class); verify(callback, times(1)).handleCommand(capture.capture()); Command result = capture.getValue(); DecimalType decResult = (DecimalType) result; assertEquals(20, decResult.intValue()); }
@Test public void testQuantityTypeOnCommandFromItem() { ProfileCallback callback = mock(ProfileCallback.class); SystemOffsetProfile offsetProfile = createProfile(callback, "3°C"); Command cmd = new QuantityType<>("23°C"); offsetProfile.onCommandFromItem(cmd); ArgumentCaptor<Command> capture = ArgumentCaptor.forClass(Command.class); verify(callback, times(1)).handleCommand(capture.capture()); Command result = capture.getValue(); @SuppressWarnings("unchecked") QuantityType<Temperature> decResult = (QuantityType<Temperature>) result; assertEquals(20, decResult.intValue()); assertEquals(SIUnits.CELSIUS, decResult.getUnit()); }