mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 13:21:53 +01:00
Remove state description when loading an item with a removed pattern (#4068)
* Remove state description when loading an item with a removed pattern Fix openhab/openhab-webui#2251 Signed-off-by: Laurent Garnier <lg.hc@free.fr> * Extended integration test testSquareBracketsInFormat Signed-off-by: Laurent Garnier <lg.hc@free.fr> --------- Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
5f8da67983
commit
a9571228d2
@ -255,6 +255,8 @@ public class GenericItemProvider extends AbstractProvider<Item>
|
||||
label = label.substring(0, label.indexOf("[")).trim();
|
||||
stateDescriptionFragments.put(modelItem.getName(),
|
||||
StateDescriptionFragmentBuilder.create().withPattern(format).build());
|
||||
} else {
|
||||
stateDescriptionFragments.remove(modelItem.getName());
|
||||
}
|
||||
activeItem.setLabel(label);
|
||||
activeItem.setCategory(modelItem.getIcon());
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openhab.core.model.item.internal;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
|
||||
@ -655,5 +655,28 @@ public class GenericItemProviderTest extends JavaOSGiTest {
|
||||
StateDescription stateDescription = item.getStateDescription();
|
||||
assertThat(stateDescription, is(notNullValue()));
|
||||
assertThat(stateDescription.getPattern(), is("XPATH(/*[name()='liveStreams']/*[name()='stream']):%s"));
|
||||
|
||||
model = "Switch s \"Info [%s]\"";
|
||||
modelRepository.addOrRefreshModel(TESTMODEL_NAME, new ByteArrayInputStream(model.getBytes()));
|
||||
item = itemRegistry.get("s");
|
||||
assertThat(item, is(notNullValue()));
|
||||
stateDescription = item.getStateDescription();
|
||||
assertThat(stateDescription, is(notNullValue()));
|
||||
assertThat(stateDescription.getPattern(), is("%s"));
|
||||
|
||||
model = "Switch s \"Info\"";
|
||||
modelRepository.addOrRefreshModel(TESTMODEL_NAME, new ByteArrayInputStream(model.getBytes()));
|
||||
item = itemRegistry.get("s");
|
||||
assertThat(item, is(notNullValue()));
|
||||
stateDescription = item.getStateDescription();
|
||||
assertThat(stateDescription, is(nullValue()));
|
||||
|
||||
model = "Switch s \"Info [%s]\"";
|
||||
modelRepository.addOrRefreshModel(TESTMODEL_NAME, new ByteArrayInputStream(model.getBytes()));
|
||||
item = itemRegistry.get("s");
|
||||
assertThat(item, is(notNullValue()));
|
||||
stateDescription = item.getStateDescription();
|
||||
assertThat(stateDescription, is(notNullValue()));
|
||||
assertThat(stateDescription.getPattern(), is("%s"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user