Search in sources :

Example 1 with DmxSuspendingFadeCommand

use of org.openhab.binding.dmx.internal.cmd.DmxSuspendingFadeCommand in project openhab1-addons by openhab.

the class DmxSwitchItemTest method canHaveCustomCommandConfiguration.

@SuppressWarnings("unchecked")
@Test
public void canHaveCustomCommandConfiguration() throws BindingConfigParseException {
    // test valid configurations
    DmxItem item = getItemInstance("CHANNEL[7/3:1000] ON[FADE|0:255,255,255:30000|5000:0,0,0:-1]");
    DmxCommand cmd = ((Map<String, DmxCommand>) Whitebox.getInternalState(item, "customCommands")).get("ON");
    assertTrue(cmd instanceof DmxFadeCommand);
    getItemInstance("CHANNEL[7/4] ,ON[SFADE|0:255,255,255:30000|5000:0,0,0:-1]");
    cmd = ((Map<String, DmxCommand>) Whitebox.getInternalState(item, "customCommands")).get("ON");
    assertTrue(cmd instanceof DmxFadeCommand);
    item = getItemInstance("CHANNEL[1/18], ON[FADE|0:255,255,255:125|0:0,0,255:125|0:255,255,255:125|0:0,0,255:125|0:255,255,255:125|0:0,0,255:125|0:255,255,255:125|0:0,0,255:125|0:255,255,255:125|0:0,0,255:125|0:0,0,255:-1]");
    cmd = ((Map<String, DmxCommand>) Whitebox.getInternalState(item, "customCommands")).get("ON");
    assertTrue(cmd instanceof DmxFadeCommand);
    item = getItemInstance("CHANNEL[1/18], ON[SFADE|0:255,255,255:125|0:0,0,255:125|0:255,255,255:125|0:0,0,255:125|0:255,255,255:125|0:0,0,255:125|0:255,255,255:125|0:0,0,255:125|0:255,255,255:125|0:0,0,255:125|0:0,0,255:-1]");
    cmd = ((Map<String, DmxCommand>) Whitebox.getInternalState(item, "customCommands")).get("ON");
    assertTrue(cmd instanceof DmxSuspendingFadeCommand);
    item = getItemInstance("CHANNEL[13/3], 0[FADE|2000:127,36,127:0|2000:0,0,127:0|2000:127,0,0:0], 1[SFADE|500:127,36,127:0|500:0,0,127:0|500:127,0,0:0], 2[FADE|200:127,36,127:300|200:0,0,127:300|200:127,0,0:300]");
    cmd = ((Map<String, DmxCommand>) Whitebox.getInternalState(item, "customCommands")).get("0");
    assertTrue(cmd instanceof DmxFadeCommand);
    cmd = ((Map<String, DmxCommand>) Whitebox.getInternalState(item, "customCommands")).get("1");
    assertTrue(cmd instanceof DmxSuspendingFadeCommand);
    // test invalid configurations
    try {
        item = getItemInstance("CHANNEL[7:1000], ON[FADE|1,2,5]");
        fail("Missing exception");
    } catch (BindingConfigParseException e) {
        e.printStackTrace();
    }
    try {
        item = getItemInstance("CHANNEL[7:1000] ON[FADE|1,2,5");
        fail("Missing exception");
    } catch (BindingConfigParseException e) {
        e.printStackTrace();
    }
    try {
        item = getItemInstance("CHANNEL[7:1000]ONFADE|1,2,5]");
        fail("Missing exception");
    } catch (BindingConfigParseException e) {
        e.printStackTrace();
    }
    try {
        item = getItemInstance("CHANNEL[7:1000] ON[FADE|1,2,5]");
        fail("Missing exception");
    } catch (BindingConfigParseException e) {
        e.printStackTrace();
    }
    try {
        item = getItemInstance("CHANNEL[7/3:1000], OR[FADE|0:255,255,255|5000:0,0,0:-1]");
        fail("Missing exception");
    } catch (BindingConfigParseException e) {
        e.printStackTrace();
    }
}
Also used : DmxFadeCommand(org.openhab.binding.dmx.internal.cmd.DmxFadeCommand) BindingConfigParseException(org.openhab.model.item.binding.BindingConfigParseException) DmxCommand(org.openhab.binding.dmx.internal.cmd.DmxCommand) Map(java.util.Map) DmxSuspendingFadeCommand(org.openhab.binding.dmx.internal.cmd.DmxSuspendingFadeCommand) Test(org.junit.Test)

Aggregations

Map (java.util.Map)1 Test (org.junit.Test)1 DmxCommand (org.openhab.binding.dmx.internal.cmd.DmxCommand)1 DmxFadeCommand (org.openhab.binding.dmx.internal.cmd.DmxFadeCommand)1 DmxSuspendingFadeCommand (org.openhab.binding.dmx.internal.cmd.DmxSuspendingFadeCommand)1 BindingConfigParseException (org.openhab.model.item.binding.BindingConfigParseException)1