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

View file

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