use of org.openhab.binding.netatmo.internal.weather.MeasurementRequestStub in project openhab1-addons by openhab.
the class MeasurementTest method testSuccess.
@Test
public void testSuccess() throws Exception {
final MeasurementRequestStub request = createRequest("/getmeasure.json");
request.addMeasure(NetatmoMeasureType.TEMPERATURE);
request.addMeasure(NetatmoMeasureType.HUMIDITY);
final MeasurementResponse response = request.execute();
assertFalse(response.isError());
assertNull(response.getError());
assertEquals("access_token=" + ACCESS_TOKEN + "&scale=max&date_end=last&device_id=" + DEVICE_ID + "&module_id=" + MODULE_ID + "&type=Humidity,Temperature", request.getContent());
final List<Body> bodyList = response.getBody();
assertNotNull(bodyList);
assertEquals(1, bodyList.size());
final Body body = bodyList.get(0);
final List<List<BigDecimal>> valuesList = body.getValues();
assertNotNull(valuesList);
assertEquals(1, valuesList.size());
final List<BigDecimal> values = valuesList.get(0);
assertNotNull(values);
assertEquals(2, values.size());
assertEquals(new BigDecimal("77"), values.get(0));
assertEquals(new BigDecimal("19.3"), values.get(1));
}
use of org.openhab.binding.netatmo.internal.weather.MeasurementRequestStub in project openhab1-addons by openhab.
the class MeasurementTest method testError.
@Test
public void testError() throws Exception {
final MeasurementRequestStub request = createRequest("/error-2.json");
final MeasurementResponse response = request.execute();
assertTrue(response.isError());
final NetatmoError error = response.getError();
assertNotNull(error);
assertEquals(2, error.getCode());
assertEquals("Invalid access token", error.getMessage());
}
Aggregations