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


##########
eventmesh-common/src/test/java/org/apache/eventmesh/common/protocol/http/WebhookProtocolTransportObjectTest.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.apache.eventmesh.common.Constants;
+import org.apache.eventmesh.common.utils.JsonUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class WebhookProtocolTransportObjectTest {
+
+    private WebhookProtocolTransportObject webhookProtocolTransportObject;
+
+    @Before
+    public void setUp() {
+        webhookProtocolTransportObject = 
WebhookProtocolTransportObject.builder().build();
+    }
+
+    @Test
+    public void testSetCloudEventId() {
+        
webhookProtocolTransportObject.setCloudEventId("d0b29520-2bba-11ee-877b-2b18ac132e64");
+    }
+
+    @Test
+    public void testSetEventType() {
+        webhookProtocolTransportObject.setEventType("github.all");
+    }
+
+    @Test
+    public void testSetCloudEventName() {
+        webhookProtocolTransportObject.setCloudEventName("github-eventmesh");
+    }
+
+    @Test
+    public void testSetCloudEventSource() {
+        webhookProtocolTransportObject.setCloudEventSource("www.github.com");
+    }
+
+    @Test
+    public void testSetDataContentType() {
+        webhookProtocolTransportObject.setDataContentType("application/json");
+    }
+
+    @Test
+    public void testSetBody() {
+        Map<String, Object> bodyMap = new HashMap<>();
+        bodyMap.put("user", "tom");
+        bodyMap.put("password", "123456");

Review Comment:
   In fact, you should compare the byte array of the body, not two hashmaps. 
you just need to convert a piece of **STRING** (the received web request, the 
actual value) to a byte array, and then construct an expected value on your 
own, convert it to a byte array and compare it to the former.
   
   For example:
   
   ```java
   String request = '...';
   byte[] expectedBody = ...;
   Assert.assertEquals(expectedBody, actualBody);
   ```



-- 
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