pandaapo commented on code in PR #4603:
URL: https://github.com/apache/eventmesh/pull/4603#discussion_r1416386014
##########
eventmesh-connectors/eventmesh-connector-wechat/src/test/java/org/apache/eventmesh/connector/wechat/sink/connector/WeChatSinkConnectorTest.java:
##########
@@ -95,31 +112,44 @@ public void setUp() throws Exception {
Mockito.doReturn(sendMessageRequestCall).when(okHttpClient).newCall(Mockito.argThat(sendMessageMatcher));
Mockito.doReturn(sendMessageResponse).when(sendMessageRequestCall).execute();
- weChatSinkConnector = new WeChatSinkConnector();
- WeChatSinkConfig weChatSinkConfig = (WeChatSinkConfig)
ConfigUtil.parse(weChatSinkConnector.configClass());
- weChatSinkConnector.init(weChatSinkConfig);
- Field clientField =
ReflectionSupport.findFields(weChatSinkConnector.getClass(),
- (f) -> f.getName().equals("okHttpClient"),
- HierarchyTraversalMode.BOTTOM_UP).get(0);
- clientField.setAccessible(true);
- clientField.set(weChatSinkConnector, okHttpClient);
- weChatSinkConnector.start();
+ List<ConnectRecord> records = new ArrayList<>();
+ RecordPartition partition = new RecordPartition();
+ RecordOffset offset = new RecordOffset();
+ ConnectRecord connectRecord = new ConnectRecord(partition, offset,
+ System.currentTimeMillis(), "Hello,
EventMesh!".getBytes(StandardCharsets.UTF_8));
+ records.add(connectRecord);
+
+ weChatSinkConnector.put(records);
+ verify(okHttpClient, times(2)).newCall(any(Request.class));
+
+
WeChatSinkConnector.ACCESS_TOKEN_CACHE.invalidate(WeChatSinkConnector.ACCESS_TOKEN_CACHE_KEY);
Review Comment:
I am thinking about the necessity of this line of code. It seems that you
did not actually interact with WeChat in your test, so you should not be using
this token.
我在思考这行代码的必要性。您的测试中好像并不会真的与wechat交互,应该用不到该token吧。
##########
eventmesh-connectors/eventmesh-connector-wechat/src/test/java/org/apache/eventmesh/connector/wechat/sink/connector/WeChatSinkConnectorTest.java:
##########
@@ -95,31 +112,44 @@ public void setUp() throws Exception {
Mockito.doReturn(sendMessageRequestCall).when(okHttpClient).newCall(Mockito.argThat(sendMessageMatcher));
Mockito.doReturn(sendMessageResponse).when(sendMessageRequestCall).execute();
- weChatSinkConnector = new WeChatSinkConnector();
- WeChatSinkConfig weChatSinkConfig = (WeChatSinkConfig)
ConfigUtil.parse(weChatSinkConnector.configClass());
- weChatSinkConnector.init(weChatSinkConfig);
- Field clientField =
ReflectionSupport.findFields(weChatSinkConnector.getClass(),
- (f) -> f.getName().equals("okHttpClient"),
- HierarchyTraversalMode.BOTTOM_UP).get(0);
- clientField.setAccessible(true);
- clientField.set(weChatSinkConnector, okHttpClient);
- weChatSinkConnector.start();
+ List<ConnectRecord> records = new ArrayList<>();
+ RecordPartition partition = new RecordPartition();
+ RecordOffset offset = new RecordOffset();
+ ConnectRecord connectRecord = new ConnectRecord(partition, offset,
+ System.currentTimeMillis(), "Hello,
EventMesh!".getBytes(StandardCharsets.UTF_8));
+ records.add(connectRecord);
+
+ weChatSinkConnector.put(records);
+ verify(okHttpClient, times(2)).newCall(any(Request.class));
+
+
WeChatSinkConnector.ACCESS_TOKEN_CACHE.invalidate(WeChatSinkConnector.ACCESS_TOKEN_CACHE_KEY);
Review Comment:
I am thinking about the necessity of this line of code. It seems that you
did not actually interact with WeChat in your test, so you should not be using
this token.
我在思考这行代码的必要性。您的测试中好像并不会真的与wechat交互,应该用不到该token吧。
--
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]