Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>org.thingsboard</groupId>
<artifactId>tbel</artifactId>
<packaging>jar</packaging>
<version>1.2.6</version>
<version>1.2.7</version>

<name>tbel</name>
<url>https://thingsboard.io/</url>
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/mvel2/execution/ExecutionArrayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,4 +299,8 @@ public boolean validateClazzInArrayIsOnlyNumber(Object e) {
return false;
}
}

public boolean validateClazzInArrayIsOnlyString() {
return !super.stream().anyMatch(e -> !(e instanceof String));
}
}
48 changes: 0 additions & 48 deletions src/test/java/org/mvel2/tests/core/TbExpressionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2413,54 +2413,6 @@ public void testExpectType_InputKnownEgressTypeAsInterface() {
assertEquals(expected, actual);
}

public void testExecutionHashMap_Public_Key_Value() {
String body = "var msg1 = {\n" +
" \"temperature\": 22.4,\n" +
" \"humidity\": 78\n" +
"};\n" +
"\n" +
"var map = {\n" +
" \"test\": 42,\n" +
" \"nested\": {\n" +
" \"rssi\": 130\n" +
" }\n" +
"};\n" +
"foreach(element: map) {\n" +
" msg1[element.key] = element.value;\n" +
"}\n" +
"return {\n" +
" msg1\n" +
"};";
Object result = executeScript(body);

String expected = "[{temperature=22.4, humidity=78, test=42, nested={rssi=130}}]";
assertEquals(expected, result.toString());
}

public void testExecutionHashMap_getKey_getValue() {
String body = "var msg1 = {\n" +
" \"temperature\": 22.4,\n" +
" \"humidity\": 78\n" +
"};\n" +
"\n" +
"var map = {\n" +
" \"test\": 42,\n" +
" \"nested\": {\n" +
" \"rssi\": 130\n" +
" }\n" +
"};\n" +
"foreach(element: map) {\n" +
" msg1[element.getKey()] = element.getValue();\n" +
"}\n" +
"return {\n" +
" msg1\n" +
"};";
Object result = executeScript(body);

String expected = "[{temperature=22.4, humidity=78, test=42, nested={rssi=130}}]";
assertEquals(expected, result.toString());
}

public void testBooleanBitwiseOperations() {
String body = " var x = true;\n" +
"var y = false;\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,54 @@ public void testExecutionHashMap_ToReversed() {
assertTrue(eq);
}

public void testExecutionHashMap_Public_Key_Value() {
String body = "var msg1 = {\n" +
" \"temperature\": 22.4,\n" +
" \"humidity\": 78\n" +
"};\n" +
"\n" +
"var map = {\n" +
" \"test\": 42,\n" +
" \"nested\": {\n" +
" \"rssi\": 130\n" +
" }\n" +
"};\n" +
"foreach(element: map) {\n" +
" msg1[element.key] = element.value;\n" +
"}\n" +
"return {\n" +
" msg1\n" +
"};";
Object result = executeScript(body);

String expected = "[{temperature=22.4, humidity=78, test=42, nested={rssi=130}}]";
assertEquals(expected, result.toString());
}

public void testExecutionHashMap_getKey_getValue() {
String body = "var msg1 = {\n" +
" \"temperature\": 22.4,\n" +
" \"humidity\": 78\n" +
"};\n" +
"\n" +
"var map = {\n" +
" \"test\": 42,\n" +
" \"nested\": {\n" +
" \"rssi\": 130\n" +
" }\n" +
"};\n" +
"foreach(element: map) {\n" +
" msg1[element.getKey()] = element.getValue();\n" +
"}\n" +
"return {\n" +
" msg1\n" +
"};";
Object result = executeScript(body);

String expected = "[{temperature=22.4, humidity=78, test=42, nested={rssi=130}}]";
assertEquals(expected, result.toString());
}

// array

public void testCreateSingleValueArray() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void testStringToBytes_ArgumentTypeIsNotStringLineNotZero_Bad() throws Ex
}
}

public void testSHexToBytes_InFunction_Ok() throws Exception {
public void testHexToBytes_InFunction_Ok() throws Exception {
String scriptBody = "var data = frm();\n" +
"function frm(){\n" +
" var out = {};\n" +
Expand Down