use of org.openhab.binding.dmx.DmxService in project openhab1-addons by openhab.
the class DmxColorItemTest method canBeSetWithHsbCommand.
@Test
public void canBeSetWithHsbCommand() throws BindingConfigParseException {
DmxItem item = getValidInstance();
DmxService service = Mockito.mock(DmxService.class);
HSBType hsb = new HSBType(DecimalType.ZERO, PercentType.HUNDRED, PercentType.HUNDRED);
item.processCommand(service, hsb);
Mockito.verify(service).setChannelValue(3, 255);
Mockito.verify(service).setChannelValue(4, 0);
Mockito.verify(service).setChannelValue(5, 0);
}
use of org.openhab.binding.dmx.DmxService in project openhab1-addons by openhab.
the class DmxColorItemTest method canBeSetWithPercentType.
@Override
@Test
public void canBeSetWithPercentType() throws BindingConfigParseException {
DmxItem item = getValidInstance();
DmxService service = Mockito.mock(DmxService.class);
item.processCommand(service, new PercentType(50));
Mockito.verify(service).setChannelValue(3, 129);
Mockito.verify(service).setChannelValue(4, 129);
Mockito.verify(service).setChannelValue(5, 129);
}
use of org.openhab.binding.dmx.DmxService in project openhab1-addons by openhab.
the class DmxDimmerItemTest method increasesWhenIncreaseCommandReceived.
@Test
public void increasesWhenIncreaseCommandReceived() throws BindingConfigParseException {
DmxItem item = getValidInstance();
DmxService service = Mockito.mock(DmxService.class);
Mockito.when(service.getChannelValue(3)).thenReturn(95);
Mockito.when(service.getChannelValue(4)).thenReturn(3);
item.processCommand(service, IncreaseDecreaseType.INCREASE);
Mockito.verify(service).enableChannel(3);
Mockito.verify(service).increaseChannel(3, DmxDimmerItem.DIMMER_STEP_SIZE);
Mockito.verify(service).enableChannel(4);
Mockito.verify(service).increaseChannel(4, DmxDimmerItem.DIMMER_STEP_SIZE);
}
use of org.openhab.binding.dmx.DmxService in project openhab1-addons by openhab.
the class DmxSwitchItemTest method switchesOffWhenOffCommandReceived.
@Test
public void switchesOffWhenOffCommandReceived() throws BindingConfigParseException {
DmxItem item = getValidInstance();
DmxService service = Mockito.mock(DmxService.class);
item.processCommand(service, OnOffType.OFF);
Mockito.verify(service).disableChannel(3);
Mockito.verify(service).disableChannel(4);
}
use of org.openhab.binding.dmx.DmxService in project openhab1-addons by openhab.
the class DmxSwitchItemTest method canCallCustomCommand.
@Test
@SuppressWarnings("unchecked")
public void canCallCustomCommand() throws BindingConfigParseException {
DmxItem item = getValidInstance();
DmxService service = Mockito.mock(DmxService.class);
DmxCommand cmd = Mockito.mock(DmxCommand.class);
Map<String, DmxCommand> commands = (Map<String, DmxCommand>) Whitebox.getInternalState(item, "customCommands");
commands.put("ON", cmd);
item.processCommand(service, OnOffType.ON);
Mockito.verify(cmd).execute(service);
}
Aggregations