updated device profile validation tests & convertToRpcRequest method in ProtoConverter
This commit is contained in:
parent
d769f6749c
commit
0d21170b7a
@ -779,7 +779,7 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
||||
"\n" +
|
||||
"message RpcRequestMsg {\n" +
|
||||
" optional int32 requestId = 2;\n" +
|
||||
" repeated string params = 3;\n" +
|
||||
" optional string params = 3;\n" +
|
||||
" \n" +
|
||||
"}", "[Transport Configuration] invalid rpc request proto schema provided! RpcRequestMsg message should always contains 3 fields: method, requestId and params!");
|
||||
}
|
||||
@ -793,7 +793,7 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
||||
"message RpcRequestMsg {\n" +
|
||||
" optional string methodName = 1;\n" +
|
||||
" optional int32 requestId = 2;\n" +
|
||||
" repeated string params = 3;\n" +
|
||||
" optional string params = 3;\n" +
|
||||
" \n" +
|
||||
"}", "[Transport Configuration] invalid rpc request proto schema provided! Failed to get field descriptor for field: method!");
|
||||
}
|
||||
@ -807,7 +807,7 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
||||
"message RpcRequestMsg {\n" +
|
||||
" optional string method = 1;\n" +
|
||||
" optional int32 requestIdentifier = 2;\n" +
|
||||
" repeated string params = 3;\n" +
|
||||
" optional string params = 3;\n" +
|
||||
" \n" +
|
||||
"}", "[Transport Configuration] invalid rpc request proto schema provided! Failed to get field descriptor for field: requestId!");
|
||||
}
|
||||
@ -821,7 +821,7 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
||||
"message RpcRequestMsg {\n" +
|
||||
" optional string method = 1;\n" +
|
||||
" optional int32 requestId = 2;\n" +
|
||||
" repeated string parameters = 3;\n" +
|
||||
" optional string parameters = 3;\n" +
|
||||
" \n" +
|
||||
"}", "[Transport Configuration] invalid rpc request proto schema provided! Failed to get field descriptor for field: params!");
|
||||
}
|
||||
|
||||
@ -58,13 +58,13 @@ public abstract class AbstractCoapServerSideRpcProtoIntegrationTest extends Abst
|
||||
"package rpc;\n" +
|
||||
"\n" +
|
||||
"message RpcRequestMsg {\n" +
|
||||
" string method = 1;\n" +
|
||||
" int32 requestId = 2;\n" +
|
||||
" optional string method = 1;\n" +
|
||||
" optional int32 requestId = 2;\n" +
|
||||
" Params params = 3;\n" +
|
||||
"\n" +
|
||||
" message Params {\n" +
|
||||
" string pin = 1;\n" +
|
||||
" int32 value = 2;\n" +
|
||||
" optional string pin = 1;\n" +
|
||||
" optional int32 value = 2;\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
|
||||
@ -56,13 +56,13 @@ public abstract class AbstractMqttServerSideRpcProtoIntegrationTest extends Abst
|
||||
"package rpc;\n" +
|
||||
"\n" +
|
||||
"message RpcRequestMsg {\n" +
|
||||
" string method = 1;\n" +
|
||||
" int32 requestId = 2;\n" +
|
||||
" optional string method = 1;\n" +
|
||||
" optional int32 requestId = 2;\n" +
|
||||
" Params params = 3;\n" +
|
||||
"\n" +
|
||||
" message Params {\n" +
|
||||
" string pin = 1;\n" +
|
||||
" int32 value = 2;\n" +
|
||||
" optional string pin = 1;\n" +
|
||||
" optional int32 value = 2;\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ public class ProtoTransportPayloadConfiguration implements TransportPayloadTypeC
|
||||
"package rpc;\n" +
|
||||
"\n" +
|
||||
"message RpcResponseMsg {\n" +
|
||||
" string payload = 1;\n" +
|
||||
" optional string payload = 1;\n" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@ -96,9 +96,9 @@ public class ProtoTransportPayloadConfiguration implements TransportPayloadTypeC
|
||||
"package rpc;\n" +
|
||||
"\n" +
|
||||
"message RpcRequestMsg {\n" +
|
||||
" string method = 1;\n" +
|
||||
" int32 requestId = 2;\n" +
|
||||
" string params = 3;\n" +
|
||||
" optional string method = 1;\n" +
|
||||
" optional int32 requestId = 2;\n" +
|
||||
" optional string params = 3;\n" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
package org.thingsboard.server.transport.coap.adaptors;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.protobuf.Descriptors;
|
||||
import com.google.protobuf.DynamicMessage;
|
||||
|
||||
@ -175,7 +175,7 @@ public class ProtoConverter {
|
||||
}
|
||||
|
||||
public static byte[] convertToRpcRequest(TransportProtos.ToDeviceRpcRequestMsg toDeviceRpcRequestMsg, DynamicMessage.Builder rpcRequestDynamicMessageBuilder) throws AdaptorException {
|
||||
rpcRequestDynamicMessageBuilder.clear();
|
||||
rpcRequestDynamicMessageBuilder = rpcRequestDynamicMessageBuilder.getDefaultInstanceForType().newBuilderForType();
|
||||
JsonObject rpcRequestJson = new JsonObject();
|
||||
rpcRequestJson.addProperty("method", toDeviceRpcRequestMsg.getMethodName());
|
||||
rpcRequestJson.addProperty("requestId", toDeviceRpcRequestMsg.getRequestId());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user