use of org.eclipse.smarthome.core.library.types.DecimalType in project smarthome by eclipse.
the class ItemStateConverterImplTest method testStateConversion.
@Test
public void testStateConversion() {
Item item = new NumberItem("number");
State originalState = new PercentType("42");
State convertedState = itemStateConverter.convertToAcceptedState(originalState, item);
assertThat(convertedState, is(new DecimalType("0.42")));
}
use of org.eclipse.smarthome.core.library.types.DecimalType in project smarthome by eclipse.
the class ItemStateConverterImplTest method testNoConversion.
@Test
public void testNoConversion() {
Item item = new NumberItem("number");
State originalState = new DecimalType(12.34);
State state = itemStateConverter.convertToAcceptedState(originalState, item);
assertTrue(originalState == state);
}
use of org.eclipse.smarthome.core.library.types.DecimalType in project smarthome by eclipse.
the class SitemapResourceTest method whenLongPolling_ShouldObserveItemsFromValueColorConditions.
@Test
public void whenLongPolling_ShouldObserveItemsFromValueColorConditions() {
new Thread(() -> {
try {
// wait for the #getPageData call and listeners to attach to the
Thread.sleep(STATE_UPDATE_WAIT_TIME);
// item
valueColorItem.setState(new DecimalType(BigDecimal.ONE));
} catch (InterruptedException e) {
}
}).start();
// non-null is sufficient here.
when(headers.getRequestHeader(HTTP_HEADER_X_ATMOSPHERE_TRANSPORT)).thenReturn(Collections.emptyList());
Response response = sitemapResource.getPageData(headers, null, SITEMAP_MODEL_NAME, SITEMAP_NAME, null);
PageDTO pageDTO = (PageDTO) response.getEntity();
// assert that the item state change did trigger the blocking method to
assertThat(pageDTO.timeout, is(false));
// return
}
use of org.eclipse.smarthome.core.library.types.DecimalType in project smarthome by eclipse.
the class SitemapResourceTest method whenLongPolling_ShouldObserveItemsFromLabelColorConditions.
@Test
public void whenLongPolling_ShouldObserveItemsFromLabelColorConditions() {
new Thread(() -> {
try {
// wait for the #getPageData call and listeners to attach to the
Thread.sleep(STATE_UPDATE_WAIT_TIME);
// item
labelColorItem.setState(new DecimalType(BigDecimal.ONE));
} catch (InterruptedException e) {
}
}).start();
// non-null is sufficient here.
when(headers.getRequestHeader(HTTP_HEADER_X_ATMOSPHERE_TRANSPORT)).thenReturn(Collections.emptyList());
Response response = sitemapResource.getPageData(headers, null, SITEMAP_MODEL_NAME, SITEMAP_NAME, null);
PageDTO pageDTO = (PageDTO) response.getEntity();
// assert that the item state change did trigger the blocking method to
assertThat(pageDTO.timeout, is(false));
// return
}
use of org.eclipse.smarthome.core.library.types.DecimalType in project smarthome by eclipse.
the class ZonePlayerHandler method snoozeAlarm.
public void snoozeAlarm(Command command) {
if (isAlarmRunning() && command instanceof DecimalType) {
int minutes = ((DecimalType) command).intValue();
Map<String, String> inputs = new HashMap<String, String>();
Calendar snoozePeriod = Calendar.getInstance();
snoozePeriod.setTimeZone(TimeZone.getTimeZone("GMT"));
snoozePeriod.setTimeInMillis(0);
snoozePeriod.add(Calendar.MINUTE, minutes);
SimpleDateFormat pFormatter = new SimpleDateFormat("HH:mm:ss");
pFormatter.setTimeZone(TimeZone.getTimeZone("GMT"));
try {
inputs.put("Duration", pFormatter.format(snoozePeriod.getTime()));
} catch (NumberFormatException ex) {
logger.debug("Action Invalid Value Format Exception {}", ex.getMessage());
}
Map<String, String> result = service.invokeAction(this, "AVTransport", "SnoozeAlarm", inputs);
for (String variable : result.keySet()) {
this.onValueReceived(variable, result.get(variable), "AVTransport");
}
} else {
logger.debug("There is no alarm running on {}", getUDN());
}
}
Aggregations