You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/items/YamlItemDTO.java
addToList(errors, "invalid item: name \"%s\" not matching the expected syntax %s".formatted(name,
93
-
ID_PATTERN.pattern()));
92
+
if (!ItemUtil.isValidItemName(name)) {
93
+
addToList(errors,
94
+
"invalid item: name \"%s\" must begin with a letter or underscore followed by alphanumeric characters and underscores, and must not contain any other symbols."
Copy file name to clipboardExpand all lines: bundles/org.openhab.core.model.yaml/src/test/java/org/openhab/core/model/yaml/internal/items/YamlItemDTOTest.java
+22-22Lines changed: 22 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@ public void testIsValid() throws IOException {
53
53
assertTrue(item.isValid(null, null));
54
54
item.name = "$name";
55
55
assertFalse(item.isValid(null, null));
56
-
item.name = "my-name";
56
+
item.name = "my_name";
57
57
assertTrue(item.isValid(null, null));
58
58
59
59
item.type = "Group";
@@ -123,10 +123,10 @@ public void testEquals() throws IOException {
123
123
YamlItemDTOitem1 = newYamlItemDTO();
124
124
YamlItemDTOitem2 = newYamlItemDTO();
125
125
126
-
item1.name = "item-name";
127
-
item2.name = "item-name-2";
126
+
item1.name = "item_name";
127
+
item2.name = "item_name_2";
128
128
assertFalse(item1.equals(item2));
129
-
item2.name = "item-name";
129
+
item2.name = "item_name";
130
130
assertTrue(item1.equals(item2));
131
131
assertEquals(item1.hashCode(), item2.hashCode());
132
132
@@ -206,8 +206,8 @@ public void testEqualsWithLabel() throws IOException {
206
206
YamlItemDTOitem1 = newYamlItemDTO();
207
207
YamlItemDTOitem2 = newYamlItemDTO();
208
208
209
-
item1.name = "item-name";
210
-
item2.name = "item-name";
209
+
item1.name = "item_name";
210
+
item2.name = "item_name";
211
211
item1.type = "String";
212
212
item2.type = "String";
213
213
@@ -235,8 +235,8 @@ public void testEqualsWithIcon() throws IOException {
235
235
YamlItemDTOitem1 = newYamlItemDTO();
236
236
YamlItemDTOitem2 = newYamlItemDTO();
237
237
238
-
item1.name = "item-name";
239
-
item2.name = "item-name";
238
+
item1.name = "item_name";
239
+
item2.name = "item_name";
240
240
item1.type = "Number";
241
241
item2.type = "Number";
242
242
@@ -264,8 +264,8 @@ public void testEqualsWithFormat() throws IOException {
264
264
YamlItemDTOitem1 = newYamlItemDTO();
265
265
YamlItemDTOitem2 = newYamlItemDTO();
266
266
267
-
item1.name = "item-name";
268
-
item2.name = "item-name";
267
+
item1.name = "item_name";
268
+
item2.name = "item_name";
269
269
item1.type = "Number";
270
270
item2.type = "Number";
271
271
@@ -293,8 +293,8 @@ public void testEqualsWithUnit() throws IOException {
293
293
YamlItemDTOitem1 = newYamlItemDTO();
294
294
YamlItemDTOitem2 = newYamlItemDTO();
295
295
296
-
item1.name = "item-name";
297
-
item2.name = "item-name";
296
+
item1.name = "item_name";
297
+
item2.name = "item_name";
298
298
item1.type = "Number";
299
299
item2.type = "Number";
300
300
@@ -322,8 +322,8 @@ public void testEqualsWithAutoupdate() throws IOException {
322
322
YamlItemDTOitem1 = newYamlItemDTO();
323
323
YamlItemDTOitem2 = newYamlItemDTO();
324
324
325
-
item1.name = "item-name";
326
-
item2.name = "item-name";
325
+
item1.name = "item_name";
326
+
item2.name = "item_name";
327
327
item1.type = "Number";
328
328
item2.type = "Number";
329
329
@@ -364,8 +364,8 @@ public void testEqualsWithGroups() throws IOException {
364
364
YamlItemDTOitem1 = newYamlItemDTO();
365
365
YamlItemDTOitem2 = newYamlItemDTO();
366
366
367
-
item1.name = "item-name";
368
-
item2.name = "item-name";
367
+
item1.name = "item_name";
368
+
item2.name = "item_name";
369
369
item1.type = "Number";
370
370
item2.type = "Number";
371
371
@@ -406,8 +406,8 @@ public void testEqualsWithTags() throws IOException {
406
406
YamlItemDTOitem1 = newYamlItemDTO();
407
407
YamlItemDTOitem2 = newYamlItemDTO();
408
408
409
-
item1.name = "item-name";
410
-
item2.name = "item-name";
409
+
item1.name = "item_name";
410
+
item2.name = "item_name";
411
411
item1.type = "Number";
412
412
item2.type = "Number";
413
413
@@ -449,8 +449,8 @@ public void testEqualsWithChannels() throws IOException {
449
449
YamlItemDTOitem1 = newYamlItemDTO();
450
450
YamlItemDTOitem2 = newYamlItemDTO();
451
451
452
-
item1.name = "item-name";
453
-
item2.name = "item-name";
452
+
item1.name = "item_name";
453
+
item2.name = "item_name";
454
454
item1.type = "Number";
455
455
item2.type = "Number";
456
456
@@ -499,8 +499,8 @@ public void testEqualsWithMetadata() throws IOException {
0 commit comments