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 \"%s\": \"name\" 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
+23-21Lines changed: 23 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,8 @@ public void testIsValid() throws IOException {
54
54
item.name = "$name";
55
55
assertFalse(item.isValid(null, null));
56
56
item.name = "my-name";
57
+
assertFalse(item.isValid(null, null));
58
+
item.name = "my_name";
57
59
assertTrue(item.isValid(null, null));
58
60
59
61
item.type = "Group";
@@ -123,10 +125,10 @@ public void testEquals() throws IOException {
123
125
YamlItemDTOitem1 = newYamlItemDTO();
124
126
YamlItemDTOitem2 = newYamlItemDTO();
125
127
126
-
item1.name = "item-name";
127
-
item2.name = "item-name-2";
128
+
item1.name = "item_name";
129
+
item2.name = "item_name_2";
128
130
assertFalse(item1.equals(item2));
129
-
item2.name = "item-name";
131
+
item2.name = "item_name";
130
132
assertTrue(item1.equals(item2));
131
133
assertEquals(item1.hashCode(), item2.hashCode());
132
134
@@ -206,8 +208,8 @@ public void testEqualsWithLabel() throws IOException {
206
208
YamlItemDTOitem1 = newYamlItemDTO();
207
209
YamlItemDTOitem2 = newYamlItemDTO();
208
210
209
-
item1.name = "item-name";
210
-
item2.name = "item-name";
211
+
item1.name = "item_name";
212
+
item2.name = "item_name";
211
213
item1.type = "String";
212
214
item2.type = "String";
213
215
@@ -235,8 +237,8 @@ public void testEqualsWithIcon() throws IOException {
235
237
YamlItemDTOitem1 = newYamlItemDTO();
236
238
YamlItemDTOitem2 = newYamlItemDTO();
237
239
238
-
item1.name = "item-name";
239
-
item2.name = "item-name";
240
+
item1.name = "item_name";
241
+
item2.name = "item_name";
240
242
item1.type = "Number";
241
243
item2.type = "Number";
242
244
@@ -264,8 +266,8 @@ public void testEqualsWithFormat() throws IOException {
264
266
YamlItemDTOitem1 = newYamlItemDTO();
265
267
YamlItemDTOitem2 = newYamlItemDTO();
266
268
267
-
item1.name = "item-name";
268
-
item2.name = "item-name";
269
+
item1.name = "item_name";
270
+
item2.name = "item_name";
269
271
item1.type = "Number";
270
272
item2.type = "Number";
271
273
@@ -293,8 +295,8 @@ public void testEqualsWithUnit() throws IOException {
293
295
YamlItemDTOitem1 = newYamlItemDTO();
294
296
YamlItemDTOitem2 = newYamlItemDTO();
295
297
296
-
item1.name = "item-name";
297
-
item2.name = "item-name";
298
+
item1.name = "item_name";
299
+
item2.name = "item_name";
298
300
item1.type = "Number";
299
301
item2.type = "Number";
300
302
@@ -322,8 +324,8 @@ public void testEqualsWithAutoupdate() throws IOException {
322
324
YamlItemDTOitem1 = newYamlItemDTO();
323
325
YamlItemDTOitem2 = newYamlItemDTO();
324
326
325
-
item1.name = "item-name";
326
-
item2.name = "item-name";
327
+
item1.name = "item_name";
328
+
item2.name = "item_name";
327
329
item1.type = "Number";
328
330
item2.type = "Number";
329
331
@@ -364,8 +366,8 @@ public void testEqualsWithGroups() throws IOException {
364
366
YamlItemDTOitem1 = newYamlItemDTO();
365
367
YamlItemDTOitem2 = newYamlItemDTO();
366
368
367
-
item1.name = "item-name";
368
-
item2.name = "item-name";
369
+
item1.name = "item_name";
370
+
item2.name = "item_name";
369
371
item1.type = "Number";
370
372
item2.type = "Number";
371
373
@@ -406,8 +408,8 @@ public void testEqualsWithTags() throws IOException {
406
408
YamlItemDTOitem1 = newYamlItemDTO();
407
409
YamlItemDTOitem2 = newYamlItemDTO();
408
410
409
-
item1.name = "item-name";
410
-
item2.name = "item-name";
411
+
item1.name = "item_name";
412
+
item2.name = "item_name";
411
413
item1.type = "Number";
412
414
item2.type = "Number";
413
415
@@ -449,8 +451,8 @@ public void testEqualsWithChannels() throws IOException {
449
451
YamlItemDTOitem1 = newYamlItemDTO();
450
452
YamlItemDTOitem2 = newYamlItemDTO();
451
453
452
-
item1.name = "item-name";
453
-
item2.name = "item-name";
454
+
item1.name = "item_name";
455
+
item2.name = "item_name";
454
456
item1.type = "Number";
455
457
item2.type = "Number";
456
458
@@ -499,8 +501,8 @@ public void testEqualsWithMetadata() throws IOException {
0 commit comments