use of org.eclipse.smarthome.core.items.MetadataKey in project smarthome by eclipse.
the class ItemResourceOSGiTest method testRemoveMetadata_unmanagedMetadata.
@Test
public void testRemoveMetadata_unmanagedMetadata() {
MetadataProvider provider = mock(MetadataProvider.class);
when(provider.getAll()).thenReturn(Collections.singleton(new Metadata(new MetadataKey("namespace", ITEM_NAME1), "some value", null)));
registerService(provider);
Response response = itemResource.removeMetadata(ITEM_NAME1, "namespace");
assertEquals(409, response.getStatus());
}
use of org.eclipse.smarthome.core.items.MetadataKey in project smarthome by eclipse.
the class MetadataRegistryImplTest method testGet.
@Test
public void testGet() throws Exception {
MetadataKey key = new MetadataKey("namespace", "itemName");
registry.added(managedProvider, new Metadata(key, "value", Collections.emptyMap()));
registry.added(managedProvider, new Metadata(new MetadataKey("other", "itemName"), "other", Collections.emptyMap()));
registry.added(managedProvider, new Metadata(new MetadataKey("namespace", "other"), "other", Collections.emptyMap()));
Metadata res = registry.get(key);
assertNotNull(res);
assertEquals("value", res.getValue());
assertEquals("namespace", res.getUID().getNamespace());
assertEquals("itemName", res.getUID().getItemName());
}
use of org.eclipse.smarthome.core.items.MetadataKey in project smarthome by eclipse.
the class AbstractItemEventSubscriberOSGiTest method setup.
@Before
public void setup() {
initMocks(this);
eventPublisher = getService(EventPublisher.class);
assertNotNull(eventPublisher);
when(itemProvider.getAll()).thenReturn(Collections.singletonList(new SwitchItem(ITEM_NAME)));
registerService(itemProvider);
EventSubscriber itemEventSubscriber = new AbstractItemEventSubscriber() {
@Override
protected void receiveCommand(ItemCommandEvent event) {
commandEvent = event;
}
@Override
protected void receiveUpdate(ItemStateEvent event) {
updateEvent = event;
}
};
registerService(itemEventSubscriber, EventSubscriber.class.getName());
when(mockMetadataProvider.getAll()).thenReturn(Collections.singletonList(new Metadata(new MetadataKey("autoupdate", ITEM_NAME), Boolean.toString(false), null)));
registerService(mockMetadataProvider);
}
use of org.eclipse.smarthome.core.items.MetadataKey in project smarthome by eclipse.
the class GenericMetadataProvider method addMetadata.
/**
* Adds metadata to this provider
*
* @param bindingType
* @param itemName
* @param configuration
*/
public void addMetadata(String bindingType, String itemName, String value, @Nullable Map<String, Object> configuration) {
MetadataKey key = new MetadataKey(bindingType, itemName);
Metadata md = new Metadata(key, value, configuration);
try {
lock.writeLock().lock();
metadata.add(md);
} finally {
lock.writeLock().unlock();
}
notifyListenersAboutAddedElement(md);
}
use of org.eclipse.smarthome.core.items.MetadataKey in project smarthome by eclipse.
the class MetadataRegistryImplTest method testGet_empty.
@Test
public void testGet_empty() throws Exception {
MetadataKey key = new MetadataKey("namespace", "itemName");
Metadata res = registry.get(key);
assertNull(res);
}
Aggregations