Fixed test cases

This commit is contained in:
Ziver Koc 2016-08-18 16:43:05 +02:00
parent a9b8799f21
commit 3a8bb12bab
2 changed files with 35 additions and 23 deletions

View file

@ -1,6 +1,8 @@
package se.hal.plugin.tellstick;
import se.hal.plugin.tellstick.device.NexaSelfLearning;
import se.hal.plugin.tellstick.protocol.NexaSelfLearningProtocol;
import se.hal.struct.devicedata.SwitchEventData;
/**
* Created by Ziver on 2015-11-19.
@ -17,30 +19,32 @@ public class TelstickSerialCommNexaOnOffTest {
Thread.sleep(1000);
NexaSelfLearningProtocol nexa = new NexaSelfLearningProtocol();
NexaSelfLearning nexaDevice = new NexaSelfLearning();
//nexa.setHouse(11772006);
nexa.setHouse(14160770);
nexa.setGroup(false);
nexa.setUnit(1);
nexaDevice.setHouse(14160770);
nexaDevice.setGroup(false);
nexaDevice.setUnit(1);
SwitchEventData nexaData = new SwitchEventData();
System.out.println("Up and Running");
while(true) {
Thread.sleep(2000);
nexa.turnOn();
nexa.setUnit(0);
comm.write(nexa);
nexaData.turnOn();
nexaDevice.setUnit(0);
comm.send(nexaDevice, nexaData);
Thread.sleep(2000);
nexa.setUnit(1);
comm.write(nexa);
nexaDevice.setUnit(1);
comm.send(nexaDevice, nexaData);
Thread.sleep(2000);
nexa.turnOff();
nexa.setUnit(0);
comm.write(nexa);
nexaData.turnOff();
nexaDevice.setUnit(0);
comm.send(nexaDevice, nexaData);
Thread.sleep(2000);
nexa.setUnit(1);
comm.write(nexa);
nexaDevice.setUnit(1);
comm.send(nexaDevice, nexaData);
}
} catch (Exception e) {
e.printStackTrace();

View file

@ -2,11 +2,13 @@ package se.hal.plugin.tellstick;
import org.junit.Before;
import org.junit.Test;
import se.hal.intf.HalEventConfig;
import se.hal.intf.HalEventReportListener;
import se.hal.intf.*;
import se.hal.struct.devicedata.SwitchEventData;
import se.hal.struct.devicedata.TemperatureSensorData;
import zutil.converter.Converter;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
@ -45,7 +47,7 @@ public class TelstickSerialCommTest {
final ArrayList<HalEventConfig> list = new ArrayList<>();
tellstick.setListener(new HalEventReportListener() {
@Override
public void reportReceived(HalEventConfig e) {
public void reportReceived(HalEventConfig e, HalDeviceData d) {
list.add(e);
}
});
@ -63,7 +65,7 @@ public class TelstickSerialCommTest {
final ArrayList<HalEventConfig> list = new ArrayList<>();
tellstick.setListener(new HalEventReportListener() {
@Override
public void reportReceived(HalEventConfig e) {
public void reportReceived(HalEventConfig e, HalDeviceData d) {
list.add(e);
}
});
@ -79,7 +81,7 @@ public class TelstickSerialCommTest {
private static class TestEvent extends TellstickProtocol implements HalEventConfig {
private static class TestEvent extends TellstickProtocol implements HalEventConfig,TellstickDevice {
public int testData;
public TestEvent(){
@ -87,16 +89,22 @@ public class TelstickSerialCommTest {
}
@Override
public void decode(byte[] data) {
public List<TellstickDecodedEntry> decode(byte[] data) {
testData = Converter.toInt(data);
ArrayList<TellstickDecodedEntry> list = new ArrayList<>();
list.add(new TellstickDecodedEntry(
this, new TemperatureSensorData(testData)
));
return list;
}
@Override
public String encode() {return null;}
@Override
public double getData() {return 0;}
public Class<? extends HalEventController> getEventController() { return null; }
@Override
public boolean equals(Object obj) {return testData == ((TestEvent)obj).testData;}
}
}