-
-
Notifications
You must be signed in to change notification settings - Fork 616
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
149 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
name: maven compile test | ||
|
||
on: [ pull_request ] | ||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
@@ -15,5 +19,12 @@ jobs: | |
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
- uses: mirromutth/[email protected] | ||
with: | ||
mysql version: '5.7' | ||
mysql database: 'sonic' | ||
mysql root password: 'Sonic!@#123' | ||
mysql user: 'root' | ||
mysql password: 'Sonic!@#123' | ||
- name: Validate and Compile with Maven | ||
run: mvn validate compile test | ||
run: mvn test |
272 changes: 136 additions & 136 deletions
272
sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotMsgToolTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,136 +1,136 @@ | ||
///* | ||
// * sonic-server Sonic Cloud Real Machine Platform. | ||
// * Copyright (C) 2022 SonicCloudOrg | ||
// * | ||
// * This program is free software: you can redistribute it and/or modify | ||
// * it under the terms of the GNU Affero General Public License as published | ||
// * by the Free Software Foundation, either version 3 of the License, or | ||
// * (at your option) any later version. | ||
// * | ||
// * This program is distributed in the hope that it will be useful, | ||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// * GNU Affero General Public License for more details. | ||
// * | ||
// * You should have received a copy of the GNU Affero General Public License | ||
// * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
// */ | ||
//package org.cloud.sonic.controller.tools; | ||
// | ||
//import org.cloud.sonic.controller.ControllerApplication; | ||
//import org.cloud.sonic.controller.models.interfaces.RobotType; | ||
//import org.junit.Test; | ||
//import org.junit.runner.RunWith; | ||
//import org.springframework.beans.factory.annotation.Autowired; | ||
//import org.springframework.boot.test.context.SpringBootTest; | ||
//import org.springframework.test.context.junit4.SpringRunner; | ||
// | ||
//@SpringBootTest(classes = ControllerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
//@RunWith(SpringRunner.class) | ||
//public class RobotMsgToolTest { | ||
// | ||
// @Autowired | ||
// private RobotMsgTool robotMsgTool; | ||
// | ||
// private String wechatToken = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx"; | ||
// | ||
// private String feishuToken = "https://open.feishu.cn/open-apis/bot/v2/hook/xxx"; | ||
// | ||
// // API path https://api.telegram.org/bot<token>/sendMessage?chat_id=<chat_id> | ||
// private String telegramToken = "https://api.telegram.org/botxxx/sendMessage?chat_id=zzz"; | ||
// | ||
// private String lineToken = "XXXXX"; | ||
// | ||
// @Test | ||
// public void sendDayReportMessage() { | ||
// robotMsgTool.sendDayReportMessage(wechatToken, "", 1, "2", | ||
// "1", "2", 1, 2, 3, RobotType.WeChat); | ||
// } | ||
// | ||
// @Test | ||
// public void sendDayReportMessage2() { | ||
// robotMsgTool.sendDayReportMessage(wechatToken, "", 1, "2", | ||
// "1", "2", 1, 0, 0, RobotType.WeChat); | ||
// } | ||
// | ||
// @Test | ||
// public void testSendErrorDevice1() { | ||
// robotMsgTool.sendErrorDevice(wechatToken, "", RobotType.WeChat, 1, 80, "111"); | ||
// } | ||
// | ||
// | ||
// @Test | ||
// public void testSendErrorDevice2() { | ||
// robotMsgTool.sendErrorDevice(wechatToken, "", RobotType.WeChat, 2, 80, "111"); | ||
// } | ||
// | ||
// @Test | ||
// public void testSendErrorDeviceFeishu() { | ||
// robotMsgTool.sendErrorDevice(feishuToken, "", RobotType.FeiShu, 1, 80, "测试"); | ||
// } | ||
// | ||
// @Test | ||
// public void testSendErrorDeviceFeishu2() { | ||
// robotMsgTool.sendErrorDevice(feishuToken, "", RobotType.FeiShu, 2, 80, "测试"); | ||
// } | ||
// | ||
// | ||
// @Test | ||
// public void sendWeekReportMessage() { | ||
// robotMsgTool.sendWeekReportMessage(wechatToken, "", 1, "2", | ||
// "1", "2", 1, 0, 0, 100, RobotType.WeChat); | ||
// } | ||
// | ||
// @Test | ||
// public void sendResultFinishReport() { | ||
// robotMsgTool.sendResultFinishReport(wechatToken, "", "111", 1, 1, 1, 1, | ||
// 1, RobotType.WeChat); | ||
// } | ||
// | ||
// @Test | ||
// public void sendDayReportMessageForTelegram() { | ||
// robotMsgTool.sendDayReportMessage(telegramToken, "", 1, "2", | ||
// "1", "2", 1, 2, 3, RobotType.Telegram); | ||
// } | ||
// | ||
// @Test | ||
// public void sendResultFinishReportForTelegram() { | ||
// robotMsgTool.sendResultFinishReport(telegramToken, "", "111", 1, 1, 1, 1, | ||
// 1, RobotType.Telegram); | ||
// } | ||
// | ||
// @Test | ||
// public void sendWeekReportMessageForTelegram() { | ||
// robotMsgTool.sendWeekReportMessage(telegramToken, "", 1, "2", | ||
// "1", "2", 1, 0, 0, 100, RobotType.Telegram); | ||
// } | ||
// | ||
// @Test | ||
// public void testSendErrorDeviceForTelegram() { | ||
// robotMsgTool.sendErrorDevice(telegramToken, "", RobotType.Telegram, 2, 80, "测试"); | ||
// } | ||
// | ||
// @Test | ||
// public void sendDayReportMessageForLineNotify() { | ||
// robotMsgTool.sendDayReportMessage(lineToken, "", 1, "2", | ||
// "1", "2", 1, 2, 3, RobotType.LineNotify); | ||
// } | ||
// | ||
// @Test | ||
// public void sendResultFinishReportForLineNotify() { | ||
// robotMsgTool.sendResultFinishReport(lineToken, "", "111", 1, 1, 2, 1, | ||
// 1, RobotType.LineNotify); | ||
// } | ||
// | ||
// @Test | ||
// public void sendWeekReportMessageForLineNotify() { | ||
// robotMsgTool.sendWeekReportMessage(lineToken, "", 1, "2", | ||
// "1", "2", 1, 3, 5, 100, RobotType.LineNotify); | ||
// } | ||
// | ||
// @Test | ||
// public void testSendErrorDeviceForLineNotify() { | ||
// robotMsgTool.sendErrorDevice(lineToken, "", RobotType.LineNotify, 2, 80, "测试"); | ||
// } | ||
// | ||
//} | ||
/* | ||
* sonic-server Sonic Cloud Real Machine Platform. | ||
* Copyright (C) 2022 SonicCloudOrg | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package org.cloud.sonic.controller.tools; | ||
|
||
import org.cloud.sonic.controller.ControllerApplication; | ||
import org.cloud.sonic.controller.models.interfaces.RobotType; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
@SpringBootTest(classes = ControllerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@RunWith(SpringRunner.class) | ||
public class RobotMsgToolTest { | ||
|
||
@Autowired | ||
private RobotMsgTool robotMsgTool; | ||
|
||
private String wechatToken = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx"; | ||
|
||
private String feishuToken = "https://open.feishu.cn/open-apis/bot/v2/hook/xxx"; | ||
|
||
// API path https://api.telegram.org/bot<token>/sendMessage?chat_id=<chat_id> | ||
private String telegramToken = "https://api.telegram.org/botxxx/sendMessage?chat_id=zzz"; | ||
|
||
private String lineToken = "XXXXX"; | ||
|
||
@Test | ||
public void sendDayReportMessage() { | ||
robotMsgTool.sendDayReportMessage(wechatToken, "", 1, "2", | ||
"1", "2", 1, 2, 3, RobotType.WeChat); | ||
} | ||
|
||
@Test | ||
public void sendDayReportMessage2() { | ||
robotMsgTool.sendDayReportMessage(wechatToken, "", 1, "2", | ||
"1", "2", 1, 0, 0, RobotType.WeChat); | ||
} | ||
|
||
@Test | ||
public void testSendErrorDevice1() { | ||
robotMsgTool.sendErrorDevice(wechatToken, "", RobotType.WeChat, 1, 80, "111"); | ||
} | ||
|
||
|
||
@Test | ||
public void testSendErrorDevice2() { | ||
robotMsgTool.sendErrorDevice(wechatToken, "", RobotType.WeChat, 2, 80, "111"); | ||
} | ||
|
||
@Test | ||
public void testSendErrorDeviceFeishu() { | ||
robotMsgTool.sendErrorDevice(feishuToken, "", RobotType.FeiShu, 1, 80, "测试"); | ||
} | ||
|
||
@Test | ||
public void testSendErrorDeviceFeishu2() { | ||
robotMsgTool.sendErrorDevice(feishuToken, "", RobotType.FeiShu, 2, 80, "测试"); | ||
} | ||
|
||
|
||
@Test | ||
public void sendWeekReportMessage() { | ||
robotMsgTool.sendWeekReportMessage(wechatToken, "", 1, "2", | ||
"1", "2", 1, 0, 0, 100, RobotType.WeChat); | ||
} | ||
|
||
@Test | ||
public void sendResultFinishReport() { | ||
robotMsgTool.sendResultFinishReport(wechatToken, "", "111", 1, 1, 1, 1, | ||
1, RobotType.WeChat); | ||
} | ||
|
||
@Test | ||
public void sendDayReportMessageForTelegram() { | ||
robotMsgTool.sendDayReportMessage(telegramToken, "", 1, "2", | ||
"1", "2", 1, 2, 3, RobotType.Telegram); | ||
} | ||
|
||
@Test | ||
public void sendResultFinishReportForTelegram() { | ||
robotMsgTool.sendResultFinishReport(telegramToken, "", "111", 1, 1, 1, 1, | ||
1, RobotType.Telegram); | ||
} | ||
|
||
@Test | ||
public void sendWeekReportMessageForTelegram() { | ||
robotMsgTool.sendWeekReportMessage(telegramToken, "", 1, "2", | ||
"1", "2", 1, 0, 0, 100, RobotType.Telegram); | ||
} | ||
|
||
@Test | ||
public void testSendErrorDeviceForTelegram() { | ||
robotMsgTool.sendErrorDevice(telegramToken, "", RobotType.Telegram, 2, 80, "测试"); | ||
} | ||
|
||
@Test | ||
public void sendDayReportMessageForLineNotify() { | ||
robotMsgTool.sendDayReportMessage(lineToken, "", 1, "2", | ||
"1", "2", 1, 2, 3, RobotType.LineNotify); | ||
} | ||
|
||
@Test | ||
public void sendResultFinishReportForLineNotify() { | ||
robotMsgTool.sendResultFinishReport(lineToken, "", "111", 1, 1, 2, 1, | ||
1, RobotType.LineNotify); | ||
} | ||
|
||
@Test | ||
public void sendWeekReportMessageForLineNotify() { | ||
robotMsgTool.sendWeekReportMessage(lineToken, "", 1, "2", | ||
"1", "2", 1, 3, 5, 100, RobotType.LineNotify); | ||
} | ||
|
||
@Test | ||
public void testSendErrorDeviceForLineNotify() { | ||
robotMsgTool.sendErrorDevice(lineToken, "", RobotType.LineNotify, 2, 80, "测试"); | ||
} | ||
|
||
} |