Pil0tXia commented on code in PR #4340:
URL: https://github.com/apache/eventmesh/pull/4340#discussion_r1285567750


##########
eventmesh-common/src/test/java/org/apache/eventmesh/common/protocol/http/WebhookProtocolTransportObjectTest.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.common.protocol.http;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class WebhookProtocolTransportObjectTest {
+
+    WebhookProtocolTransportObject webhookProtocolTransportObject = new 
WebhookProtocolTransportObject("cloudEventId", "eventType",
+        "cloudEventName", "cloudEventSource", "dataContentType", new byte[] 
{(byte) 0});
+
+    @Test
+    public void testSetCloudEventId() {
+        webhookProtocolTransportObject.setCloudEventId("cloudEventId");
+    }
+
+    @Test
+    public void testSetEventType() {
+        webhookProtocolTransportObject.setEventType("eventType");
+    }
+
+    @Test
+    public void testSetCloudEventName() {
+        webhookProtocolTransportObject.setCloudEventName("cloudEventName");
+    }
+
+    @Test
+    public void testSetCloudEventSource() {
+        webhookProtocolTransportObject.setCloudEventSource("cloudEventSource");
+    }
+
+    @Test
+    public void testSetDataContentType() {
+        webhookProtocolTransportObject.setDataContentType("dataContentType");
+    }
+
+    @Test
+    public void testSetBody() {
+        webhookProtocolTransportObject.setBody(new byte[]{(byte) 0});

Review Comment:
   Not enough. The builder should be used like this:
   
   ```
   WebhookProtocolTransportObject webhookProtocolTransportObject = 
WebhookProtocolTransportObject.builder()
               
.cloudEventId(cloudEventId).eventType(eventType).cloudEventName(webHookConfig.getCloudEventName())
               .cloudEventSource(webHookConfig.getManufacturerDomain())
               
.dataContentType(webHookConfig.getDataContentType()).body(body).build();
   ```
   
   Pleas substitute getters with expected value. Otherwise, the test will fail.
   
   Moreover, as is said above twice, I suggest give full bytes to `body` in 
`testSetBody`, instead of `0`, as is shown in the screenshot.
   
   
![image](https://github.com/apache/eventmesh/assets/41445332/7203db8f-d9de-4fd2-80d2-6269d19c600a)
   
   You may build a byte array with a test string. As is used in 
`WebHookController`:
   
   ```
   ByteBuf buf = ((FullHttpRequest) httpRequest).content();
               webHookController.execute(httpRequest.uri(), header, 
ByteBufUtil.getBytes(buf));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to