Search in sources :

Example 6 with DmxService

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);
}
Also used : DmxService(org.openhab.binding.dmx.DmxService) HSBType(org.openhab.core.library.types.HSBType) Test(org.junit.Test)

Example 7 with DmxService

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);
}
Also used : DmxService(org.openhab.binding.dmx.DmxService) PercentType(org.openhab.core.library.types.PercentType) Test(org.junit.Test)

Example 8 with DmxService

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);
}
Also used : DmxService(org.openhab.binding.dmx.DmxService) Test(org.junit.Test)

Example 9 with DmxService

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);
}
Also used : DmxService(org.openhab.binding.dmx.DmxService) Test(org.junit.Test)

Example 10 with DmxService

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);
}
Also used : DmxService(org.openhab.binding.dmx.DmxService) DmxCommand(org.openhab.binding.dmx.internal.cmd.DmxCommand) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 DmxService (org.openhab.binding.dmx.DmxService)12 PercentType (org.openhab.core.library.types.PercentType)5 HSBType (org.openhab.core.library.types.HSBType)3 DecimalType (org.openhab.core.library.types.DecimalType)2 Map (java.util.Map)1 DmxCommand (org.openhab.binding.dmx.internal.cmd.DmxCommand)1