use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class NtpOSGiTest method testNullPropertyFormatting.
@Test
public void testNullPropertyFormatting() {
Configuration configuration = new Configuration();
Configuration channelConfig = new Configuration();
channelConfig.put(NtpBindingConstants.PROPERTY_DATE_TIME_FORMAT, null);
initialize(configuration, NtpBindingConstants.CHANNEL_STRING, ACCEPTED_ITEM_TYPE_STRING, channelConfig, null);
String dateFromItemRegistry = getItemState(ACCEPTED_ITEM_TYPE_STRING).toString();
assertFormat(dateFromItemRegistry, NtpHandler.DATE_PATTERN_WITH_TZ);
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class NtpOSGiTest method testStringChannelFormatting.
@Test
public void testStringChannelFormatting() {
final String formatPattern = "EEE, d MMM yyyy HH:mm:ss z";
Configuration configuration = new Configuration();
Configuration channelConfig = new Configuration();
channelConfig.put(NtpBindingConstants.PROPERTY_DATE_TIME_FORMAT, formatPattern);
initialize(configuration, NtpBindingConstants.CHANNEL_STRING, ACCEPTED_ITEM_TYPE_STRING, channelConfig, null);
String dateFromItemRegistry = getItemState(ACCEPTED_ITEM_TYPE_STRING).toString();
assertFormat(dateFromItemRegistry, formatPattern);
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class NtpOSGiTest method assertCommunicationError.
private void assertCommunicationError(String acceptedItemType) {
Configuration configuration = new Configuration();
final String WRONG_HOSTNAME = "wrong.hostname";
if (acceptedItemType.equals(ACCEPTED_ITEM_TYPE_DATE_TIME)) {
initialize(configuration, NtpBindingConstants.CHANNEL_DATE_TIME, ACCEPTED_ITEM_TYPE_DATE_TIME, null, WRONG_HOSTNAME);
} else if (acceptedItemType.equals(ACCEPTED_ITEM_TYPE_STRING)) {
initialize(configuration, NtpBindingConstants.CHANNEL_STRING, ACCEPTED_ITEM_TYPE_STRING, null, WRONG_HOSTNAME);
}
waitForAssert(() -> {
assertEquals(ThingStatusDetail.COMMUNICATION_ERROR, ntpThing.getStatusInfo().getStatusDetail());
});
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class NtpOSGiTest method testEmptyStringPropertyFormatting.
@Test
public void testEmptyStringPropertyFormatting() {
Configuration configuration = new Configuration();
Configuration channelConfig = new Configuration();
// Empty string
channelConfig.put(NtpBindingConstants.PROPERTY_DATE_TIME_FORMAT, "");
initialize(configuration, NtpBindingConstants.CHANNEL_STRING, ACCEPTED_ITEM_TYPE_STRING, channelConfig, null);
String dateFromItemRegistry = getItemState(ACCEPTED_ITEM_TYPE_STRING).toString();
assertFormat(dateFromItemRegistry, NtpHandler.DATE_PATTERN_WITH_TZ);
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class NtpOSGiTest method assertEventIsReceived.
private void assertEventIsReceived(UpdateEventType updateEventType, String channelID, String acceptedItemType) {
Configuration configuration = new Configuration();
initialize(configuration, channelID, acceptedItemType, null, null);
EventSubscriber eventSubscriberMock = mock(EventSubscriber.class);
when(eventSubscriberMock.getSubscribedEventTypes()).thenReturn(Collections.singleton(ItemStateEvent.TYPE));
registerService(eventSubscriberMock);
if (updateEventType.equals(UpdateEventType.HANDLE_COMMAND)) {
ntpHandler.handleCommand(new ChannelUID("ntp:test:chan:1"), new StringType("test"));
} else if (updateEventType.equals(UpdateEventType.CHANNEL_LINKED)) {
ntpHandler.channelLinked(new ChannelUID("ntp:test:chan:1"));
}
waitForAssert(() -> {
verify(eventSubscriberMock, atLeastOnce()).receive(ArgumentMatchers.any(Event.class));
});
}
Aggregations