use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class GenericItemProvider method internalDispatchBindings.
private void internalDispatchBindings(BindingConfigReader reader, String modelName, Item item, EList<ModelBinding> bindings) {
for (ModelBinding binding : bindings) {
String bindingType = binding.getType();
String config = binding.getConfiguration();
Configuration configuration = new Configuration();
binding.getProperties().forEach(p -> configuration.put(p.getKey(), p.getValue()));
BindingConfigReader localReader = reader;
if (reader == null) {
logger.trace("Given binding config reader is null > query cache to find appropriate reader!");
localReader = bindingConfigReaders.get(bindingType);
} else {
if (!localReader.getBindingType().equals(binding.getType())) {
logger.trace("The Readers' binding type '{}' and the Bindings' type '{}' doesn't match > continue processing next binding.", localReader.getBindingType(), binding.getType());
continue;
} else {
logger.debug("Start processing binding configuration of Item '{}' with '{}' reader.", item, localReader.getClass().getSimpleName());
}
}
if (localReader != null) {
try {
localReader.validateItemType(item.getType(), config);
localReader.processBindingConfiguration(modelName, item.getType(), item.getName(), config, configuration);
} catch (BindingConfigParseException e) {
logger.error("Binding configuration of type '{}' of item '{}' could not be parsed correctly.", bindingType, item.getName(), e);
} catch (Exception e) {
// Catch badly behaving binding exceptions and continue processing
logger.error("Binding configuration of type '{}' of item '{}' could not be parsed correctly.", bindingType, item.getName(), e);
}
} else {
logger.trace("Couldn't find config reader for binding type '{}' > " + "parsing binding configuration of Item '{}' aborted!", bindingType, item);
}
}
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class FSInternetRadioHandlerJavaTest method offlineIfWrongPIN.
/**
* Verify OFFLINE Thing status when the PIN is wrong.
*/
@Test
public void offlineIfWrongPIN() {
final String wrongPin = "5678";
Configuration config = createConfiguration(DEFAULT_CONFIG_PROPERTY_IP, wrongPin, String.valueOf(DEFAULT_CONFIG_PROPERTY_PORT), DEFAULT_CONFIG_PROPERTY_REFRESH);
initializeRadioThing(config);
waitForAssert(() -> {
String exceptionMessage = "java.lang.RuntimeException: Radio does not allow connection, maybe wrong pin?";
verifyCommunicationError(exceptionMessage);
});
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class FSInternetRadioHandlerJavaTest method offlineIfEmptyPIN.
/**
* Verify OFFLINE Thing status when the PIN is empty String.
*/
@Test
public void offlineIfEmptyPIN() {
Configuration config = createConfiguration(DEFAULT_CONFIG_PROPERTY_IP, "", String.valueOf(DEFAULT_CONFIG_PROPERTY_PORT), DEFAULT_CONFIG_PROPERTY_REFRESH);
Thing radioThingWithEmptyPIN = initializeRadioThing(config);
testRadioThingConsideringConfiguration(radioThingWithEmptyPIN);
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class AbstractDmxThingTest method initializeBridge.
private void initializeBridge() {
bridgeProperties = new HashMap<>();
bridge = BridgeBuilder.create(THING_TYPE_TEST_BRIDGE, "testbridge").withLabel("Test Bridge").withConfiguration(new Configuration(bridgeProperties)).build();
dmxBridgeHandler = new TestBridgeHandler(bridge);
bridge.setHandler(dmxBridgeHandler);
ThingHandlerCallback bridgeHandler = mock(ThingHandlerCallback.class);
doAnswer(answer -> {
((Thing) answer.getArgument(0)).setStatusInfo(answer.getArgument(1));
return null;
}).when(bridgeHandler).statusUpdated(any(), any());
dmxBridgeHandler.setCallback(bridgeHandler);
dmxBridgeHandler.initialize();
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class DimmerThingHandlerTest method setUp.
@Before
public void setUp() {
super.setup();
thingProperties = new HashMap<>();
thingProperties.put(CONFIG_DMX_ID, TEST_CHANNEL_CONFIG);
thingProperties.put(CONFIG_DIMMER_FADE_TIME, TEST_FADE_TIME);
dimmerThing = ThingBuilder.create(THING_TYPE_DIMMER, "testdimmer").withLabel("Dimmer Thing").withBridge(bridge.getUID()).withConfiguration(new Configuration(thingProperties)).withChannel(ChannelBuilder.create(CHANNEL_UID_BRIGHTNESS, "Brightness").withType(BRIGHTNESS_CHANNEL_TYPEUID).build()).build();
dimmerThingHandler = new DimmerThingHandler(dimmerThing) {
@Override
@Nullable
protected Bridge getBridge() {
return bridge;
}
};
initializeHandler(dimmerThingHandler);
}
Aggregations