Search in sources :

Example 1 with GetStationsDataRequestStub

use of org.openhab.binding.netatmo.internal.weather.GetStationsDataRequestStub in project openhab1-addons by openhab.

the class GetStationsDataTest method testError.

@Test
public void testError() throws Exception {
    final GetStationsDataRequestStub request = createRequest("/error-2.json");
    final GetStationsDataResponse response = request.execute();
    assertTrue(response.isError());
}
Also used : GetStationsDataRequestStub(org.openhab.binding.netatmo.internal.weather.GetStationsDataRequestStub) GetStationsDataResponse(org.openhab.binding.netatmo.internal.weather.GetStationsDataResponse) Test(org.junit.Test)

Example 2 with GetStationsDataRequestStub

use of org.openhab.binding.netatmo.internal.weather.GetStationsDataRequestStub in project openhab1-addons by openhab.

the class GetStationsDataTest method testSuccess.

@Test
public void testSuccess() throws Exception {
    final GetStationsDataRequestStub request = createRequest("/getstationsdata.json");
    final GetStationsDataResponse response = request.execute();
    assertFalse(response.isError());
    assertEquals("access_token=" + ACCESS_TOKEN, request.getContent());
    assertEquals("ok", response.getStatus());
    final List<Device> devices = response.getDevices();
    assertEquals(2, devices.size());
    final Device device1 = devices.get(0);
    final List<Module> modules1 = device1.getModules();
    assertEquals(4, modules1.size());
    final Device device2 = devices.get(1);
    final List<Module> modules2 = device2.getModules();
    assertEquals(4, modules2.size());
    final Place place1 = device1.getPlace();
    assertEquals(30.478512648583, place1.getAltitude());
    final Place place2 = device2.getPlace();
    assertEquals(150.0, place2.getAltitude());
}
Also used : GetStationsDataRequestStub(org.openhab.binding.netatmo.internal.weather.GetStationsDataRequestStub) Device(org.openhab.binding.netatmo.internal.weather.GetStationsDataResponse.Device) Module(org.openhab.binding.netatmo.internal.weather.GetStationsDataResponse.Module) GetStationsDataResponse(org.openhab.binding.netatmo.internal.weather.GetStationsDataResponse) Place(org.openhab.binding.netatmo.internal.weather.GetStationsDataResponse.Place) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 GetStationsDataRequestStub (org.openhab.binding.netatmo.internal.weather.GetStationsDataRequestStub)2 GetStationsDataResponse (org.openhab.binding.netatmo.internal.weather.GetStationsDataResponse)2 Device (org.openhab.binding.netatmo.internal.weather.GetStationsDataResponse.Device)1 Module (org.openhab.binding.netatmo.internal.weather.GetStationsDataResponse.Module)1 Place (org.openhab.binding.netatmo.internal.weather.GetStationsDataResponse.Place)1