Search in sources :

Example 1 with DmxService

use of org.openhab.binding.dmx.DmxService in project openhab1-addons by openhab.

the class DmxColorItemTest method canBeSetWith0PercentType.

@Test
public void canBeSetWith0PercentType() throws BindingConfigParseException {
    DmxItem item = getValidInstance();
    DmxService service = Mockito.mock(DmxService.class);
    item.processCommand(service, new PercentType(0));
    Mockito.verify(service).setChannelValue(3, 0);
    Mockito.verify(service).setChannelValue(4, 0);
    Mockito.verify(service).setChannelValue(5, 0);
}
Also used : DmxService(org.openhab.binding.dmx.DmxService) PercentType(org.openhab.core.library.types.PercentType) Test(org.junit.Test)

Example 2 with DmxService

use of org.openhab.binding.dmx.DmxService in project openhab1-addons by openhab.

the class DmxColorItemTest method decreasesWhenDecreaseCommandReceived.

@Test
@Override
public void decreasesWhenDecreaseCommandReceived() throws BindingConfigParseException {
    DmxItem item = getValidInstance();
    DmxService service = Mockito.mock(DmxService.class);
    HSBType hsb = new HSBType(new DecimalType(150), new PercentType(50), new PercentType(50));
    item.processCommand(service, hsb);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(3, 65);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(4, 129);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(5, 97);
    item.processCommand(service, IncreaseDecreaseType.DECREASE);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(3, 57);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(4, 116);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(5, 87);
}
Also used : DmxService(org.openhab.binding.dmx.DmxService) DecimalType(org.openhab.core.library.types.DecimalType) PercentType(org.openhab.core.library.types.PercentType) HSBType(org.openhab.core.library.types.HSBType) Test(org.junit.Test)

Example 3 with DmxService

use of org.openhab.binding.dmx.DmxService in project openhab1-addons by openhab.

the class DmxColorItemTest method increasesWhenIncreaseCommandReceived.

@Test
@Override
public void increasesWhenIncreaseCommandReceived() throws BindingConfigParseException {
    DmxItem item = getValidInstance();
    DmxService service = Mockito.mock(DmxService.class);
    HSBType hsb = new HSBType(new DecimalType(150), new PercentType(50), new PercentType(50));
    item.processCommand(service, hsb);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(3, 65);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(4, 129);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(5, 97);
    item.processCommand(service, IncreaseDecreaseType.INCREASE);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(3, 70);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(4, 140);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(5, 106);
}
Also used : DmxService(org.openhab.binding.dmx.DmxService) DecimalType(org.openhab.core.library.types.DecimalType) PercentType(org.openhab.core.library.types.PercentType) HSBType(org.openhab.core.library.types.HSBType) Test(org.junit.Test)

Example 4 with DmxService

use of org.openhab.binding.dmx.DmxService in project openhab1-addons by openhab.

the class DmxDimmerItemTest method decreasesWhenDecreaseCommandReceived.

@Test
public void decreasesWhenDecreaseCommandReceived() 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.DECREASE);
    Mockito.verify(service).decreaseChannel(3, DmxDimmerItem.DIMMER_STEP_SIZE);
    Mockito.verify(service).decreaseChannel(4, DmxDimmerItem.DIMMER_STEP_SIZE);
}
Also used : DmxService(org.openhab.binding.dmx.DmxService) Test(org.junit.Test)

Example 5 with DmxService

use of org.openhab.binding.dmx.DmxService in project openhab1-addons by openhab.

the class DmxDimmerItemTest method canBeSetWithPercentType.

@Test
public void canBeSetWithPercentType() throws BindingConfigParseException {
    DmxItem item = getValidInstance();
    DmxService service = Mockito.mock(DmxService.class);
    Mockito.when(service.getChannelValue(3)).thenReturn(0);
    Mockito.when(service.getChannelValue(4)).thenReturn(155);
    item.processCommand(service, new PercentType(0));
    Mockito.verify(service).setChannelValue(3, DmxChannel.DMX_MAX_VALUE);
    Mockito.verify(service).setChannelValue(3, PercentType.ZERO);
    Mockito.verify(service).setChannelValue(4, DmxChannel.DMX_MAX_VALUE);
    Mockito.verify(service).setChannelValue(4, PercentType.ZERO);
}
Also used : DmxService(org.openhab.binding.dmx.DmxService) PercentType(org.openhab.core.library.types.PercentType) 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