Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #4420] Add Feishu Sink connector #4522

Merged
merged 11 commits into from
Nov 19, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
@EqualsAndHashCode(callSuper = true)
public class FeishuServerConfig extends Config {

private boolean sourceEnable;

private boolean sinkEnable;
SunnyBoy-WYH marked this conversation as resolved.
Show resolved Hide resolved

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,7 @@ public class FeishuConnectServer {

public static void main(String[] args) throws Exception {

FeishuServerConfig serverConfig = ConfigUtil.parse(FeishuServerConfig.class, "server-config.yml");

if (serverConfig.isSourceEnable()) {
Application feishuSourceApp = new Application();
feishuSourceApp.run(FeishuSinkConnector.class);
}

if (serverConfig.isSinkEnable()) {
Application feishuSinkApp = new Application();
feishuSinkApp.run(FeishuSinkConnector.class);
}
Application feishuSinkApp = new Application();
feishuSinkApp.run(FeishuSinkConnector.class);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.eventmesh.connector.s3.source;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

import org.apache.eventmesh.connector.feishu.sink.config.FeishuSinkConfig;
import org.apache.eventmesh.connector.feishu.sink.config.SinkConnectorConfig;
import org.apache.eventmesh.connector.feishu.sink.connector.FeishuSinkConnector;
Expand All @@ -28,34 +30,35 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;


@Disabled
public class FeishuSinkConnectorTest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you modify the code using Mockito stubbing or other mocking techniques to remove the annotation and make the test class runnable?

能否使用Mockito的打桩或者其他模拟的方式修改下代码,使该测试类可以移除掉该注解,并能实际运行?


private static final FeishuSinkConfig sinkConfig;

private static final SinkConnectorConfig SOURCE_CONNECTOR_CONFIG;
private static final SinkConnectorConfig SINK_CONNECTOR_CONFIG;

static {
sinkConfig = new FeishuSinkConfig();
SOURCE_CONNECTOR_CONFIG = new SinkConnectorConfig();
SOURCE_CONNECTOR_CONFIG.setConnectorName("FeishuSinkConnector");
SOURCE_CONNECTOR_CONFIG.setAppId("xxx");
SOURCE_CONNECTOR_CONFIG.setAppSecret("xxx");
SOURCE_CONNECTOR_CONFIG.setReceiveId("xxx");
SOURCE_CONNECTOR_CONFIG.setReceiveIdType("open_id");
sinkConfig.setConnectorConfig(SOURCE_CONNECTOR_CONFIG);
SINK_CONNECTOR_CONFIG = new SinkConnectorConfig();
SINK_CONNECTOR_CONFIG.setConnectorName("FeishuSinkConnector");
SINK_CONNECTOR_CONFIG.setAppId("xxx");
SINK_CONNECTOR_CONFIG.setAppSecret("xxx");
SINK_CONNECTOR_CONFIG.setReceiveId("xxx");
SINK_CONNECTOR_CONFIG.setReceiveIdType("open_id");
sinkConfig.setConnectorConfig(SINK_CONNECTOR_CONFIG);
}


@Test
public void testFeishuSinkConnector() throws Exception {
FeishuSinkConnector feishuSinkConnector = new FeishuSinkConnector();
feishuSinkConnector.init(sinkConfig);
feishuSinkConnector.start();
List<ConnectRecord> connectRecords = new ArrayList<>();
connectRecords.add(new ConnectRecord(null,null,0L,"test"));
feishuSinkConnector.put(connectRecords);
public void testFeishuSinkConnector() {
assertDoesNotThrow(() -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you are using Mockito for mocking, you can change the verification method of assertDoesNotThrow() to verify the number of calls to the feishuClient that you are mocking. Otherwise, the introduction of Mockito is meaningless.

现在您已经使用Mockito进行模拟了,就可以将assertDoesNotThrow()的验证方式改成验证您所模拟的feishuClient的调用次数。否则引入的Mockito就没有意义了。

FeishuSinkConnector feishuSinkConnector = new FeishuSinkConnector();
feishuSinkConnector.init(sinkConfig);
feishuSinkConnector.start();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One startup is enough. Additionally, it would be better to call stop () at the end of the test, although it is currently an empty method.

启动一次就够了。另外,测试结束时最好调用下stop(),虽然目前是个空方法。

List<ConnectRecord> connectRecords = new ArrayList<>();
connectRecords.add(new ConnectRecord(null, null, 0L, "test"));
feishuSinkConnector.put(connectRecords);
});
}
SunnyBoy-WYH marked this conversation as resolved.
Show resolved Hide resolved


Expand Down