Search in sources :

Example 6 with BoolLatch

use of il.ac.technion.cs.smarthouse.utils.BoolLatch in project Smartcity-Smarthouse by TechnionYP5777.

the class SensorApiTest method subscribeOnTimeTest.

@Test(timeout = 4000)
public void subscribeOnTimeTest() {
    final BoolLatch wasCalled = new BoolLatch();
    SensorApi<MySensor> s = getSensor(SENSOR_COMM_NAME, MySensor.class, null);
    Assert.assertEquals(s.isConnected(), false);
    sensorConnect();
    Assert.assertEquals(s.isConnected(), true);
    s.subscribeOnTime(sensorData -> {
        Assert.assertEquals(sensorData.getParam1(), 0);
        Assert.assertEquals(sensorData.getCommercialName(), SENSOR_COMM_NAME);
        Assert.assertEquals(sensorData.getSensorLocation(), SensorLocation.UNDEFINED);
        wasCalled.setTrueAndRelease();
    }, LocalTime.now().plusSeconds(2));
    wasCalled.blockUntilTrue();
}
Also used : BoolLatch(il.ac.technion.cs.smarthouse.utils.BoolLatch) Test(org.junit.Test)

Aggregations

BoolLatch (il.ac.technion.cs.smarthouse.utils.BoolLatch)6 Test (org.junit.Test)6 ApplicationPath (il.ac.technion.cs.smarthouse.system.applications.installer.ApplicationPath)1