|
|
|
@ -16,6 +16,7 @@ |
|
|
|
package org.thingsboard.rule.engine.rest; |
|
|
|
|
|
|
|
import com.datastax.oss.driver.api.core.uuid.Uuids; |
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
|
import org.apache.http.HttpException; |
|
|
|
import org.apache.http.HttpRequest; |
|
|
|
import org.apache.http.HttpResponse; |
|
|
|
@ -26,6 +27,7 @@ import org.apache.http.protocol.HttpContext; |
|
|
|
import org.apache.http.protocol.HttpRequestHandler; |
|
|
|
import org.junit.After; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.jupiter.api.Assertions; |
|
|
|
import org.junit.runner.RunWith; |
|
|
|
import org.mockito.ArgumentCaptor; |
|
|
|
import org.mockito.Mock; |
|
|
|
@ -39,6 +41,7 @@ import org.thingsboard.server.common.data.id.EntityId; |
|
|
|
import org.thingsboard.server.common.data.id.RuleChainId; |
|
|
|
import org.thingsboard.server.common.data.id.RuleNodeId; |
|
|
|
import org.thingsboard.server.common.data.msg.TbMsgType; |
|
|
|
import org.thingsboard.server.common.data.util.TbPair; |
|
|
|
import org.thingsboard.server.common.msg.TbMsg; |
|
|
|
import org.thingsboard.server.common.msg.TbMsgDataType; |
|
|
|
import org.thingsboard.server.common.msg.TbMsgMetaData; |
|
|
|
@ -91,7 +94,9 @@ public class TbRestApiCallNodeTest { |
|
|
|
|
|
|
|
@After |
|
|
|
public void teardown() { |
|
|
|
server.stop(); |
|
|
|
if (server != null) { |
|
|
|
server.stop(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
@ -211,4 +216,20 @@ public class TbRestApiCallNodeTest { |
|
|
|
assertEquals(TbMsg.EMPTY_JSON_OBJECT, dataCaptor.getValue()); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void givenOldConfig_whenUpgrade_thenShouldReturnTrueResultWithNewConfig() throws Exception { |
|
|
|
var defaultConfig = new TbRestApiCallNodeConfiguration().defaultConfiguration(); |
|
|
|
var node = new TbRestApiCallNode(); |
|
|
|
String oldConfig = "{\"restEndpointUrlPattern\":\"http://localhost/api\",\"requestMethod\":\"POST\"," + |
|
|
|
"\"useSimpleClientHttpFactory\":false,\"ignoreRequestBody\":false,\"enableProxy\":false," + |
|
|
|
"\"useSystemProxyProperties\":false,\"proxyScheme\":null,\"proxyHost\":null,\"proxyPort\":0," + |
|
|
|
"\"proxyUser\":null,\"proxyPassword\":null,\"readTimeoutMs\":0,\"maxParallelRequestsCount\":0," + |
|
|
|
"\"headers\":{\"Content-Type\":\"application/json\"},\"useRedisQueueForMsgPersistence\":false," + |
|
|
|
"\"trimQueue\":null,\"maxQueueSize\":null,\"credentials\":{\"type\":\"anonymous\"},\"trimDoubleQuotes\":true}"; |
|
|
|
JsonNode configJson = JacksonUtil.toJsonNode(oldConfig); |
|
|
|
TbPair<Boolean, JsonNode> upgrade = node.upgrade(0, configJson); |
|
|
|
Assertions.assertTrue(upgrade.getFirst()); |
|
|
|
Assertions.assertTrue(JacksonUtil.treeToValue(upgrade.getSecond(), defaultConfig.getClass()).isParseToPlainText()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|