Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
beba6e494d |
16
.idea/checkstyle-idea.xml
generated
16
.idea/checkstyle-idea.xml
generated
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CheckStyle-IDEA" serialisationVersion="2">
|
|
||||||
<checkstyleVersion>10.22.0</checkstyleVersion>
|
|
||||||
<scanScope>JavaOnly</scanScope>
|
|
||||||
<copyLibs>true</copyLibs>
|
|
||||||
<option name="thirdPartyClasspath" />
|
|
||||||
<option name="activeLocationIds" />
|
|
||||||
<option name="locations">
|
|
||||||
<list>
|
|
||||||
<ConfigurationLocation id="bundled-sun-checks" type="BUNDLED" scope="All" description="Sun Checks">(bundled)</ConfigurationLocation>
|
|
||||||
<ConfigurationLocation id="bundled-google-checks" type="BUNDLED" scope="All" description="Google Checks">(bundled)</ConfigurationLocation>
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
21
.idea/compiler.xml
generated
21
.idea/compiler.xml
generated
@ -2,6 +2,7 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<annotationProcessing>
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="true" />
|
||||||
<profile name="Maven default annotation processors profile" enabled="true">
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
@ -14,5 +15,25 @@
|
|||||||
<module name="wechat-j-oa" />
|
<module name="wechat-j-oa" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
|
<bytecodeTargetLevel>
|
||||||
|
<module name="wechat-j-oa (1)" target="11" />
|
||||||
|
<module name="wechat-j-oa (2)" target="1.8" />
|
||||||
|
<module name="weixin-graal" target="1.8" />
|
||||||
|
<module name="weixin-java-common" target="1.8" />
|
||||||
|
<module name="weixin-java-cp" target="1.8" />
|
||||||
|
<module name="weixin-java-miniapp" target="1.8" />
|
||||||
|
<module name="weixin-java-mp" target="1.8" />
|
||||||
|
<module name="weixin-java-open" target="1.8" />
|
||||||
|
<module name="weixin-java-pay" target="1.8" />
|
||||||
|
<module name="weixin-java-qidian" target="1.8" />
|
||||||
|
<module name="wx-java" target="1.8" />
|
||||||
|
<module name="wx-java-cp-spring-boot-starter" target="1.8" />
|
||||||
|
<module name="wx-java-miniapp-spring-boot-starter" target="1.8" />
|
||||||
|
<module name="wx-java-mp-spring-boot-starter" target="1.8" />
|
||||||
|
<module name="wx-java-open-spring-boot-starter" target="1.8" />
|
||||||
|
<module name="wx-java-pay-spring-boot-starter" target="1.8" />
|
||||||
|
<module name="wx-java-qidian-spring-boot-starter" target="1.8" />
|
||||||
|
<module name="wx-java-spring-boot-starters" target="1.8" />
|
||||||
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
22
.idea/encodings.xml
generated
22
.idea/encodings.xml
generated
@ -11,8 +11,30 @@
|
|||||||
<file url="file://$PROJECT_DIR$/open/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/open/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/pay/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/pay/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/pay/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/pay/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/wx-java-miniapp-spring-boot-starter/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/wx-java-mp-spring-boot-starter/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/wx-java-open-spring-boot-starter/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/wx-java-pay-spring-boot-starter/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/wx-java-pay-spring-boot-starter/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/spring-boot-starters/wx-java-qidian-spring-boot-starter/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/weixin-graal/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/weixin-graal/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/weixin-java-miniapp/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/weixin-java-miniapp/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/weixin-java-mp/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/weixin-java-mp/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/weixin-java-qidian/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/weixin-java-qidian/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/work/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/work/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/work/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/work/src/main/resources" charset="UTF-8" />
|
||||||
</component>
|
</component>
|
||||||
|
1831
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
1831
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
.idea/jarRepositories.xml
generated
20
.idea/jarRepositories.xml
generated
@ -1,20 +1,25 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="RemoteRepositoriesConfiguration">
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="ossez-repo-snapshots" />
|
||||||
|
<option name="name" value="OSSEZ Private Snapshots" />
|
||||||
|
<option name="url" value="https://repo.ossez.com/repository/maven-snapshots/" />
|
||||||
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="ossez-repo-releases" />
|
<option name="id" value="ossez-repo-releases" />
|
||||||
<option name="name" value="iSharkFly Private Releases" />
|
<option name="name" value="OSSEZ Private Releases" />
|
||||||
<option name="url" value="https://repo.isharkfly.com/repository/isharkfly-maven-releases/" />
|
<option name="url" value="https://repo.ossez.com/repository/maven-releases/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="Central Repository" />
|
<option name="name" value="Central Repository" />
|
||||||
<option name="url" value="https://repo.isharkfly.com/repository/maven/" />
|
<option name="url" value="https://repo.ossez.com/repository/maven-public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="ossez-repo-snapshots" />
|
<option name="id" value="ossez-repo-snapshots" />
|
||||||
<option name="name" value="iSharkFly Private Snapshots" />
|
<option name="name" value="OSSEZ Private Snapshots" />
|
||||||
<option name="url" value="https://repo.isharkfly.com/repository/isharkfly-maven-snapshots/" />
|
<option name="url" value="https://repo.ossez.com/repository/maven-public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
@ -26,5 +31,10 @@
|
|||||||
<option name="name" value="JBoss Community repository" />
|
<option name="name" value="JBoss Community repository" />
|
||||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="ossez-repo-releases" />
|
||||||
|
<option name="name" value="OSSEZ Private Releases" />
|
||||||
|
<option name="url" value="https://repo.ossez.com/repository/maven-public/" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
6
.idea/jpa-buddy.xml
generated
Normal file
6
.idea/jpa-buddy.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JpaBuddyIdeaProjectConfig">
|
||||||
|
<option name="renamerInitialized" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
12
.idea/php.xml
generated
Normal file
12
.idea/php.xml
generated
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="MessDetectorOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PHPCSFixerOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
1
.idea/vcs.xml
generated
1
.idea/vcs.xml
generated
@ -2,5 +2,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
346
common/pom.xml
346
common/pom.xml
@ -2,185 +2,195 @@
|
|||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0">
|
xmlns="http://maven.apache.org/POM/4.0.0">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.ossez.wechat</groupId>
|
||||||
|
<artifactId>wechat-j-common</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
<groupId>com.ossez.wechat</groupId>
|
<groupId>com.ossez.wechat</groupId>
|
||||||
<artifactId>wechat-j-common</artifactId>
|
<artifactId>wechat-j</artifactId>
|
||||||
<packaging>jar</packaging>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<parent>
|
<name>WeChat Java Common</name>
|
||||||
<groupId>com.ossez.wechat</groupId>
|
<description>The module is common for all other package</description>
|
||||||
<artifactId>wechat-j</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<name>WeChat Java Common</name>
|
<dependencies>
|
||||||
<description>The module is common for all other package</description>
|
<dependency>
|
||||||
|
<groupId>org.jodd</groupId>
|
||||||
|
<artifactId>jodd-http</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependencies>
|
<dependency>
|
||||||
<dependency>
|
<groupId>org.slf4j</groupId>
|
||||||
<groupId>org.jodd</groupId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<artifactId>jodd-http</artifactId>
|
</dependency>
|
||||||
<scope>provided</scope>
|
<dependency>
|
||||||
</dependency>
|
<groupId>com.thoughtworks.xstream</groupId>
|
||||||
|
<artifactId>xstream</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpmime</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>jcl-over-slf4j</artifactId>
|
||||||
|
<version>1.7.36</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.thoughtworks.xstream</groupId>
|
<groupId>commons-codec</groupId>
|
||||||
<artifactId>xstream</artifactId>
|
<artifactId>commons-codec</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>httpclient</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<exclusions>
|
</dependency>
|
||||||
<exclusion>
|
<dependency>
|
||||||
<artifactId>commons-logging</artifactId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<groupId>commons-logging</groupId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
</exclusion>
|
</dependency>
|
||||||
</exclusions>
|
<dependency>
|
||||||
</dependency>
|
<groupId>com.google.guava</groupId>
|
||||||
<dependency>
|
<artifactId>guava</artifactId>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
</dependency>
|
||||||
<artifactId>httpmime</artifactId>
|
<dependency>
|
||||||
</dependency>
|
<groupId>org.projectlombok</groupId>
|
||||||
<dependency>
|
<artifactId>lombok</artifactId>
|
||||||
<groupId>org.slf4j</groupId>
|
</dependency>
|
||||||
<artifactId>jcl-over-slf4j</artifactId>
|
|
||||||
<version>1.7.36</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
</dependency>
|
<scope>test</scope>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>commons-codec</groupId>
|
<dependency>
|
||||||
<artifactId>commons-codec</artifactId>
|
<groupId>org.testng</groupId>
|
||||||
</dependency>
|
<artifactId>testng</artifactId>
|
||||||
<dependency>
|
<scope>test</scope>
|
||||||
<groupId>commons-io</groupId>
|
</dependency>
|
||||||
<artifactId>commons-io</artifactId>
|
<dependency>
|
||||||
</dependency>
|
<groupId>org.mockito</groupId>
|
||||||
<dependency>
|
<artifactId>mockito-all</artifactId>
|
||||||
<groupId>org.apache.commons</groupId>
|
<scope>test</scope>
|
||||||
<artifactId>commons-lang3</artifactId>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
<dependency>
|
<groupId>com.google.inject</groupId>
|
||||||
<groupId>com.google.guava</groupId>
|
<artifactId>guice</artifactId>
|
||||||
<artifactId>guava</artifactId>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>jetty-server</artifactId>
|
||||||
</dependency>
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-servlet</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-guava</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.dom4j</groupId>
|
||||||
|
<artifactId>dom4j</artifactId>
|
||||||
|
<version>2.1.3</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>pull-parser</groupId>
|
||||||
|
<artifactId>pull-parser</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>redis.clients</groupId>
|
||||||
|
<artifactId>jedis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.jedis-lock</groupId>
|
||||||
|
<artifactId>jedis-lock</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<dependency>
|
<build>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<plugins>
|
||||||
<artifactId>logback-classic</artifactId>
|
<plugin>
|
||||||
<scope>test</scope>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
</dependency>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<dependency>
|
<configuration>
|
||||||
<groupId>com.google.inject</groupId>
|
<suiteXmlFiles>
|
||||||
<artifactId>guice</artifactId>
|
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
|
||||||
<scope>test</scope>
|
</suiteXmlFiles>
|
||||||
</dependency>
|
</configuration>
|
||||||
<dependency>
|
</plugin>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
</plugins>
|
||||||
<artifactId>jetty-server</artifactId>
|
</build>
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
|
||||||
<artifactId>jetty-servlet</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.assertj</groupId>
|
|
||||||
<artifactId>assertj-guava</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dom4j</groupId>
|
|
||||||
<artifactId>dom4j</artifactId>
|
|
||||||
<version>2.1.3</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>pull-parser</groupId>
|
|
||||||
<artifactId>pull-parser</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>redis.clients</groupId>
|
|
||||||
<artifactId>jedis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.jedis-lock</groupId>
|
|
||||||
<artifactId>jedis-lock</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.redisson</groupId>
|
|
||||||
<artifactId>redisson</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.data</groupId>
|
|
||||||
<artifactId>spring-data-redis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jetbrains</groupId>
|
|
||||||
<artifactId>annotations</artifactId>
|
|
||||||
<version>RELEASE</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>native-image</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>false</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
|
||||||
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<version>3.5.1</version>
|
||||||
<suiteXmlFiles>
|
<configuration>
|
||||||
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
|
<annotationProcessors>
|
||||||
</suiteXmlFiles>
|
com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||||
</configuration>
|
</annotationProcessors>
|
||||||
</plugin>
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>com.github.binarywang</groupId>
|
||||||
|
<artifactId>weixin-graal</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
</profile>
|
||||||
<profile>
|
</profiles>
|
||||||
<id>native-image</id>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>false</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.5.1</version>
|
|
||||||
<configuration>
|
|
||||||
<annotationProcessors>
|
|
||||||
com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
|
||||||
</annotationProcessors>
|
|
||||||
<annotationProcessorPaths>
|
|
||||||
<path>
|
|
||||||
<groupId>com.github.binarywang</groupId>
|
|
||||||
<artifactId>weixin-graal</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</path>
|
|
||||||
</annotationProcessorPaths>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.wechat.common.model.entity.menu;
|
package com.ossez.wechat.common.bean.menu;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@ -19,7 +19,7 @@ import lombok.Data;
|
|||||||
public class WxMenu implements Serializable {
|
public class WxMenu implements Serializable {
|
||||||
private static final long serialVersionUID = -7083914585539687746L;
|
private static final long serialVersionUID = -7083914585539687746L;
|
||||||
|
|
||||||
private List<MenuButton> buttons = new ArrayList<>();
|
private List<WxMenuButton> buttons = new ArrayList<>();
|
||||||
|
|
||||||
private WxMenuRule matchRule;
|
private WxMenuRule matchRule;
|
||||||
|
|
@ -0,0 +1,96 @@
|
|||||||
|
package com.ossez.wechat.common.bean.menu;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import com.ossez.wechat.common.util.json.WxGsonBuilder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* menu button.
|
||||||
|
*
|
||||||
|
* @author Daniel Qian
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WxMenuButton implements Serializable {
|
||||||
|
private static final long serialVersionUID = -1070939403109776555L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 菜单的响应动作类型.
|
||||||
|
* view表示网页类型,
|
||||||
|
* click表示点击类型,
|
||||||
|
* miniprogram表示小程序类型
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单标题,不超过16个字节,子菜单不超过60个字节.
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 菜单KEY值,用于消息接口推送,不超过128字节.
|
||||||
|
* click等点击类型必须
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 网页链接.
|
||||||
|
* 用户点击菜单可打开链接,不超过1024字节。type为miniprogram时,不支持小程序的老版本客户端将打开本url。
|
||||||
|
* view、miniprogram类型必须
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 调用新增永久素材接口返回的合法media_id.
|
||||||
|
* media_id类型和view_limited类型必须
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@SerializedName("media_id")
|
||||||
|
private String mediaId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 调用发布图文接口获得的article_id.
|
||||||
|
* article_id类型和article_view_limited类型必须
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@SerializedName("article_id")
|
||||||
|
private String articleId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 小程序的appid.
|
||||||
|
* miniprogram类型必须
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@SerializedName("appid")
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* 小程序的页面路径.
|
||||||
|
* miniprogram类型必须
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
@SerializedName("pagepath")
|
||||||
|
private String pagePath;
|
||||||
|
|
||||||
|
@SerializedName("sub_button")
|
||||||
|
private List<WxMenuButton> subButtons = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return WxGsonBuilder.create().toJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.ossez.wechat.common.model.entity.menu;
|
package com.ossez.wechat.common.bean.menu;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -58,33 +58,51 @@ public class WeChatConstant {
|
|||||||
/**
|
/**
|
||||||
* 主动发送消息(即客服消息)的消息类型.
|
* 主动发送消息(即客服消息)的消息类型.
|
||||||
*/
|
*/
|
||||||
public static class MsgType {
|
public static class KefuMsgType {
|
||||||
/**
|
/**
|
||||||
* 消息类型:
|
* 文本消息.
|
||||||
* text(文本)
|
|
||||||
* image(图片)
|
|
||||||
* voice(语音)
|
|
||||||
* video(视频)
|
|
||||||
* music(音乐)
|
|
||||||
* news(图文消息 - 点击跳转到外链)
|
|
||||||
* mpnews(图文消息 - 点击跳转到图文消息页面)
|
|
||||||
* wxcard(卡券)
|
|
||||||
* miniprogrampage(小程序)
|
|
||||||
* markdown(目前仅支持markdown语法的子集,微工作台(原企业号)不支持展示markdown消息)
|
|
||||||
* file(发送文件 - CP专用)
|
|
||||||
* textcard(文本卡片消息 - CP专用)
|
|
||||||
* wxcard(卡券消息)
|
|
||||||
*/
|
*/
|
||||||
public static final String TEXT = "text";
|
public static final String TEXT = "text";
|
||||||
|
/**
|
||||||
|
* 图片消息.
|
||||||
|
*/
|
||||||
public static final String IMAGE = "image";
|
public static final String IMAGE = "image";
|
||||||
|
/**
|
||||||
|
* 语音消息.
|
||||||
|
*/
|
||||||
public static final String VOICE = "voice";
|
public static final String VOICE = "voice";
|
||||||
|
/**
|
||||||
|
* 视频消息.
|
||||||
|
*/
|
||||||
public static final String VIDEO = "video";
|
public static final String VIDEO = "video";
|
||||||
|
/**
|
||||||
|
* 音乐消息.
|
||||||
|
*/
|
||||||
public static final String MUSIC = "music";
|
public static final String MUSIC = "music";
|
||||||
|
/**
|
||||||
|
* 图文消息(点击跳转到外链).
|
||||||
|
*/
|
||||||
public static final String NEWS = "news";
|
public static final String NEWS = "news";
|
||||||
|
/**
|
||||||
|
* 图文消息(点击跳转到图文消息页面).
|
||||||
|
*/
|
||||||
public static final String MPNEWS = "mpnews";
|
public static final String MPNEWS = "mpnews";
|
||||||
|
/**
|
||||||
|
* markdown消息.
|
||||||
|
* (目前仅支持markdown语法的子集,微工作台(原企业号)不支持展示markdown消息)
|
||||||
|
*/
|
||||||
public static final String MARKDOWN = "markdown";
|
public static final String MARKDOWN = "markdown";
|
||||||
|
/**
|
||||||
|
* 发送文件(CP专用).
|
||||||
|
*/
|
||||||
public static final String FILE = "file";
|
public static final String FILE = "file";
|
||||||
|
/**
|
||||||
|
* 文本卡片消息(CP专用).
|
||||||
|
*/
|
||||||
public static final String TEXTCARD = "textcard";
|
public static final String TEXTCARD = "textcard";
|
||||||
|
/**
|
||||||
|
* 卡券消息.
|
||||||
|
*/
|
||||||
public static final String WXCARD = "wxcard";
|
public static final String WXCARD = "wxcard";
|
||||||
/**
|
/**
|
||||||
* 转发到客服的消息.
|
* 转发到客服的消息.
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
package com.ossez.wechat.common.exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniel Qian
|
|
||||||
*/
|
|
||||||
public class DataStructureException extends WxErrorException {
|
|
||||||
private static final long serialVersionUID = -6357149550353160810L;
|
|
||||||
|
|
||||||
private final WxError error;
|
|
||||||
|
|
||||||
private static final int DEFAULT_ERROR_CODE = -99;
|
|
||||||
|
|
||||||
public DataStructureException(String message) {
|
|
||||||
this(WxError.builder().errorCode(DEFAULT_ERROR_CODE).errorMsg(message).build());
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataStructureException(WxError error) {
|
|
||||||
super(error.toString());
|
|
||||||
this.error = error;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public WxError getError() {
|
|
||||||
return this.error;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package com.ossez.wechat.common.model;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WeChatStatus Response Object
|
|
||||||
*
|
|
||||||
* @author YuCheng Hu
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class WeChatStatus {
|
|
||||||
|
|
||||||
@JsonProperty("errcode")
|
|
||||||
private int errCode = 0;
|
|
||||||
|
|
||||||
@JsonProperty("errmsg")
|
|
||||||
private String errMsg;
|
|
||||||
|
|
||||||
public int getErrCode() {
|
|
||||||
return errCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setErrCode(int errCode) {
|
|
||||||
this.errCode = errCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getErrMsg() {
|
|
||||||
return errMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setErrMsg(String errMsg) {
|
|
||||||
this.errMsg = errMsg;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
package com.ossez.wechat.common.model.entity.builder;
|
|
||||||
|
|
||||||
import com.ossez.wechat.common.model.entity.menu.MenuButton;
|
|
||||||
import com.ossez.wechat.common.model.req.MenuRequest;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MenuButtonBuilder {
|
|
||||||
private List<MenuButton> subButtonList;
|
|
||||||
private String type;
|
|
||||||
private String name;
|
|
||||||
private String key;
|
|
||||||
private String url;
|
|
||||||
|
|
||||||
public MenuButtonBuilder setSubButtonList(List<MenuButton> subButtonList) {
|
|
||||||
this.subButtonList = subButtonList;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MenuButtonBuilder setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MenuButtonBuilder setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MenuButtonBuilder setKey(String key) {
|
|
||||||
this.key = key;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MenuButtonBuilder setUrl(String url) {
|
|
||||||
this.url = url;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MenuButton createMenuButton() {
|
|
||||||
return new MenuButton(subButtonList, type, name, key, url);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package com.ossez.wechat.common.model.entity.menu;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
import com.ossez.wechat.common.model.req.MenuRequest;
|
|
||||||
import com.ossez.wechat.common.util.json.WxGsonBuilder;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* menu button.
|
|
||||||
*
|
|
||||||
* @author Daniel Qian
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class MenuButton implements Serializable {
|
|
||||||
private static final long serialVersionUID = -1070939403109776555L;
|
|
||||||
|
|
||||||
public MenuButton(List<MenuButton> subButtonList, String type, String name, String key, String url) {
|
|
||||||
this.subButtonList = subButtonList;
|
|
||||||
this.type = type;
|
|
||||||
this.name = name;
|
|
||||||
this.key = key;
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonProperty(value = "sub_button")
|
|
||||||
private List<MenuButton> subButtonList;
|
|
||||||
@JsonProperty("type")
|
|
||||||
private String type;
|
|
||||||
@JsonProperty("name")
|
|
||||||
private String name;
|
|
||||||
@JsonProperty("key")
|
|
||||||
private String key;
|
|
||||||
@JsonProperty("url")
|
|
||||||
private String url;
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package com.ossez.wechat.common.model.req;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CustomMessage
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*/
|
|
||||||
public class DataCubeRequest implements Serializable {
|
|
||||||
private static final long serialVersionUID = -9196732086954365246L;
|
|
||||||
|
|
||||||
@JsonProperty(value = "begin_date", required = true)
|
|
||||||
private String beginDate;
|
|
||||||
|
|
||||||
@JsonProperty(value = "end_date", required = true)
|
|
||||||
private String endDate;
|
|
||||||
|
|
||||||
public String getBeginDate() {
|
|
||||||
return beginDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBeginDate(String beginDate) {
|
|
||||||
this.beginDate = beginDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEndDate() {
|
|
||||||
return endDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEndDate(String endDate) {
|
|
||||||
this.endDate = endDate;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package com.ossez.wechat.common.model.req;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import com.ossez.wechat.common.model.entity.menu.MenuButton;
|
|
||||||
import com.ossez.wechat.common.model.res.DataCubeArticle;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CustomMessage
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*/
|
|
||||||
public class MenuRequest implements Serializable {
|
|
||||||
private static final long serialVersionUID = -9196732086954365246L;
|
|
||||||
@JsonProperty(value = "button", required = true)
|
|
||||||
private List<MenuButton> buttonList;
|
|
||||||
|
|
||||||
|
|
||||||
public List<MenuButton> getButtonList() {
|
|
||||||
return buttonList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setButtonList(List<MenuButton> buttonList) {
|
|
||||||
this.buttonList = buttonList;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,130 +0,0 @@
|
|||||||
package com.ossez.wechat.common.model.res;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UserSummaryResponse Object
|
|
||||||
*
|
|
||||||
* @author YuCheng Hu
|
|
||||||
*/
|
|
||||||
public class DataCubeArticle {
|
|
||||||
@JsonProperty("list")
|
|
||||||
private List<ArticleData> articleDataList;
|
|
||||||
|
|
||||||
public static class ArticleData {
|
|
||||||
@JsonProperty("ref_date")
|
|
||||||
private String refDate;
|
|
||||||
|
|
||||||
@JsonProperty("msgid")
|
|
||||||
private String msgId;
|
|
||||||
@JsonProperty("title")
|
|
||||||
private String title;
|
|
||||||
@JsonProperty("int_page_read_user")
|
|
||||||
private Long intPageReadUser;
|
|
||||||
@JsonProperty("ori_page_read_user")
|
|
||||||
private Long oriPageReadUser;
|
|
||||||
@JsonProperty("ori_page_read_count")
|
|
||||||
private Long oriPageReadCount;
|
|
||||||
@JsonProperty("share_user")
|
|
||||||
private Long shareUser;
|
|
||||||
|
|
||||||
@JsonProperty("shareCount")
|
|
||||||
private Long shareCount;
|
|
||||||
|
|
||||||
@JsonProperty("add_to_fav_user")
|
|
||||||
private Long addToFavUser;
|
|
||||||
|
|
||||||
@JsonProperty("add_to_fav_count")
|
|
||||||
private Long addToFavCount;
|
|
||||||
|
|
||||||
public String getRefDate() {
|
|
||||||
return refDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefDate(String refDate) {
|
|
||||||
this.refDate = refDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMsgId() {
|
|
||||||
return msgId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMsgId(String msgId) {
|
|
||||||
this.msgId = msgId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getIntPageReadUser() {
|
|
||||||
return intPageReadUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIntPageReadUser(Long intPageReadUser) {
|
|
||||||
this.intPageReadUser = intPageReadUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getOriPageReadUser() {
|
|
||||||
return oriPageReadUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOriPageReadUser(Long oriPageReadUser) {
|
|
||||||
this.oriPageReadUser = oriPageReadUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getOriPageReadCount() {
|
|
||||||
return oriPageReadCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOriPageReadCount(Long oriPageReadCount) {
|
|
||||||
this.oriPageReadCount = oriPageReadCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getShareUser() {
|
|
||||||
return shareUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShareUser(Long shareUser) {
|
|
||||||
this.shareUser = shareUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getShareCount() {
|
|
||||||
return shareCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShareCount(Long shareCount) {
|
|
||||||
this.shareCount = shareCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getAddToFavUser() {
|
|
||||||
return addToFavUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAddToFavUser(Long addToFavUser) {
|
|
||||||
this.addToFavUser = addToFavUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getAddToFavCount() {
|
|
||||||
return addToFavCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAddToFavCount(Long addToFavCount) {
|
|
||||||
this.addToFavCount = addToFavCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ArticleData> getArticleDataList() {
|
|
||||||
return articleDataList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArticleDataList(List<ArticleData> articleDataList) {
|
|
||||||
this.articleDataList = articleDataList;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
package com.ossez.wechat.common.model.res;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UserSummaryResponse Object
|
|
||||||
*
|
|
||||||
* @author YuCheng Hu
|
|
||||||
*/
|
|
||||||
public class DataCubeUser {
|
|
||||||
@JsonProperty("list")
|
|
||||||
private List<UserData> userDataList;
|
|
||||||
|
|
||||||
public static class UserData {
|
|
||||||
@JsonProperty("ref_date")
|
|
||||||
private String refDate;
|
|
||||||
@JsonProperty("user_source")
|
|
||||||
private Long userSource;
|
|
||||||
|
|
||||||
@JsonProperty("new_user")
|
|
||||||
private Long newUser;
|
|
||||||
@JsonProperty("cancel_user")
|
|
||||||
private Long cancelUser;
|
|
||||||
|
|
||||||
@JsonProperty("cumulate_user")
|
|
||||||
private Long cumulateUser;
|
|
||||||
|
|
||||||
public String getRefDate() {
|
|
||||||
return refDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefDate(String refDate) {
|
|
||||||
this.refDate = refDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getUserSource() {
|
|
||||||
return userSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserSource(Long userSource) {
|
|
||||||
this.userSource = userSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getNewUser() {
|
|
||||||
return newUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNewUser(Long newUser) {
|
|
||||||
this.newUser = newUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getCancelUser() {
|
|
||||||
return cancelUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCancelUser(Long cancelUser) {
|
|
||||||
this.cancelUser = cancelUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getCumulateUser() {
|
|
||||||
return cumulateUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCumulateUser(Long cumulateUser) {
|
|
||||||
this.cumulateUser = cumulateUser;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<UserData> getUserDataList() {
|
|
||||||
return userDataList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserDataList(List<UserData> userDataList) {
|
|
||||||
this.userDataList = userDataList;
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,7 +5,7 @@ import com.google.gson.GsonBuilder;
|
|||||||
import com.ossez.wechat.common.exception.WxError;
|
import com.ossez.wechat.common.exception.WxError;
|
||||||
import com.ossez.wechat.common.model.WeChatAccessToken;
|
import com.ossez.wechat.common.model.WeChatAccessToken;
|
||||||
import com.ossez.wechat.common.bean.WxNetCheckResult;
|
import com.ossez.wechat.common.bean.WxNetCheckResult;
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenu;
|
import com.ossez.wechat.common.bean.menu.WxMenu;
|
||||||
import com.ossez.wechat.common.bean.result.WxMediaUploadResult;
|
import com.ossez.wechat.common.bean.result.WxMediaUploadResult;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -9,10 +9,9 @@
|
|||||||
package com.ossez.wechat.common.util.json;
|
package com.ossez.wechat.common.util.json;
|
||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import com.ossez.wechat.common.model.entity.builder.MenuButtonBuilder;
|
import com.ossez.wechat.common.bean.menu.WxMenu;
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenu;
|
import com.ossez.wechat.common.bean.menu.WxMenuButton;
|
||||||
import com.ossez.wechat.common.model.entity.menu.MenuButton;
|
import com.ossez.wechat.common.bean.menu.WxMenuRule;
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenuRule;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
@ -20,16 +19,16 @@ import java.lang.reflect.Type;
|
|||||||
/**
|
/**
|
||||||
* @author Daniel Qian
|
* @author Daniel Qian
|
||||||
*/
|
*/
|
||||||
public class WxMenuGsonAdapter {
|
public class WxMenuGsonAdapter implements JsonSerializer<WxMenu>, JsonDeserializer<WxMenu> {
|
||||||
|
|
||||||
// @Override
|
@Override
|
||||||
public JsonElement serialize(WxMenu menu, Type typeOfSrc, JsonSerializationContext context) {
|
public JsonElement serialize(WxMenu menu, Type typeOfSrc, JsonSerializationContext context) {
|
||||||
JsonObject json = new JsonObject();
|
JsonObject json = new JsonObject();
|
||||||
|
|
||||||
JsonArray buttonArray = new JsonArray();
|
JsonArray buttonArray = new JsonArray();
|
||||||
for (MenuButton button : menu.getButtons()) {
|
for (WxMenuButton button : menu.getButtons()) {
|
||||||
// JsonObject buttonJson = convertToJson(button);
|
JsonObject buttonJson = convertToJson(button);
|
||||||
// buttonArray.add(buttonJson);
|
buttonArray.add(buttonJson);
|
||||||
}
|
}
|
||||||
json.add("button", buttonArray);
|
json.add("button", buttonArray);
|
||||||
|
|
||||||
@ -40,25 +39,25 @@ public class WxMenuGsonAdapter {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected JsonObject convertToJson(MenuButton button) {
|
protected JsonObject convertToJson(WxMenuButton button) {
|
||||||
// JsonObject buttonJson = new JsonObject();
|
JsonObject buttonJson = new JsonObject();
|
||||||
// buttonJson.addProperty("type", button.getType());
|
buttonJson.addProperty("type", button.getType());
|
||||||
// buttonJson.addProperty("name", button.getName());
|
buttonJson.addProperty("name", button.getName());
|
||||||
// buttonJson.addProperty("key", button.getKey());
|
buttonJson.addProperty("key", button.getKey());
|
||||||
// buttonJson.addProperty("url", button.getUrl());
|
buttonJson.addProperty("url", button.getUrl());
|
||||||
// buttonJson.addProperty("media_id", button.getMediaId());
|
buttonJson.addProperty("media_id", button.getMediaId());
|
||||||
// buttonJson.addProperty("article_id", button.getArticleId());
|
buttonJson.addProperty("article_id", button.getArticleId());
|
||||||
// buttonJson.addProperty("appid", button.getAppId());
|
buttonJson.addProperty("appid", button.getAppId());
|
||||||
// buttonJson.addProperty("pagepath", button.getPagePath());
|
buttonJson.addProperty("pagepath", button.getPagePath());
|
||||||
// if (button.getSubButtons() != null && button.getSubButtons().size() > 0) {
|
if (button.getSubButtons() != null && button.getSubButtons().size() > 0) {
|
||||||
// JsonArray buttonArray = new JsonArray();
|
JsonArray buttonArray = new JsonArray();
|
||||||
// for (MenuButton sub_button : button.getSubButtons()) {
|
for (WxMenuButton sub_button : button.getSubButtons()) {
|
||||||
// buttonArray.add(convertToJson(sub_button));
|
buttonArray.add(convertToJson(sub_button));
|
||||||
// }
|
}
|
||||||
// buttonJson.add("sub_button", buttonArray);
|
buttonJson.add("sub_button", buttonArray);
|
||||||
// }
|
}
|
||||||
// return buttonJson;
|
return buttonJson;
|
||||||
// }
|
}
|
||||||
|
|
||||||
protected JsonObject convertToJson(WxMenuRule menuRule) {
|
protected JsonObject convertToJson(WxMenuRule menuRule) {
|
||||||
JsonObject matchRule = new JsonObject();
|
JsonObject matchRule = new JsonObject();
|
||||||
@ -87,47 +86,47 @@ public class WxMenuGsonAdapter {
|
|||||||
return menuRule;
|
return menuRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
@Override
|
||||||
// public WxMenu deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public WxMenu deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
// /*
|
/*
|
||||||
// * 操蛋的微信
|
* 操蛋的微信
|
||||||
// * 创建菜单时是 { button : ... }
|
* 创建菜单时是 { button : ... }
|
||||||
// * 查询菜单时是 { menu : { button : ... } }
|
* 查询菜单时是 { menu : { button : ... } }
|
||||||
// * 现在企业号升级为企业微信后,没有此问题,因此需要单独处理
|
* 现在企业号升级为企业微信后,没有此问题,因此需要单独处理
|
||||||
// */
|
*/
|
||||||
// JsonArray buttonsJson = json.getAsJsonObject().get("menu").getAsJsonObject().get("button").getAsJsonArray();
|
JsonArray buttonsJson = json.getAsJsonObject().get("menu").getAsJsonObject().get("button").getAsJsonArray();
|
||||||
// return this.buildMenuFromJson(buttonsJson);
|
return this.buildMenuFromJson(buttonsJson);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// protected WxMenu buildMenuFromJson(JsonArray buttonsJson) {
|
protected WxMenu buildMenuFromJson(JsonArray buttonsJson) {
|
||||||
// WxMenu menu = new WxMenu();
|
WxMenu menu = new WxMenu();
|
||||||
// for (int i = 0; i < buttonsJson.size(); i++) {
|
for (int i = 0; i < buttonsJson.size(); i++) {
|
||||||
// JsonObject buttonJson = buttonsJson.get(i).getAsJsonObject();
|
JsonObject buttonJson = buttonsJson.get(i).getAsJsonObject();
|
||||||
// MenuButton button = convertFromJson(buttonJson);
|
WxMenuButton button = convertFromJson(buttonJson);
|
||||||
// menu.getButtons().add(button);
|
menu.getButtons().add(button);
|
||||||
// if (buttonJson.get("sub_button") == null || buttonJson.get("sub_button").isJsonNull()) {
|
if (buttonJson.get("sub_button") == null || buttonJson.get("sub_button").isJsonNull()) {
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
// JsonArray sub_buttonsJson = buttonJson.get("sub_button").getAsJsonArray();
|
JsonArray sub_buttonsJson = buttonJson.get("sub_button").getAsJsonArray();
|
||||||
// for (int j = 0; j < sub_buttonsJson.size(); j++) {
|
for (int j = 0; j < sub_buttonsJson.size(); j++) {
|
||||||
// JsonObject sub_buttonJson = sub_buttonsJson.get(j).getAsJsonObject();
|
JsonObject sub_buttonJson = sub_buttonsJson.get(j).getAsJsonObject();
|
||||||
// button.getSubButtons().add(convertFromJson(sub_buttonJson));
|
button.getSubButtons().add(convertFromJson(sub_buttonJson));
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// return menu;
|
return menu;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// protected MenuButton convertFromJson(JsonObject json) {
|
protected WxMenuButton convertFromJson(JsonObject json) {
|
||||||
// MenuButton button = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button = new WxMenuButton();
|
||||||
// button.setName(GsonHelper.getString(json, "name"));
|
button.setName(GsonHelper.getString(json, "name"));
|
||||||
// button.setKey(GsonHelper.getString(json, "key"));
|
button.setKey(GsonHelper.getString(json, "key"));
|
||||||
// button.setUrl(GsonHelper.getString(json, "url"));
|
button.setUrl(GsonHelper.getString(json, "url"));
|
||||||
// button.setType(GsonHelper.getString(json, "type"));
|
button.setType(GsonHelper.getString(json, "type"));
|
||||||
// button.setMediaId(GsonHelper.getString(json, "media_id"));
|
button.setMediaId(GsonHelper.getString(json, "media_id"));
|
||||||
// button.setArticleId(GsonHelper.getString(json, "article_id"));
|
button.setArticleId(GsonHelper.getString(json, "article_id"));
|
||||||
// button.setAppId(GsonHelper.getString(json, "appid"));
|
button.setAppId(GsonHelper.getString(json, "appid"));
|
||||||
// button.setPagePath(GsonHelper.getString(json, "pagepath"));
|
button.setPagePath(GsonHelper.getString(json, "pagepath"));
|
||||||
// return button;
|
return button;
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
package com.ossez.wechat.common.api;
|
package com.ossez.wechat.common.api;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.testng.annotations.Test;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.testng.Assert.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jiangby
|
* @author jiangby
|
||||||
@ -16,8 +13,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
|||||||
* @description: 作用
|
* @description: 作用
|
||||||
* created on 2022/5/26 1:46
|
* created on 2022/5/26 1:46
|
||||||
*/
|
*/
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@Test
|
||||||
@Slf4j
|
|
||||||
public class WxMessageInMemoryDuplicateCheckerSingletonTest {
|
public class WxMessageInMemoryDuplicateCheckerSingletonTest {
|
||||||
|
|
||||||
private static WxMessageInMemoryDuplicateCheckerSingleton checkerSingleton = WxMessageInMemoryDuplicateCheckerSingleton.getInstance();
|
private static WxMessageInMemoryDuplicateCheckerSingleton checkerSingleton = WxMessageInMemoryDuplicateCheckerSingleton.getInstance();
|
||||||
@ -28,14 +24,14 @@ public class WxMessageInMemoryDuplicateCheckerSingletonTest {
|
|||||||
// 第一次检查
|
// 第一次检查
|
||||||
for (Long msgId : msgIds) {
|
for (Long msgId : msgIds) {
|
||||||
boolean result = checkerSingleton.isDuplicate(String.valueOf(msgId));
|
boolean result = checkerSingleton.isDuplicate(String.valueOf(msgId));
|
||||||
assertThat(result).isFalse();
|
assertFalse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化后1S进行检查 每五秒检查一次,过期时间为15秒,过15秒再检查
|
// 初始化后1S进行检查 每五秒检查一次,过期时间为15秒,过15秒再检查
|
||||||
TimeUnit.SECONDS.sleep(15);
|
TimeUnit.SECONDS.sleep(15);
|
||||||
for (Long msgId : msgIds) {
|
for (Long msgId : msgIds) {
|
||||||
boolean result = checkerSingleton.isDuplicate(String.valueOf(msgId));
|
boolean result = checkerSingleton.isDuplicate(String.valueOf(msgId));
|
||||||
assertThat(result).isTrue();
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 过6秒再检查
|
// 过6秒再检查
|
||||||
|
@ -1,41 +1,39 @@
|
|||||||
package com.ossez.wechat.common.api;
|
package com.ossez.wechat.common.api;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.testng.annotations.Test;
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestInstance;
|
|
||||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.testng.Assert.assertFalse;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
@TestInstance(Lifecycle.PER_CLASS)
|
@Test
|
||||||
@Slf4j
|
|
||||||
public class WxMessageInMemoryDuplicateCheckerTest {
|
public class WxMessageInMemoryDuplicateCheckerTest {
|
||||||
private WxMessageInMemoryDuplicateChecker checker = new WxMessageInMemoryDuplicateChecker(2000L, 1000L);
|
private WxMessageInMemoryDuplicateChecker checker = new WxMessageInMemoryDuplicateChecker(2000L, 1000L);
|
||||||
|
|
||||||
@Test
|
public void test() throws InterruptedException {
|
||||||
public void test() throws InterruptedException {
|
Long[] msgIds = new Long[]{1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L};
|
||||||
Long[] msgIds = new Long[]{1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L};
|
|
||||||
|
|
||||||
// 第一次检查
|
// 第一次检查
|
||||||
for (Long msgId : msgIds) {
|
for (Long msgId : msgIds) {
|
||||||
boolean result = checker.isDuplicate(String.valueOf(msgId));
|
boolean result = checker.isDuplicate(String.valueOf(msgId));
|
||||||
assertThat(result).isFalse();
|
assertFalse(result);
|
||||||
}
|
|
||||||
|
|
||||||
// 过1秒再检查
|
|
||||||
TimeUnit.SECONDS.sleep(1);
|
|
||||||
for (Long msgId : msgIds) {
|
|
||||||
boolean result = checker.isDuplicate(String.valueOf(msgId));
|
|
||||||
assertThat(result).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 过1.5秒再检查
|
|
||||||
TimeUnit.MILLISECONDS.sleep(1500L);
|
|
||||||
for (Long msgId : msgIds) {
|
|
||||||
boolean result = checker.isDuplicate(String.valueOf(msgId));
|
|
||||||
assertThat(result).isFalse();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 过1秒再检查
|
||||||
|
TimeUnit.SECONDS.sleep(1);
|
||||||
|
for (Long msgId : msgIds) {
|
||||||
|
boolean result = checker.isDuplicate(String.valueOf(msgId));
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 过1.5秒再检查
|
||||||
|
TimeUnit.MILLISECONDS.sleep(1500L);
|
||||||
|
for (Long msgId : msgIds) {
|
||||||
|
boolean result = checker.isDuplicate(String.valueOf(msgId));
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,35 @@
|
|||||||
package com.ossez.wechat.common.exception;
|
package com.ossez.wechat.common.exception;
|
||||||
|
|
||||||
import com.ossez.wechat.common.enums.WxType;
|
import com.ossez.wechat.common.enums.WxType;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.testng.annotations.Test;
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestInstance;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNull;
|
||||||
|
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@Test
|
||||||
@Slf4j
|
|
||||||
public class WxErrorTest {
|
public class WxErrorTest {
|
||||||
@Test
|
|
||||||
public void testFromJson() {
|
public void testFromJson() {
|
||||||
String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\" }";
|
String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\" }";
|
||||||
WxError wxError = WxError.fromJson(json, WxType.MP);
|
WxError wxError = WxError.fromJson(json, WxType.MP);
|
||||||
assertThat(40003).isEqualTo(wxError.getErrorCode());
|
assertEquals(40003, wxError.getErrorCode());
|
||||||
// assertEquals(wxError.getErrorMsgEn(), "invalid openid");
|
assertEquals(wxError.getErrorMsgEn(), "invalid openid");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
public void testFromBadJson1() {
|
||||||
// public void testFromBadJson1() {
|
String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\", \"media_id\": \"12323423dsfafsf232f\" }";
|
||||||
// String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\", \"media_id\": \"12323423dsfafsf232f\" }";
|
WxError wxError = WxError.fromJson(json, WxType.MP);
|
||||||
// WxError wxError = WxError.fromJson(json, WxType.MP);
|
assertEquals(40003, wxError.getErrorCode());
|
||||||
// assertEquals(40003, wxError.getErrorCode());
|
assertEquals(wxError.getErrorMsgEn(), "invalid openid");
|
||||||
// assertEquals(wxError.getErrorMsgEn(), "invalid openid");
|
|
||||||
//
|
}
|
||||||
// }
|
|
||||||
//
|
public void testFromBadJson2() {
|
||||||
// @Test
|
String json = "{\"access_token\":\"ACCESS_TOKEN\",\"expires_in\":7200}";
|
||||||
// public void testFromBadJson2() {
|
WxError wxError = WxError.fromJson(json, WxType.MP);
|
||||||
// String json = "{\"access_token\":\"ACCESS_TOKEN\",\"expires_in\":7200}";
|
assertEquals(0, wxError.getErrorCode());
|
||||||
// WxError wxError = WxError.fromJson(json, WxType.MP);
|
assertNull(wxError.getErrorMsg());
|
||||||
// assertEquals(0, wxError.getErrorCode());
|
|
||||||
// assertNull(wxError.getErrorMsg());
|
}
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package com.ossez.wechat.common.model;
|
package com.ossez.wechat.common.model;
|
||||||
|
|
||||||
import com.ossez.wechat.common.model.entity.builder.MenuButtonBuilder;
|
import com.ossez.wechat.common.bean.menu.WxMenu;
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenu;
|
import com.ossez.wechat.common.bean.menu.WxMenuButton;
|
||||||
import com.ossez.wechat.common.model.entity.menu.MenuButton;
|
import com.ossez.wechat.common.bean.menu.WxMenuRule;
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenuRule;
|
|
||||||
import org.testng.*;
|
import org.testng.*;
|
||||||
import org.testng.annotations.*;
|
import org.testng.annotations.*;
|
||||||
|
|
||||||
@ -19,41 +18,41 @@ public class WxMenuTest {
|
|||||||
@Test(dataProvider = "wxPushMenu")
|
@Test(dataProvider = "wxPushMenu")
|
||||||
public void testToJson(String json) {
|
public void testToJson(String json) {
|
||||||
WxMenu menu = new WxMenu();
|
WxMenu menu = new WxMenu();
|
||||||
MenuButton button1 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button1 = new WxMenuButton();
|
||||||
button1.setType("click");
|
button1.setType("click");
|
||||||
button1.setName("今日歌曲");
|
button1.setName("今日歌曲");
|
||||||
button1.setKey("V1001_TODAY_MUSIC");
|
button1.setKey("V1001_TODAY_MUSIC");
|
||||||
|
|
||||||
MenuButton button2 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button2 = new WxMenuButton();
|
||||||
button2.setType("click");
|
button2.setType("click");
|
||||||
button2.setName("歌手简介");
|
button2.setName("歌手简介");
|
||||||
button2.setKey("V1001_TODAY_SINGER");
|
button2.setKey("V1001_TODAY_SINGER");
|
||||||
|
|
||||||
MenuButton button3 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button3 = new WxMenuButton();
|
||||||
button3.setName("菜单");
|
button3.setName("菜单");
|
||||||
|
|
||||||
menu.getButtons().add(button1);
|
menu.getButtons().add(button1);
|
||||||
menu.getButtons().add(button2);
|
menu.getButtons().add(button2);
|
||||||
menu.getButtons().add(button3);
|
menu.getButtons().add(button3);
|
||||||
|
|
||||||
MenuButton button31 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button31 = new WxMenuButton();
|
||||||
button31.setType("view");
|
button31.setType("view");
|
||||||
button31.setName("搜索");
|
button31.setName("搜索");
|
||||||
button31.setUrl("http://www.soso.com/");
|
button31.setUrl("http://www.soso.com/");
|
||||||
|
|
||||||
MenuButton button32 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button32 = new WxMenuButton();
|
||||||
button32.setType("view");
|
button32.setType("view");
|
||||||
button32.setName("视频");
|
button32.setName("视频");
|
||||||
button32.setUrl("http://v.qq.com/");
|
button32.setUrl("http://v.qq.com/");
|
||||||
|
|
||||||
MenuButton button33 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button33 = new WxMenuButton();
|
||||||
button33.setType("click");
|
button33.setType("click");
|
||||||
button33.setName("赞一下我们");
|
button33.setName("赞一下我们");
|
||||||
button33.setKey("V1001_GOOD");
|
button33.setKey("V1001_GOOD");
|
||||||
|
|
||||||
// button3.getSubButtons().add(button31);
|
button3.getSubButtons().add(button31);
|
||||||
// button3.getSubButtons().add(button32);
|
button3.getSubButtons().add(button32);
|
||||||
// button3.getSubButtons().add(button33);
|
button3.getSubButtons().add(button33);
|
||||||
|
|
||||||
Assert.assertEquals(menu.toJson(), json);
|
Assert.assertEquals(menu.toJson(), json);
|
||||||
}
|
}
|
||||||
@ -61,7 +60,7 @@ public class WxMenuTest {
|
|||||||
@Test(dataProvider = "wxAddConditionalMenu")
|
@Test(dataProvider = "wxAddConditionalMenu")
|
||||||
public void testAddConditionalToJson(String json) {
|
public void testAddConditionalToJson(String json) {
|
||||||
WxMenu menu = new WxMenu();
|
WxMenu menu = new WxMenu();
|
||||||
MenuButton button1 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button1 = new WxMenuButton();
|
||||||
button1.setType("click");
|
button1.setType("click");
|
||||||
button1.setName("今日歌曲");
|
button1.setName("今日歌曲");
|
||||||
button1.setKey("V1001_TODAY_MUSIC");
|
button1.setKey("V1001_TODAY_MUSIC");
|
||||||
|
262
mp/pom.xml
262
mp/pom.xml
@ -1,141 +1,151 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<project
|
<project
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0">
|
xmlns="http://maven.apache.org/POM/4.0.0">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.ossez.wechat</groupId>
|
||||||
|
<artifactId>wechat-j-mp</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
<groupId>com.ossez.wechat</groupId>
|
<groupId>com.ossez.wechat</groupId>
|
||||||
<artifactId>wechat-j-mp</artifactId>
|
<artifactId>wechat-j</artifactId>
|
||||||
<packaging>jar</packaging>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<parent>
|
<name>WeChat Java Mini Program</name>
|
||||||
<groupId>com.ossez.wechat</groupId>
|
<description>The module is WeChat Mini Program</description>
|
||||||
<artifactId>wechat-j</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<name>WeChat Java Mini Program</name>
|
|
||||||
<description>The module is WeChat Mini Program</description>
|
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ossez.wechat</groupId>
|
<groupId>com.ossez.wechat</groupId>
|
||||||
<artifactId>wechat-j-common</artifactId>
|
<artifactId>wechat-j-common</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jodd</groupId>
|
<groupId>org.jodd</groupId>
|
||||||
<artifactId>jodd-http</artifactId>
|
<artifactId>jodd-http</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.inject</groupId>
|
<groupId>org.testng</groupId>
|
||||||
<artifactId>guice</artifactId>
|
<artifactId>testng</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>jetty-server</artifactId>
|
<artifactId>mockito-all</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>com.google.inject</groupId>
|
||||||
<artifactId>jetty-servlet</artifactId>
|
<artifactId>guice</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>joda-time</artifactId>
|
<artifactId>jetty-server</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>redis.clients</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jedis</artifactId>
|
<artifactId>jetty-servlet</artifactId>
|
||||||
</dependency>
|
<scope>test</scope>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>ch.qos.logback</groupId>
|
<dependency>
|
||||||
<artifactId>logback-classic</artifactId>
|
<groupId>joda-time</groupId>
|
||||||
<scope>test</scope>
|
<artifactId>joda-time</artifactId>
|
||||||
</dependency>
|
<scope>test</scope>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.assertj</groupId>
|
<dependency>
|
||||||
<artifactId>assertj-guava</artifactId>
|
<groupId>redis.clients</groupId>
|
||||||
<scope>test</scope>
|
<artifactId>jedis</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
</dependency>
|
<scope>test</scope>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.redisson</groupId>
|
<dependency>
|
||||||
<artifactId>redisson</artifactId>
|
<groupId>org.assertj</groupId>
|
||||||
</dependency>
|
<artifactId>assertj-guava</artifactId>
|
||||||
<dependency>
|
<scope>test</scope>
|
||||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
</dependency>
|
||||||
<artifactId>jackson-dataformat-xml</artifactId>
|
<dependency>
|
||||||
<optional>true</optional>
|
<groupId>org.projectlombok</groupId>
|
||||||
</dependency>
|
<artifactId>lombok</artifactId>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.bouncycastle</groupId>
|
<dependency>
|
||||||
<artifactId>bcprov-jdk15on</artifactId>
|
<groupId>org.redisson</groupId>
|
||||||
<version>1.70</version>
|
<artifactId>redisson</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>jackson-dataformat-xml</artifactId>
|
||||||
<version>4.11.0</version>
|
<optional>true</optional>
|
||||||
<scope>test</scope>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
|
<version>1.70</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-core</artifactId>
|
||||||
|
<version>4.11.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<suiteXmlFiles>
|
||||||
|
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
|
||||||
|
</suiteXmlFiles>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>native-image</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>false</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
|
||||||
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<version>3.5.1</version>
|
||||||
<suiteXmlFiles>
|
<configuration>
|
||||||
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
|
<annotationProcessors>
|
||||||
</suiteXmlFiles>
|
com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||||
</configuration>
|
</annotationProcessors>
|
||||||
</plugin>
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>com.github.binarywang</groupId>
|
||||||
|
<artifactId>weixin-graal</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
</profile>
|
||||||
<profiles>
|
</profiles>
|
||||||
<profile>
|
|
||||||
<id>native-image</id>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>false</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.5.1</version>
|
|
||||||
<configuration>
|
|
||||||
<annotationProcessors>
|
|
||||||
com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
|
||||||
</annotationProcessors>
|
|
||||||
<annotationProcessorPaths>
|
|
||||||
<path>
|
|
||||||
<groupId>com.github.binarywang</groupId>
|
|
||||||
<artifactId>weixin-graal</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</path>
|
|
||||||
</annotationProcessorPaths>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
15
oa/pom.xml
15
oa/pom.xml
@ -31,6 +31,21 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.testng</groupId>
|
||||||
|
<artifactId>testng</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-all</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.inject</groupId>
|
||||||
|
<artifactId>guice</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-server</artifactId>
|
<artifactId>jetty-server</artifactId>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ossez.wechat.oa.api;
|
package com.ossez.wechat.oa.api;
|
||||||
|
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenu;
|
import com.ossez.wechat.common.bean.menu.WxMenu;
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
import com.ossez.wechat.oa.bean.menu.WxMpGetSelfMenuInfoResult;
|
import com.ossez.wechat.oa.bean.menu.WxMpGetSelfMenuInfoResult;
|
||||||
import com.ossez.wechat.oa.bean.menu.WxMpMenu;
|
import com.ossez.wechat.oa.bean.menu.WxMpMenu;
|
||||||
|
@ -5,7 +5,7 @@ import com.ossez.wechat.oa.bean.menu.WxMpGetSelfMenuInfoResult;
|
|||||||
import com.ossez.wechat.oa.bean.menu.WxMpMenu;
|
import com.ossez.wechat.oa.bean.menu.WxMpMenu;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenu;
|
import com.ossez.wechat.common.bean.menu.WxMenu;
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
import com.ossez.wechat.common.util.json.GsonParser;
|
import com.ossez.wechat.common.util.json.GsonParser;
|
||||||
import com.ossez.wechat.oa.api.WxMpMenuService;
|
import com.ossez.wechat.oa.api.WxMpMenuService;
|
||||||
|
@ -1,149 +0,0 @@
|
|||||||
package com.ossez.wechat.oa.api.impl.okhttp;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
|
||||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
|
||||||
import com.ossez.wechat.common.exception.DataStructureException;
|
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
|
||||||
import com.ossez.wechat.common.model.req.DataCubeRequest;
|
|
||||||
import com.ossez.wechat.common.model.res.DataCubeArticle;
|
|
||||||
import com.ossez.wechat.common.model.res.DataCubeUser;
|
|
||||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.interceptor.AuthenticationInterceptor;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.interceptor.WeChatErrorInterceptor;
|
|
||||||
import okhttp3.ConnectionPool;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import retrofit2.HttpException;
|
|
||||||
import retrofit2.Retrofit;
|
|
||||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
|
||||||
import retrofit2.converter.jackson.JacksonConverterFactory;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WeChat Official Account Platform DataCube
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*/
|
|
||||||
public class WeChatDataCubeService {
|
|
||||||
private final Logger log = LoggerFactory.getLogger(WeChatDataCubeService.class);
|
|
||||||
|
|
||||||
private WeChatOfficialAccountApi weChatOfficialAccountApi;
|
|
||||||
|
|
||||||
public WeChatDataCubeService(WeChatOfficialAccountService weChatOfficialAccountService) {
|
|
||||||
String accessToken = null;
|
|
||||||
try {
|
|
||||||
accessToken = weChatOfficialAccountService.getAccessToken();
|
|
||||||
} catch (WxErrorException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
mapper.setSerializationInclusion(Include.NON_NULL);
|
|
||||||
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
|
|
||||||
|
|
||||||
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new AuthenticationInterceptor(accessToken)).addInterceptor(new WeChatErrorInterceptor()).connectionPool(new ConnectionPool(5, 1, TimeUnit.SECONDS)).readTimeout(1000, TimeUnit.SECONDS).build();
|
|
||||||
|
|
||||||
Retrofit retrofit = new Retrofit.Builder().baseUrl(WeChatConstant.ENDPOINT_WECHAT).client(client).addConverterFactory(JacksonConverterFactory.create(mapper)).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build();
|
|
||||||
|
|
||||||
this.weChatOfficialAccountApi = retrofit.create(WeChatOfficialAccountApi.class);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get user summary
|
|
||||||
*
|
|
||||||
* @param beginDate
|
|
||||||
* @param endDate
|
|
||||||
* @return
|
|
||||||
* @throws WxErrorException
|
|
||||||
*/
|
|
||||||
public DataCubeUser getUserSummary(LocalDateTime beginDate, LocalDateTime endDate) throws WxErrorException {
|
|
||||||
if (!(ObjectUtils.isNotEmpty(beginDate) && ObjectUtils.isNotEmpty(endDate) && endDate.isAfter(beginDate))) {
|
|
||||||
log.warn("The begin date [{}] Or end date [{}] was null or ender date greater than begin date.", beginDate, endDate);
|
|
||||||
throw new DataStructureException("Query data range error ");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
DataCubeRequest dataCubeRequest = new DataCubeRequest();
|
|
||||||
dataCubeRequest.setBeginDate(beginDate.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
|
||||||
dataCubeRequest.setEndDate(endDate.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
|
||||||
|
|
||||||
return weChatOfficialAccountApi.getUserSummary(dataCubeRequest).blockingGet();
|
|
||||||
} catch (HttpException ex) {
|
|
||||||
log.warn("Call WeChat API with error: " + ex);
|
|
||||||
if (ex.code() == 400) {
|
|
||||||
throw new WxErrorException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataCubeUser getUserCumulate(LocalDateTime beginDate, LocalDateTime endDate) throws WxErrorException {
|
|
||||||
if (!(ObjectUtils.isNotEmpty(beginDate) && ObjectUtils.isNotEmpty(endDate) && endDate.isAfter(beginDate))) {
|
|
||||||
log.warn("The begin date [{}] Or end date [{}] was null or ender date greater than begin date.", beginDate, endDate);
|
|
||||||
throw new DataStructureException("Query data range error ");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
DataCubeRequest dataCubeRequest = new DataCubeRequest();
|
|
||||||
dataCubeRequest.setBeginDate(beginDate.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
|
||||||
dataCubeRequest.setEndDate(endDate.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
|
||||||
|
|
||||||
return weChatOfficialAccountApi.getUserCumulate(dataCubeRequest).blockingGet();
|
|
||||||
} catch (HttpException ex) {
|
|
||||||
log.warn("Call WeChat API with error: " + ex);
|
|
||||||
if (ex.code() == 400) {
|
|
||||||
throw new WxErrorException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param beginDate
|
|
||||||
* @param endDate
|
|
||||||
* @return
|
|
||||||
* @throws WxErrorException
|
|
||||||
*/
|
|
||||||
public DataCubeArticle getArticleSummary(LocalDateTime beginDate, LocalDateTime endDate) throws WxErrorException {
|
|
||||||
try {
|
|
||||||
return weChatOfficialAccountApi.getarticlesummary(getDataCubeRequest(beginDate, endDate)).blockingGet();
|
|
||||||
} catch (HttpException ex) {
|
|
||||||
log.warn("Call WeChat API with error: " + ex);
|
|
||||||
if (ex.code() == 400) {
|
|
||||||
throw new WxErrorException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DataCubeRequest getDataCubeRequest(LocalDateTime beginDate, LocalDateTime endDate) throws DataStructureException {
|
|
||||||
if (!(ObjectUtils.isNotEmpty(beginDate) && ObjectUtils.isNotEmpty(endDate) && endDate.isAfter(beginDate))) {
|
|
||||||
log.warn("The begin date [{}] Or end date [{}] was null or ender date greater than begin date.", beginDate, endDate);
|
|
||||||
throw new DataStructureException("Query data range error ");
|
|
||||||
}
|
|
||||||
|
|
||||||
DataCubeRequest dataCubeRequest = new DataCubeRequest();
|
|
||||||
dataCubeRequest.setBeginDate(beginDate.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
|
||||||
dataCubeRequest.setEndDate(endDate.format(DateTimeFormatter.ISO_LOCAL_DATE));
|
|
||||||
|
|
||||||
return dataCubeRequest;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
package com.ossez.wechat.oa.api.impl.okhttp;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
|
||||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
|
||||||
import com.ossez.wechat.common.exception.DataStructureException;
|
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
|
||||||
import com.ossez.wechat.common.model.WeChatStatus;
|
|
||||||
import com.ossez.wechat.common.model.req.DataCubeRequest;
|
|
||||||
import com.ossez.wechat.common.model.req.MenuRequest;
|
|
||||||
import com.ossez.wechat.common.model.res.DataCubeArticle;
|
|
||||||
import com.ossez.wechat.common.model.res.DataCubeUser;
|
|
||||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.interceptor.AuthenticationInterceptor;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.interceptor.WeChatErrorInterceptor;
|
|
||||||
import okhttp3.ConnectionPool;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import retrofit2.HttpException;
|
|
||||||
import retrofit2.Retrofit;
|
|
||||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
|
||||||
import retrofit2.converter.jackson.JacksonConverterFactory;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* WeChat Official Account Platform DataCube
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*/
|
|
||||||
public class WeChatMenuService {
|
|
||||||
private final Logger log = LoggerFactory.getLogger(WeChatMenuService.class);
|
|
||||||
|
|
||||||
private WeChatOfficialAccountApi weChatOfficialAccountApi;
|
|
||||||
|
|
||||||
public WeChatMenuService(WeChatOfficialAccountService weChatOfficialAccountService) {
|
|
||||||
String accessToken = null;
|
|
||||||
try {
|
|
||||||
accessToken = weChatOfficialAccountService.getAccessToken();
|
|
||||||
} catch (WxErrorException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
||||||
mapper.setSerializationInclusion(Include.NON_NULL);
|
|
||||||
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
|
|
||||||
|
|
||||||
OkHttpClient client = new OkHttpClient.Builder()
|
|
||||||
.addInterceptor(new AuthenticationInterceptor(accessToken))
|
|
||||||
.addInterceptor(new WeChatErrorInterceptor())
|
|
||||||
.connectionPool(new ConnectionPool(5, 1, TimeUnit.SECONDS)).readTimeout(1000, TimeUnit.SECONDS)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Retrofit retrofit = new Retrofit.Builder().baseUrl(WeChatConstant.ENDPOINT_WECHAT).client(client)
|
|
||||||
.addConverterFactory(JacksonConverterFactory.create(mapper))
|
|
||||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
this.weChatOfficialAccountApi = retrofit.create(WeChatOfficialAccountApi.class);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param menuRequest
|
|
||||||
* @return
|
|
||||||
* @throws WxErrorException
|
|
||||||
*/
|
|
||||||
public WeChatStatus create(MenuRequest menuRequest) throws WxErrorException {
|
|
||||||
try {
|
|
||||||
|
|
||||||
return weChatOfficialAccountApi.createMenu(menuRequest).blockingGet();
|
|
||||||
} catch (HttpException ex) {
|
|
||||||
log.warn("Call WeChat API with error: " + ex);
|
|
||||||
if (ex.code() == 400) {
|
|
||||||
throw new WxErrorException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
package com.ossez.wechat.oa.api.impl.okhttp;
|
package com.ossez.wechat.oa.api.impl.okhttp;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||||
@ -30,7 +29,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class WeChatMsgService {
|
public class WeChatMsgService {
|
||||||
private final Logger log = LoggerFactory.getLogger(WeChatMsgService.class);
|
private final Logger log = LoggerFactory.getLogger(WeChatMsgService.class);
|
||||||
|
|
||||||
private WeChatOfficialAccountApi weChatOfficialAccountApi;
|
WeChatOfficialAccountApi weChatOfficialAccountApi;
|
||||||
|
|
||||||
public WeChatMsgService(WeChatOfficialAccountService weChatOfficialAccountService) {
|
public WeChatMsgService(WeChatOfficialAccountService weChatOfficialAccountService) {
|
||||||
String accessToken = null;
|
String accessToken = null;
|
||||||
@ -42,7 +41,7 @@ public class WeChatMsgService {
|
|||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
mapper.setSerializationInclusion(Include.NON_NULL);
|
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
|
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
|
||||||
|
|
||||||
OkHttpClient client = new OkHttpClient.Builder()
|
OkHttpClient client = new OkHttpClient.Builder()
|
||||||
@ -56,8 +55,10 @@ public class WeChatMsgService {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
this.weChatOfficialAccountApi = retrofit.create(WeChatOfficialAccountApi.class);
|
this.weChatOfficialAccountApi = retrofit.create(WeChatOfficialAccountApi.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String sendMessage(CustomMessage customMessage) throws WxErrorException {
|
public String sendMessage(CustomMessage customMessage) throws WxErrorException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -2,12 +2,11 @@ package com.ossez.wechat.oa.api.impl.okhttp;
|
|||||||
|
|
||||||
import com.ossez.wechat.common.model.WeChatAccessToken;
|
import com.ossez.wechat.common.model.WeChatAccessToken;
|
||||||
import com.ossez.wechat.common.model.WeChatApiDomainIp;
|
import com.ossez.wechat.common.model.WeChatApiDomainIp;
|
||||||
import com.ossez.wechat.common.model.WeChatStatus;
|
import com.ossez.wechat.common.model.req.CustomMessage;
|
||||||
import com.ossez.wechat.common.model.req.*;
|
import com.ossez.wechat.common.model.req.NetworkCheck;
|
||||||
import com.ossez.wechat.common.model.res.DataCubeArticle;
|
import com.ossez.wechat.common.model.req.QueryQuota;
|
||||||
import com.ossez.wechat.common.model.res.NetworkCheckResponse;
|
import com.ossez.wechat.common.model.res.NetworkCheckResponse;
|
||||||
import com.ossez.wechat.common.model.res.QueryQuotaResponse;
|
import com.ossez.wechat.common.model.res.QueryQuotaResponse;
|
||||||
import com.ossez.wechat.common.model.res.DataCubeUser;
|
|
||||||
import io.reactivex.Single;
|
import io.reactivex.Single;
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
||||||
@ -32,37 +31,5 @@ public interface WeChatOfficialAccountApi {
|
|||||||
Single<QueryQuotaResponse> queryQuota(@Body QueryQuota request);
|
Single<QueryQuotaResponse> queryQuota(@Body QueryQuota request);
|
||||||
|
|
||||||
@POST("/cgi-bin/message/custom/send")
|
@POST("/cgi-bin/message/custom/send")
|
||||||
Single<WeChatStatus> sendMessage(@Body CustomMessage customMessage);
|
Single<WeChatAccessToken> sendMessage(@Body CustomMessage customMessage);
|
||||||
|
}
|
||||||
// MENU
|
|
||||||
@POST("/cgi-bin/menu/create")
|
|
||||||
Single<WeChatStatus> createMenu(@Body MenuRequest menuRequest);
|
|
||||||
|
|
||||||
@GET("/cgi-bin/get_current_selfmenu_info")
|
|
||||||
Single<WeChatStatus> getMenu();
|
|
||||||
|
|
||||||
// DATA ANALYST
|
|
||||||
@POST("/datacube/getusersummary")
|
|
||||||
Single<DataCubeUser> getUserSummary(@Body DataCubeRequest dataCubeRequest);
|
|
||||||
|
|
||||||
@POST("/datacube/getusercumulate")
|
|
||||||
Single<DataCubeUser> getUserCumulate(@Body DataCubeRequest dataCubeRequest);
|
|
||||||
|
|
||||||
@POST("/datacube/getarticlesummary")
|
|
||||||
Single<DataCubeArticle> getarticlesummary(@Body DataCubeRequest dataCubeRequest);
|
|
||||||
|
|
||||||
@POST("/datacube/getarticletotal")
|
|
||||||
Single<DataCubeUser> getarticletotal(@Body DataCubeRequest dataCubeRequest);
|
|
||||||
|
|
||||||
@POST("/datacube/getuserread")
|
|
||||||
Single<DataCubeUser> getuserread(@Body DataCubeRequest dataCubeRequest);
|
|
||||||
|
|
||||||
@POST("/datacube/getuserreadhour")
|
|
||||||
Single<DataCubeUser> getuserreadhour(@Body DataCubeRequest dataCubeRequest);
|
|
||||||
|
|
||||||
@POST("/datacube/getusershare")
|
|
||||||
Single<DataCubeUser> getusershare(@Body DataCubeRequest dataCubeRequest);
|
|
||||||
|
|
||||||
@POST("/datacube/getusersharehour")
|
|
||||||
Single<DataCubeUser> getusersharehour(@Body DataCubeRequest dataCubeRequest);
|
|
||||||
}
|
|
||||||
|
@ -11,11 +11,10 @@ import java.io.Serializable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kefu message Object
|
* 客服消息.
|
||||||
*
|
*
|
||||||
* @author YuCheng
|
* @author chanjarster
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class WxMpKefuMessage implements Serializable {
|
public class WxMpKefuMessage implements Serializable {
|
||||||
@ -125,18 +124,18 @@ public class WxMpKefuMessage implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 请使用
|
* 请使用
|
||||||
* {@link WeChatConstant.MsgType#TEXT}
|
* {@link WeChatConstant.KefuMsgType#TEXT}
|
||||||
* {@link WeChatConstant.MsgType#IMAGE}
|
* {@link WeChatConstant.KefuMsgType#IMAGE}
|
||||||
* {@link WeChatConstant.MsgType#VOICE}
|
* {@link WeChatConstant.KefuMsgType#VOICE}
|
||||||
* {@link WeChatConstant.MsgType#MUSIC}
|
* {@link WeChatConstant.KefuMsgType#MUSIC}
|
||||||
* {@link WeChatConstant.MsgType#VIDEO}
|
* {@link WeChatConstant.KefuMsgType#VIDEO}
|
||||||
* {@link WeChatConstant.MsgType#NEWS}
|
* {@link WeChatConstant.KefuMsgType#NEWS}
|
||||||
* {@link WeChatConstant.MsgType#MPNEWS}
|
* {@link WeChatConstant.KefuMsgType#MPNEWS}
|
||||||
* {@link WeChatConstant.MsgType#WXCARD}
|
* {@link WeChatConstant.KefuMsgType#WXCARD}
|
||||||
* {@link WeChatConstant.MsgType#MINIPROGRAMPAGE}
|
* {@link WeChatConstant.KefuMsgType#MINIPROGRAMPAGE}
|
||||||
* {@link WeChatConstant.MsgType#TASKCARD}
|
* {@link WeChatConstant.KefuMsgType#TASKCARD}
|
||||||
* {@link WeChatConstant.MsgType#MSGMENU}
|
* {@link WeChatConstant.KefuMsgType#MSGMENU}
|
||||||
* {@link WeChatConstant.MsgType#MP_NEWS_ARTICLE}
|
* {@link WeChatConstant.KefuMsgType#MP_NEWS_ARTICLE}
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public void setMsgType(String msgType) {
|
public void setMsgType(String msgType) {
|
||||||
|
@ -8,8 +8,9 @@ import lombok.Data;
|
|||||||
import com.ossez.wechat.oa.util.json.WxMpGsonBuilder;
|
import com.ossez.wechat.oa.util.json.WxMpGsonBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author YuCheng
|
* @author Binary Wang
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
public class WxMpKfOnlineList implements Serializable {
|
public class WxMpKfOnlineList implements Serializable {
|
||||||
private static final long serialVersionUID = -6154705288500854617L;
|
private static final long serialVersionUID = -6154705288500854617L;
|
||||||
|
|
||||||
@ -25,11 +26,4 @@ public class WxMpKfOnlineList implements Serializable {
|
|||||||
return WxMpGsonBuilder.create().toJson(this);
|
return WxMpGsonBuilder.create().toJson(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<WxMpKfInfo> getKfOnlineList() {
|
|
||||||
return kfOnlineList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKfOnlineList(List<WxMpKfInfo> kfOnlineList) {
|
|
||||||
this.kfOnlineList = kfOnlineList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import com.ossez.wechat.common.model.entity.menu.MenuButton;
|
import com.ossez.wechat.common.bean.menu.WxMenuButton;
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenuRule;
|
import com.ossez.wechat.common.bean.menu.WxMenuRule;
|
||||||
import com.ossez.wechat.common.util.json.WxGsonBuilder;
|
import com.ossez.wechat.common.util.json.WxGsonBuilder;
|
||||||
import com.ossez.wechat.oa.util.json.WxMpGsonBuilder;
|
import com.ossez.wechat.oa.util.json.WxMpGsonBuilder;
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public class WxMpMenu implements Serializable {
|
|||||||
private static final long serialVersionUID = -2279946921755382289L;
|
private static final long serialVersionUID = -2279946921755382289L;
|
||||||
|
|
||||||
@SerializedName("button")
|
@SerializedName("button")
|
||||||
private List<MenuButton> buttons;
|
private List<WxMenuButton> buttons;
|
||||||
@SerializedName("matchrule")
|
@SerializedName("matchrule")
|
||||||
private WxMenuRule rule;
|
private WxMenuRule rule;
|
||||||
@SerializedName("menuid")
|
@SerializedName("menuid")
|
||||||
|
@ -24,7 +24,7 @@ public class WxMpXmlOutTransferKefuMessage extends WxMpXmlOutMessage {
|
|||||||
protected TransInfo transInfo;
|
protected TransInfo transInfo;
|
||||||
|
|
||||||
public WxMpXmlOutTransferKefuMessage() {
|
public WxMpXmlOutTransferKefuMessage() {
|
||||||
this.msgType = WeChatConstant.MsgType.TRANSFER_CUSTOMER_SERVICE;
|
this.msgType = WeChatConstant.KefuMsgType.TRANSFER_CUSTOMER_SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@ -15,7 +15,7 @@ public final class ImageBuilder extends BaseBuilder<ImageBuilder> {
|
|||||||
private String mediaId;
|
private String mediaId;
|
||||||
|
|
||||||
public ImageBuilder() {
|
public ImageBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.IMAGE;
|
this.msgType = WeChatConstant.KefuMsgType.IMAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageBuilder mediaId(String media_id) {
|
public ImageBuilder mediaId(String media_id) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ossez.wechat.oa.builder.kefu;
|
package com.ossez.wechat.oa.builder.kefu;
|
||||||
|
|
||||||
import com.ossez.wechat.common.constant.WeChatConstant.MsgType;
|
import com.ossez.wechat.common.constant.WeChatConstant.KefuMsgType;
|
||||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +20,7 @@ public final class MiniProgramPageBuilder extends BaseBuilder<MiniProgramPageBui
|
|||||||
private String thumbMediaId;
|
private String thumbMediaId;
|
||||||
|
|
||||||
public MiniProgramPageBuilder() {
|
public MiniProgramPageBuilder() {
|
||||||
this.msgType = MsgType.MINIPROGRAMPAGE;
|
this.msgType = KefuMsgType.MINIPROGRAMPAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ public final class MpNewsArticleBuilder extends BaseBuilder<MpNewsArticleBuilder
|
|||||||
private String articleId;
|
private String articleId;
|
||||||
|
|
||||||
public MpNewsArticleBuilder() {
|
public MpNewsArticleBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.MP_NEWS_ARTICLE;
|
this.msgType = WeChatConstant.KefuMsgType.MP_NEWS_ARTICLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MpNewsArticleBuilder articleId(String articleId) {
|
public MpNewsArticleBuilder articleId(String articleId) {
|
||||||
|
@ -16,7 +16,7 @@ public final class MpNewsBuilder extends BaseBuilder<MpNewsBuilder> {
|
|||||||
private String mediaId;
|
private String mediaId;
|
||||||
|
|
||||||
public MpNewsBuilder() {
|
public MpNewsBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.MPNEWS;
|
this.msgType = WeChatConstant.KefuMsgType.MPNEWS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MpNewsBuilder mediaId(String mediaId) {
|
public MpNewsBuilder mediaId(String mediaId) {
|
||||||
|
@ -24,7 +24,7 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder> {
|
|||||||
private String hqMusicUrl;
|
private String hqMusicUrl;
|
||||||
|
|
||||||
public MusicBuilder() {
|
public MusicBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.MUSIC;
|
this.msgType = WeChatConstant.KefuMsgType.MUSIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MusicBuilder musicUrl(String musicurl) {
|
public MusicBuilder musicUrl(String musicurl) {
|
||||||
|
@ -20,7 +20,7 @@ public final class NewsBuilder extends BaseBuilder<NewsBuilder> {
|
|||||||
private List<WxMpKefuMessage.WxArticle> articles = new ArrayList<>();
|
private List<WxMpKefuMessage.WxArticle> articles = new ArrayList<>();
|
||||||
|
|
||||||
public NewsBuilder() {
|
public NewsBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.NEWS;
|
this.msgType = WeChatConstant.KefuMsgType.NEWS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NewsBuilder addArticle(WxMpKefuMessage.WxArticle... articles) {
|
public NewsBuilder addArticle(WxMpKefuMessage.WxArticle... articles) {
|
||||||
|
@ -15,7 +15,7 @@ public final class TextBuilder extends BaseBuilder<TextBuilder> {
|
|||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
public TextBuilder() {
|
public TextBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.TEXT;
|
this.msgType = WeChatConstant.KefuMsgType.TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextBuilder content(String content) {
|
public TextBuilder content(String content) {
|
||||||
|
@ -24,7 +24,7 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder> {
|
|||||||
private String thumbMediaId;
|
private String thumbMediaId;
|
||||||
|
|
||||||
public VideoBuilder() {
|
public VideoBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.VIDEO;
|
this.msgType = WeChatConstant.KefuMsgType.VIDEO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VideoBuilder mediaId(String mediaId) {
|
public VideoBuilder mediaId(String mediaId) {
|
||||||
|
@ -15,7 +15,7 @@ public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> {
|
|||||||
private String mediaId;
|
private String mediaId;
|
||||||
|
|
||||||
public VoiceBuilder() {
|
public VoiceBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.VOICE;
|
this.msgType = WeChatConstant.KefuMsgType.VOICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VoiceBuilder mediaId(String media_id) {
|
public VoiceBuilder mediaId(String media_id) {
|
||||||
|
@ -15,7 +15,7 @@ public final class WxCardBuilder extends BaseBuilder<WxCardBuilder> {
|
|||||||
private String cardId;
|
private String cardId;
|
||||||
|
|
||||||
public WxCardBuilder() {
|
public WxCardBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.WXCARD;
|
this.msgType = WeChatConstant.KefuMsgType.WXCARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WxCardBuilder cardId(String cardId) {
|
public WxCardBuilder cardId(String cardId) {
|
||||||
|
@ -23,7 +23,7 @@ public final class WxMsgMenuBuilder extends BaseBuilder<WxMsgMenuBuilder> {
|
|||||||
|
|
||||||
|
|
||||||
public WxMsgMenuBuilder() {
|
public WxMsgMenuBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.MSGMENU;
|
this.msgType = WeChatConstant.KefuMsgType.MSGMENU;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WxMsgMenuBuilder addMenus(WxMpKefuMessage.MsgMenu... msgMenus) {
|
public WxMsgMenuBuilder addMenus(WxMpKefuMessage.MsgMenu... msgMenus) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.ossez.wechat.oa.util.json;
|
package com.ossez.wechat.oa.util.json;
|
||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import com.ossez.wechat.common.constant.WeChatConstant.MsgType;
|
import com.ossez.wechat.common.constant.WeChatConstant.KefuMsgType;
|
||||||
import com.ossez.wechat.common.exception.WxRuntimeException;
|
import com.ossez.wechat.common.exception.WxRuntimeException;
|
||||||
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -17,22 +17,22 @@ public class WxMpKefuMessageGsonAdapter implements JsonSerializer<WxMpKefuMessag
|
|||||||
messageJson.addProperty("msgtype", message.getMsgType());
|
messageJson.addProperty("msgtype", message.getMsgType());
|
||||||
|
|
||||||
switch (message.getMsgType()) {
|
switch (message.getMsgType()) {
|
||||||
case MsgType.TEXT:
|
case KefuMsgType.TEXT:
|
||||||
JsonObject text = new JsonObject();
|
JsonObject text = new JsonObject();
|
||||||
text.addProperty("content", message.getContent());
|
text.addProperty("content", message.getContent());
|
||||||
messageJson.add("text", text);
|
messageJson.add("text", text);
|
||||||
break;
|
break;
|
||||||
case MsgType.IMAGE:
|
case KefuMsgType.IMAGE:
|
||||||
JsonObject image = new JsonObject();
|
JsonObject image = new JsonObject();
|
||||||
image.addProperty("media_id", message.getMediaId());
|
image.addProperty("media_id", message.getMediaId());
|
||||||
messageJson.add("image", image);
|
messageJson.add("image", image);
|
||||||
break;
|
break;
|
||||||
case MsgType.VOICE:
|
case KefuMsgType.VOICE:
|
||||||
JsonObject voice = new JsonObject();
|
JsonObject voice = new JsonObject();
|
||||||
voice.addProperty("media_id", message.getMediaId());
|
voice.addProperty("media_id", message.getMediaId());
|
||||||
messageJson.add("voice", voice);
|
messageJson.add("voice", voice);
|
||||||
break;
|
break;
|
||||||
case MsgType.VIDEO:
|
case KefuMsgType.VIDEO:
|
||||||
JsonObject video = new JsonObject();
|
JsonObject video = new JsonObject();
|
||||||
video.addProperty("media_id", message.getMediaId());
|
video.addProperty("media_id", message.getMediaId());
|
||||||
video.addProperty("thumb_media_id", message.getThumbMediaId());
|
video.addProperty("thumb_media_id", message.getThumbMediaId());
|
||||||
@ -40,7 +40,7 @@ public class WxMpKefuMessageGsonAdapter implements JsonSerializer<WxMpKefuMessag
|
|||||||
video.addProperty("description", message.getDescription());
|
video.addProperty("description", message.getDescription());
|
||||||
messageJson.add("video", video);
|
messageJson.add("video", video);
|
||||||
break;
|
break;
|
||||||
case MsgType.MUSIC:
|
case KefuMsgType.MUSIC:
|
||||||
JsonObject music = new JsonObject();
|
JsonObject music = new JsonObject();
|
||||||
music.addProperty("title", message.getTitle());
|
music.addProperty("title", message.getTitle());
|
||||||
music.addProperty("description", message.getDescription());
|
music.addProperty("description", message.getDescription());
|
||||||
@ -49,7 +49,7 @@ public class WxMpKefuMessageGsonAdapter implements JsonSerializer<WxMpKefuMessag
|
|||||||
music.addProperty("hqmusicurl", message.getHqMusicUrl());
|
music.addProperty("hqmusicurl", message.getHqMusicUrl());
|
||||||
messageJson.add("music", music);
|
messageJson.add("music", music);
|
||||||
break;
|
break;
|
||||||
case MsgType.NEWS:
|
case KefuMsgType.NEWS:
|
||||||
JsonObject newsJsonObject = new JsonObject();
|
JsonObject newsJsonObject = new JsonObject();
|
||||||
JsonArray articleJsonArray = new JsonArray();
|
JsonArray articleJsonArray = new JsonArray();
|
||||||
for (WxMpKefuMessage.WxArticle article : message.getArticles()) {
|
for (WxMpKefuMessage.WxArticle article : message.getArticles()) {
|
||||||
@ -63,17 +63,17 @@ public class WxMpKefuMessageGsonAdapter implements JsonSerializer<WxMpKefuMessag
|
|||||||
newsJsonObject.add("articles", articleJsonArray);
|
newsJsonObject.add("articles", articleJsonArray);
|
||||||
messageJson.add("news", newsJsonObject);
|
messageJson.add("news", newsJsonObject);
|
||||||
break;
|
break;
|
||||||
case MsgType.MPNEWS:
|
case KefuMsgType.MPNEWS:
|
||||||
JsonObject json = new JsonObject();
|
JsonObject json = new JsonObject();
|
||||||
json.addProperty("media_id", message.getMpNewsMediaId());
|
json.addProperty("media_id", message.getMpNewsMediaId());
|
||||||
messageJson.add("mpnews", json);
|
messageJson.add("mpnews", json);
|
||||||
break;
|
break;
|
||||||
case MsgType.WXCARD:
|
case KefuMsgType.WXCARD:
|
||||||
JsonObject wxcard = new JsonObject();
|
JsonObject wxcard = new JsonObject();
|
||||||
wxcard.addProperty("card_id", message.getCardId());
|
wxcard.addProperty("card_id", message.getCardId());
|
||||||
messageJson.add("wxcard", wxcard);
|
messageJson.add("wxcard", wxcard);
|
||||||
break;
|
break;
|
||||||
case MsgType.MINIPROGRAMPAGE:
|
case KefuMsgType.MINIPROGRAMPAGE:
|
||||||
JsonObject miniProgramPage = new JsonObject();
|
JsonObject miniProgramPage = new JsonObject();
|
||||||
miniProgramPage.addProperty("title", message.getTitle());
|
miniProgramPage.addProperty("title", message.getTitle());
|
||||||
miniProgramPage.addProperty("appid", message.getMiniProgramAppId());
|
miniProgramPage.addProperty("appid", message.getMiniProgramAppId());
|
||||||
@ -81,7 +81,7 @@ public class WxMpKefuMessageGsonAdapter implements JsonSerializer<WxMpKefuMessag
|
|||||||
miniProgramPage.addProperty("thumb_media_id", message.getThumbMediaId());
|
miniProgramPage.addProperty("thumb_media_id", message.getThumbMediaId());
|
||||||
messageJson.add("miniprogrampage", miniProgramPage);
|
messageJson.add("miniprogrampage", miniProgramPage);
|
||||||
break;
|
break;
|
||||||
case MsgType.MSGMENU: {
|
case KefuMsgType.MSGMENU: {
|
||||||
JsonObject msgmenuJsonObject = new JsonObject();
|
JsonObject msgmenuJsonObject = new JsonObject();
|
||||||
JsonArray listJsonArray = new JsonArray();
|
JsonArray listJsonArray = new JsonArray();
|
||||||
for (WxMpKefuMessage.MsgMenu list : message.getMsgMenus()) {
|
for (WxMpKefuMessage.MsgMenu list : message.getMsgMenus()) {
|
||||||
@ -96,7 +96,7 @@ public class WxMpKefuMessageGsonAdapter implements JsonSerializer<WxMpKefuMessag
|
|||||||
messageJson.add("msgmenu", msgmenuJsonObject);
|
messageJson.add("msgmenu", msgmenuJsonObject);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MsgType.MP_NEWS_ARTICLE:
|
case KefuMsgType.MP_NEWS_ARTICLE:
|
||||||
JsonObject mpNewsArticleJson = new JsonObject();
|
JsonObject mpNewsArticleJson = new JsonObject();
|
||||||
mpNewsArticleJson.addProperty("article_id", message.getMpNewsArticleId());
|
mpNewsArticleJson.addProperty("article_id", message.getMpNewsArticleId());
|
||||||
messageJson.add("mpnewsarticle", mpNewsArticleJson);
|
messageJson.add("mpnewsarticle", mpNewsArticleJson);
|
||||||
|
@ -1,196 +0,0 @@
|
|||||||
package com.ossez.wechat.oa.api.impl;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.ossez.wechat.common.exception.DataStructureException;
|
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
|
||||||
import com.ossez.wechat.common.model.res.DataCubeArticle;
|
|
||||||
import com.ossez.wechat.common.model.res.DataCubeUser;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatDataCubeService;
|
|
||||||
import com.ossez.wechat.oa.api.test.TestBase;
|
|
||||||
import com.ossez.wechat.oa.api.test.TestConfigStorage;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestInstance;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for datacube API
|
|
||||||
* @author YuCheng
|
|
||||||
*/
|
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
|
||||||
public class DataCubeServiceTest extends TestBase {
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(TestBase.class);
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
protected TestConfigStorage testConfigStorage;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
protected WeChatDataCubeService weChatDataCubeService;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetUserSummarye() throws WxErrorException, DataStructureException {
|
|
||||||
DataCubeUser dataCubeUser = weChatDataCubeService.getUserSummary(LocalDateTime.now().minusDays(4), LocalDateTime.now().minusDays(1));
|
|
||||||
|
|
||||||
assertThat(dataCubeUser).isNotNull();
|
|
||||||
assertThat(dataCubeUser.getUserDataList().size()).isEqualTo(4);
|
|
||||||
assertThat(dataCubeUser.getUserDataList().get(0).getCancelUser()).isGreaterThanOrEqualTo(0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetUserCumulate() throws WxErrorException {
|
|
||||||
DataCubeUser dataCubeUser = weChatDataCubeService.getUserCumulate(LocalDateTime.now().minusDays(4), LocalDateTime.now().minusDays(1));
|
|
||||||
|
|
||||||
assertThat(dataCubeUser).isNotNull();
|
|
||||||
assertThat(dataCubeUser.getUserDataList().size()).isEqualTo(4);
|
|
||||||
assertThat(dataCubeUser.getUserDataList().get(0).getCumulateUser()).isGreaterThanOrEqualTo(0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetarticlesummary() throws WxErrorException {
|
|
||||||
DataCubeArticle dataCubeArticle = weChatDataCubeService.getArticleSummary(LocalDateTime.now().minusDays(12), LocalDateTime.now().minusDays(12));
|
|
||||||
|
|
||||||
assertThat(dataCubeArticle).isNotNull();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// @Test(dataProvider = "oneDay")
|
|
||||||
// public void testGetArticleSummary(Date date) throws WxErrorException {
|
|
||||||
// List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getArticleSummary(date, date);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * TODO 该接口,暂时没找到有数据的日期,无法测试验证
|
|
||||||
// */
|
|
||||||
// @Test(dataProvider = "oneDay")
|
|
||||||
// public void testGetArticleTotal(Date date) throws WxErrorException {
|
|
||||||
// List<WxDataCubeArticleTotal> results = this.wxService.getDataCubeService()
|
|
||||||
// .getArticleTotal(date, date);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test(dataProvider = "threeDays")
|
|
||||||
// public void testGetUserRead(Date beginDate, Date endDate)
|
|
||||||
// throws WxErrorException {
|
|
||||||
// List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getUserRead(beginDate, endDate);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test(dataProvider = "oneDay")
|
|
||||||
// public void testGetUserReadHour(Date date) throws WxErrorException {
|
|
||||||
// List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getUserReadHour(date, date);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test(dataProvider = "sevenDays")
|
|
||||||
// public void testGetUserShare(Date beginDate, Date endDate)
|
|
||||||
// throws WxErrorException {
|
|
||||||
// List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getUserShare(beginDate, endDate);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test(dataProvider = "oneDay")
|
|
||||||
// public void testGetUserShareHour(Date date) throws WxErrorException {
|
|
||||||
// List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getUserShareHour(date, date);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test(dataProvider = "sevenDays")
|
|
||||||
// public void testGetUpstreamMsg(Date beginDate, Date endDate) throws WxErrorException {
|
|
||||||
// List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getUpstreamMsg(beginDate, endDate);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test(dataProvider = "oneDay")
|
|
||||||
// public void testGetUpstreamMsgHour(Date date) throws WxErrorException {
|
|
||||||
// List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getUpstreamMsgHour(date, date);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test(dataProvider = "thirtyDays")
|
|
||||||
// public void testGetUpstreamMsgWeek(Date beginDate, Date endDate) throws WxErrorException {
|
|
||||||
// List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getUpstreamMsgWeek(beginDate, endDate);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * TODO 该接口,暂时没找到有数据的日期,无法测试验证
|
|
||||||
// */
|
|
||||||
// @Test(dataProvider = "thirtyDays")
|
|
||||||
// public void testGetUpstreamMsgMonth(Date beginDate, Date endDate) throws WxErrorException {
|
|
||||||
// List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getUpstreamMsgMonth(beginDate, endDate);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test(dataProvider = "fifteenDays")
|
|
||||||
// public void testGetUpstreamMsgDist(Date beginDate, Date endDate) throws WxErrorException {
|
|
||||||
// List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getUpstreamMsgDist(beginDate, endDate);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test(dataProvider = "thirtyDays")
|
|
||||||
// public void testGetUpstreamMsgDistWeek(Date beginDate, Date endDate) throws WxErrorException {
|
|
||||||
// List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getUpstreamMsgDistWeek(beginDate, endDate);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * TODO 该接口,暂时没找到有数据的日期,无法测试验证
|
|
||||||
// */
|
|
||||||
// @Test(dataProvider = "thirtyDays")
|
|
||||||
// public void testGetUpstreamMsgDistMonth(Date beginDate, Date endDate) throws WxErrorException {
|
|
||||||
// List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getUpstreamMsgDistMonth(beginDate, endDate);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test(dataProvider = "thirtyDays")
|
|
||||||
// public void testGetInterfaceSummary(Date beginDate, Date endDate) throws WxErrorException {
|
|
||||||
// List<WxDataCubeInterfaceResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getInterfaceSummary(beginDate, endDate);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test(dataProvider = "oneDay")
|
|
||||||
// public void testGetInterfaceSummaryHour(Date date) throws WxErrorException {
|
|
||||||
// List<WxDataCubeInterfaceResult> results = this.wxService.getDataCubeService()
|
|
||||||
// .getInterfaceSummaryHour(date, date);
|
|
||||||
// Assert.assertNotNull(results);
|
|
||||||
// System.out.println(results);
|
|
||||||
// }
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
package com.ossez.wechat.oa.api.impl;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
|
||||||
import com.ossez.wechat.common.model.WeChatStatus;
|
|
||||||
import com.ossez.wechat.common.model.entity.builder.MenuButtonBuilder;
|
|
||||||
import com.ossez.wechat.common.model.entity.menu.MenuButton;
|
|
||||||
import com.ossez.wechat.common.model.req.MenuRequest;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatMenuService;
|
|
||||||
import com.ossez.wechat.oa.api.test.TestBase;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestInstance;
|
|
||||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for datacube API
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*/
|
|
||||||
@TestInstance(Lifecycle.PER_CLASS)
|
|
||||||
public class MenuServiceTest extends TestBase {
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(TestBase.class);
|
|
||||||
@Inject
|
|
||||||
protected WeChatMenuService weChatMenuService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test Create Menu
|
|
||||||
*
|
|
||||||
* @throws WxErrorException
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testCreate() throws WxErrorException {
|
|
||||||
log.debug("Create WeChat Offical Account Menun Test");
|
|
||||||
MenuRequest menuRequest = new MenuRequest();
|
|
||||||
|
|
||||||
List<MenuButton> buttonList = new ArrayList<>();
|
|
||||||
|
|
||||||
List<MenuButton> menuLinkButtonList = new ArrayList<>();
|
|
||||||
menuLinkButtonList.add(new MenuButtonBuilder()
|
|
||||||
.setType("view")
|
|
||||||
.setName("地产经纪")
|
|
||||||
.setUrl("https://www.verani.com/").createMenuButton());
|
|
||||||
|
|
||||||
|
|
||||||
menuLinkButtonList.add(new MenuButtonBuilder()
|
|
||||||
.setType("view")
|
|
||||||
.setName("置业科普")
|
|
||||||
.setUrl("https://www.isharkfly.com/c/realestate/8").createMenuButton());
|
|
||||||
|
|
||||||
menuLinkButtonList.add(new MenuButtonBuilder()
|
|
||||||
.setType("view")
|
|
||||||
.setName("USVisaTrack")
|
|
||||||
.setUrl("https://www.usvisatrack.com/").createMenuButton());
|
|
||||||
|
|
||||||
MenuButton buttonTop = new MenuButtonBuilder().createMenuButton();
|
|
||||||
buttonTop.setName("Shark 服务");
|
|
||||||
buttonTop.setSubButtonList(menuLinkButtonList);
|
|
||||||
buttonList.add(buttonTop);
|
|
||||||
|
|
||||||
menuRequest.setButtonList(buttonList);
|
|
||||||
|
|
||||||
WeChatStatus weChatStatus = weChatMenuService.create(menuRequest);
|
|
||||||
|
|
||||||
assertThat(weChatStatus).isNotNull();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -2,95 +2,99 @@ package com.ossez.wechat.oa.api.impl;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
|
||||||
import com.ossez.wechat.oa.api.WxMpCommentService;
|
import com.ossez.wechat.oa.api.WxMpCommentService;
|
||||||
|
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||||
import com.ossez.wechat.oa.api.test.ApiTestModule;
|
import com.ossez.wechat.oa.api.test.ApiTestModule;
|
||||||
import com.ossez.wechat.oa.bean.comment.WxMpCommentListVo;
|
import com.ossez.wechat.oa.bean.comment.WxMpCommentListVo;
|
||||||
import org.mockito.ArgumentMatchers;
|
import org.mockito.Matchers;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.testng.annotations.Guice;
|
import org.testng.annotations.Guice;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Classes move to use Junit 5
|
* 测试类.
|
||||||
|
*
|
||||||
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
|
* created on 2019-06-16
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Guice(modules = ApiTestModule.class)
|
@Guice(modules = ApiTestModule.class)
|
||||||
public class WxMpCommentServiceImplTest {
|
public class WxMpCommentServiceImplTest {
|
||||||
@Inject
|
@Inject
|
||||||
private WeChatOfficialAccountService wxService;
|
private WeChatOfficialAccountService wxService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOpen() throws WxErrorException {
|
public void testOpen() throws WxErrorException {
|
||||||
this.wxService.getCommentService().open("1", null);
|
this.wxService.getCommentService().open("1", null);
|
||||||
this.wxService.getCommentService().open("1", 0);
|
this.wxService.getCommentService().open("1", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClose() throws WxErrorException {
|
public void testClose() throws WxErrorException {
|
||||||
this.wxService.getCommentService().close("1000000001", null);
|
this.wxService.getCommentService().close("1000000001", null);
|
||||||
this.wxService.getCommentService().close("1", 0);
|
this.wxService.getCommentService().close("1", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testList() throws WxErrorException {
|
public void testList() throws WxErrorException {
|
||||||
String expectedResponse = "{\n" +
|
String expectedResponse = "{\n" +
|
||||||
" \"errcode\": 0,\n" +
|
" \"errcode\": 0,\n" +
|
||||||
" \"errmsg\": \"ok\",\n" +
|
" \"errmsg\": \"ok\",\n" +
|
||||||
" \"total\": 1,\n" +
|
" \"total\": 1,\n" +
|
||||||
" \"comment\": [\n" +
|
" \"comment\": [\n" +
|
||||||
" {\n" +
|
" {\n" +
|
||||||
" \"user_comment_id\": 1,\n" +
|
" \"user_comment_id\": 1,\n" +
|
||||||
" \"openid\": \"OPENID\",\n" +
|
" \"openid\": \"OPENID\",\n" +
|
||||||
" \"create_time\": \"CREATE_TIME\",\n" +
|
" \"create_time\": \"CREATE_TIME\",\n" +
|
||||||
" \"content\": \"CONTENT\",\n" +
|
" \"content\": \"CONTENT\",\n" +
|
||||||
" \"comment_type\": 1,\n" +
|
" \"comment_type\": 1,\n" +
|
||||||
" \"reply\": {\n" +
|
" \"reply\": {\n" +
|
||||||
" \"content\": \"CONTENT\",\n" +
|
" \"content\": \"CONTENT\",\n" +
|
||||||
" \"create_time\": \"CREATE_TIME\"\n" +
|
" \"create_time\": \"CREATE_TIME\"\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" ]\n" +
|
" ]\n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
wxService = Mockito.spy(wxService);
|
wxService = Mockito.spy(wxService);
|
||||||
WxMpCommentService commentService = new WxMpCommentServiceImpl(wxService);
|
WxMpCommentService commentService = new WxMpCommentServiceImpl(wxService);
|
||||||
Mockito.doReturn(expectedResponse).when(wxService).post(ArgumentMatchers.anyString(), ArgumentMatchers.anyString());
|
Mockito.doReturn(expectedResponse).when(wxService).post(Matchers.anyString(), Matchers.anyString());
|
||||||
|
|
||||||
final WxMpCommentListVo commentListVo = commentService.list("1", 1, 1, 1, 1);
|
final WxMpCommentListVo commentListVo = commentService.list("1", 1, 1, 1, 1);
|
||||||
assertThat(commentListVo).isNotNull();
|
assertThat(commentListVo).isNotNull();
|
||||||
System.out.println(commentListVo);
|
System.out.println(commentListVo);
|
||||||
assertThat(commentListVo.getTotal()).isEqualTo(1);
|
assertThat(commentListVo.getTotal()).isEqualTo(1);
|
||||||
assertThat(commentListVo.getComment()).isNotEmpty();
|
assertThat(commentListVo.getComment()).isNotEmpty();
|
||||||
|
|
||||||
assertThat(commentListVo.getComment().get(0).getReply()).isNotNull();
|
assertThat(commentListVo.getComment().get(0).getReply()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMarkElect() throws WxErrorException {
|
public void testMarkElect() throws WxErrorException {
|
||||||
this.wxService.getCommentService().markElect("1000000001", null, 1L);
|
this.wxService.getCommentService().markElect("1000000001", null, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnmarkElect() throws WxErrorException {
|
public void testUnmarkElect() throws WxErrorException {
|
||||||
this.wxService.getCommentService().unmarkElect("1000000001", null, 1L);
|
this.wxService.getCommentService().unmarkElect("1000000001", null, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelete() throws WxErrorException {
|
public void testDelete() throws WxErrorException {
|
||||||
this.wxService.getCommentService().delete("1000000001", null, 1L);
|
this.wxService.getCommentService().delete("1000000001", null, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReplyAdd() throws WxErrorException {
|
public void testReplyAdd() throws WxErrorException {
|
||||||
this.wxService.getCommentService().replyAdd("1000000001", null, 1L, "haha");
|
this.wxService.getCommentService().replyAdd("1000000001", null, 1L, "haha");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReplyADelete() throws WxErrorException {
|
public void testReplyADelete() throws WxErrorException {
|
||||||
this.wxService.getCommentService().replyDelete("1000000001", null, 1L);
|
this.wxService.getCommentService().replyDelete("1000000001", null, 1L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,208 @@
|
|||||||
|
package com.ossez.wechat.oa.api.impl;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
|
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||||
|
import com.ossez.wechat.oa.api.test.ApiTestModule;
|
||||||
|
import com.ossez.wechat.oa.bean.datacube.*;
|
||||||
|
import org.apache.commons.lang3.time.FastDateFormat;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.DataProvider;
|
||||||
|
import org.testng.annotations.Guice;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试统计分析相关的接口
|
||||||
|
* Created by Binary Wang on 2016/8/23.
|
||||||
|
*
|
||||||
|
* @author binarywang (https://github.com/binarywang)
|
||||||
|
*/
|
||||||
|
@Guice(modules = ApiTestModule.class)
|
||||||
|
public class WxMpDataCubeServiceImplTest {
|
||||||
|
@Inject
|
||||||
|
protected WeChatOfficialAccountService wxService;
|
||||||
|
private FastDateFormat simpleDateFormat = FastDateFormat
|
||||||
|
.getInstance("yyyy-MM-dd");
|
||||||
|
|
||||||
|
@DataProvider
|
||||||
|
public Object[][] oneDay() throws ParseException {
|
||||||
|
return new Object[][]{{this.simpleDateFormat.parse("2016-08-22")}};
|
||||||
|
}
|
||||||
|
|
||||||
|
@DataProvider
|
||||||
|
public Object[][] threeDays() throws ParseException {
|
||||||
|
return new Object[][]{{this.simpleDateFormat.parse("2016-08-20"),
|
||||||
|
this.simpleDateFormat.parse("2016-08-22")}};
|
||||||
|
}
|
||||||
|
|
||||||
|
@DataProvider
|
||||||
|
public Object[][] sevenDays() throws ParseException {
|
||||||
|
return new Object[][]{{this.simpleDateFormat.parse("2016-08-16"),
|
||||||
|
this.simpleDateFormat.parse("2016-08-22")}};
|
||||||
|
}
|
||||||
|
|
||||||
|
@DataProvider
|
||||||
|
public Object[][] fifteenDays() throws ParseException {
|
||||||
|
return new Object[][]{{this.simpleDateFormat.parse("2016-08-14"),
|
||||||
|
this.simpleDateFormat.parse("2016-08-27")}};
|
||||||
|
}
|
||||||
|
|
||||||
|
@DataProvider
|
||||||
|
public Object[][] thirtyDays() throws ParseException {
|
||||||
|
return new Object[][]{{this.simpleDateFormat.parse("2016-07-30"),
|
||||||
|
this.simpleDateFormat.parse("2016-08-27")}};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "sevenDays")
|
||||||
|
public void testGetUserSummary(Date beginDate, Date endDate)
|
||||||
|
throws WxErrorException {
|
||||||
|
List<WxDataCubeUserSummary> summaries = this.wxService.getDataCubeService()
|
||||||
|
.getUserSummary(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(summaries);
|
||||||
|
System.out.println(summaries);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "sevenDays")
|
||||||
|
public void testGetUserCumulate(Date beginDate, Date endDate)
|
||||||
|
throws WxErrorException {
|
||||||
|
List<WxDataCubeUserCumulate> result = this.wxService.getDataCubeService()
|
||||||
|
.getUserCumulate(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(result);
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "oneDay")
|
||||||
|
public void testGetArticleSummary(Date date) throws WxErrorException {
|
||||||
|
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getArticleSummary(date, date);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO 该接口,暂时没找到有数据的日期,无法测试验证
|
||||||
|
*/
|
||||||
|
@Test(dataProvider = "oneDay")
|
||||||
|
public void testGetArticleTotal(Date date) throws WxErrorException {
|
||||||
|
List<WxDataCubeArticleTotal> results = this.wxService.getDataCubeService()
|
||||||
|
.getArticleTotal(date, date);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "threeDays")
|
||||||
|
public void testGetUserRead(Date beginDate, Date endDate)
|
||||||
|
throws WxErrorException {
|
||||||
|
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUserRead(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "oneDay")
|
||||||
|
public void testGetUserReadHour(Date date) throws WxErrorException {
|
||||||
|
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUserReadHour(date, date);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "sevenDays")
|
||||||
|
public void testGetUserShare(Date beginDate, Date endDate)
|
||||||
|
throws WxErrorException {
|
||||||
|
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUserShare(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "oneDay")
|
||||||
|
public void testGetUserShareHour(Date date) throws WxErrorException {
|
||||||
|
List<WxDataCubeArticleResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUserShareHour(date, date);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "sevenDays")
|
||||||
|
public void testGetUpstreamMsg(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUpstreamMsg(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "oneDay")
|
||||||
|
public void testGetUpstreamMsgHour(Date date) throws WxErrorException {
|
||||||
|
List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUpstreamMsgHour(date, date);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "thirtyDays")
|
||||||
|
public void testGetUpstreamMsgWeek(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUpstreamMsgWeek(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO 该接口,暂时没找到有数据的日期,无法测试验证
|
||||||
|
*/
|
||||||
|
@Test(dataProvider = "thirtyDays")
|
||||||
|
public void testGetUpstreamMsgMonth(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUpstreamMsgMonth(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "fifteenDays")
|
||||||
|
public void testGetUpstreamMsgDist(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUpstreamMsgDist(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "thirtyDays")
|
||||||
|
public void testGetUpstreamMsgDistWeek(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUpstreamMsgDistWeek(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO 该接口,暂时没找到有数据的日期,无法测试验证
|
||||||
|
*/
|
||||||
|
@Test(dataProvider = "thirtyDays")
|
||||||
|
public void testGetUpstreamMsgDistMonth(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
List<WxDataCubeMsgResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getUpstreamMsgDistMonth(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "thirtyDays")
|
||||||
|
public void testGetInterfaceSummary(Date beginDate, Date endDate) throws WxErrorException {
|
||||||
|
List<WxDataCubeInterfaceResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getInterfaceSummary(beginDate, endDate);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dataProvider = "oneDay")
|
||||||
|
public void testGetInterfaceSummaryHour(Date date) throws WxErrorException {
|
||||||
|
List<WxDataCubeInterfaceResult> results = this.wxService.getDataCubeService()
|
||||||
|
.getInterfaceSummaryHour(date, date);
|
||||||
|
Assert.assertNotNull(results);
|
||||||
|
System.out.println(results);
|
||||||
|
}
|
||||||
|
}
|
@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
* created on 2021/5/13/013
|
* created on 2021/5/13/013
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//@Guice(modules = ApiTestModule.class)
|
@Guice(modules = ApiTestModule.class)
|
||||||
public class WxMpGuideBuyerServiceImplTest {
|
public class WxMpGuideBuyerServiceImplTest {
|
||||||
@Inject
|
@Inject
|
||||||
protected WeChatOfficialAccountService wxService;
|
protected WeChatOfficialAccountService wxService;
|
||||||
|
@ -18,71 +18,71 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a>
|
||||||
|
* created on 2021/5/13/013
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Guice(modules = ApiTestModule.class)
|
@Guice(modules = ApiTestModule.class)
|
||||||
public class WxMpGuideMaterialServiceImplTest {
|
public class WxMpGuideMaterialServiceImplTest {
|
||||||
@Inject
|
@Inject
|
||||||
protected WeChatOfficialAccountService wxService;
|
protected WeChatOfficialAccountService wxService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图片路径
|
* 图片路径
|
||||||
*/
|
*/
|
||||||
private static final String IMG_URL = "C:\\Users\\Administrator\\Desktop\\imgText.png";
|
private static final String IMG_URL = "C:\\Users\\Administrator\\Desktop\\imgText.png";
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetGuideCardMaterial() throws WxErrorException {
|
public void testSetGuideCardMaterial() throws WxErrorException {
|
||||||
WxMediaUploadResult wxMediaUploadResult = this.wxService.getMaterialService()
|
WxMediaUploadResult wxMediaUploadResult = this.wxService.getMaterialService()
|
||||||
.mediaUpload(WeChatConstant.MediaFileType.IMAGE, new File(IMG_URL));
|
.mediaUpload(WeChatConstant.MediaFileType.IMAGE, new File(IMG_URL));
|
||||||
this.wxService.getGuideMaterialService().setGuideCardMaterial(wxMediaUploadResult.getMediaId(), 0, "小程序素材标题", "pages/login-type/index.html", "wx4f793c04fd3be5a8");
|
this.wxService.getGuideMaterialService().setGuideCardMaterial(wxMediaUploadResult.getMediaId(), 0, "小程序素材标题", "pages/login-type/index.html", "wx4f793c04fd3be5a8");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetGuideCardMaterial() throws WxErrorException {
|
public void testGetGuideCardMaterial() throws WxErrorException {
|
||||||
List<WxMpGuideCardMaterialInfo> guideCardMaterial = this.wxService.getGuideMaterialService().getGuideCardMaterial(0);
|
List<WxMpGuideCardMaterialInfo> guideCardMaterial = this.wxService.getGuideMaterialService().getGuideCardMaterial(0);
|
||||||
Assertions.assertThat(guideCardMaterial).isNotNull();
|
Assertions.assertThat(guideCardMaterial).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelGuideCardMaterial() throws WxErrorException {
|
public void testDelGuideCardMaterial() throws WxErrorException {
|
||||||
this.wxService.getGuideMaterialService().delGuideCardMaterial(0, "小程序素材标题", "pages/login-type/index.html", "wx4f793c04fd3be5a8");
|
this.wxService.getGuideMaterialService().delGuideCardMaterial(0, "小程序素材标题", "pages/login-type/index.html", "wx4f793c04fd3be5a8");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetGuideImageMaterial() throws WxErrorException {
|
public void testSetGuideImageMaterial() throws WxErrorException {
|
||||||
WxMediaUploadResult wxMediaUploadResult = this.wxService.getMaterialService()
|
WxMediaUploadResult wxMediaUploadResult = this.wxService.getMaterialService()
|
||||||
.mediaUpload(WeChatConstant.MediaFileType.IMAGE, new File(IMG_URL));
|
.mediaUpload(WeChatConstant.MediaFileType.IMAGE, new File(IMG_URL));
|
||||||
this.wxService.getGuideMaterialService().setGuideImageMaterial(wxMediaUploadResult.getMediaId(), 0);
|
this.wxService.getGuideMaterialService().setGuideImageMaterial(wxMediaUploadResult.getMediaId(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetGuideImageMaterial() throws WxErrorException {
|
public void testGetGuideImageMaterial() throws WxErrorException {
|
||||||
WxMpGuideImgMaterialInfoList guideImageMaterial = this.wxService.getGuideMaterialService().getGuideImageMaterial(0, 0, 20);
|
WxMpGuideImgMaterialInfoList guideImageMaterial = this.wxService.getGuideMaterialService().getGuideImageMaterial(0, 0, 20);
|
||||||
assertThat(guideImageMaterial).isNotNull();
|
assertThat(guideImageMaterial).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelGuideImageMaterial() throws WxErrorException {
|
public void testDelGuideImageMaterial() throws WxErrorException {
|
||||||
this.wxService.getGuideMaterialService().delGuideImageMaterial(0, "http://mmbiz.qpic.cn/mmbiz_png/63bwCoCgX0neicbffKiaL4vqXAUChYwE1VO0ZG5b6SW3Shv7kR1ia46b3gS8zf78piaR7vk7I6MRqbVzibJVJoNtkEg/0");
|
this.wxService.getGuideMaterialService().delGuideImageMaterial(0, "http://mmbiz.qpic.cn/mmbiz_png/63bwCoCgX0neicbffKiaL4vqXAUChYwE1VO0ZG5b6SW3Shv7kR1ia46b3gS8zf78piaR7vk7I6MRqbVzibJVJoNtkEg/0");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetGuideWordMaterial() throws WxErrorException {
|
public void testSetGuideWordMaterial() throws WxErrorException {
|
||||||
this.wxService.getGuideMaterialService().setGuideWordMaterial(0, "文字素材测试");
|
this.wxService.getGuideMaterialService().setGuideWordMaterial(0, "文字素材测试");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetGuideWordMaterial() throws WxErrorException {
|
public void testGetGuideWordMaterial() throws WxErrorException {
|
||||||
WxMpGuideWordMaterialInfoList guideWordMaterial = this.wxService.getGuideMaterialService().getGuideWordMaterial(0, 0, 20);
|
WxMpGuideWordMaterialInfoList guideWordMaterial = this.wxService.getGuideMaterialService().getGuideWordMaterial(0, 0, 20);
|
||||||
assertThat(guideWordMaterial).isNotNull();
|
assertThat(guideWordMaterial).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelGuideWordMaterial() throws WxErrorException {
|
public void testDelGuideWordMaterial() throws WxErrorException {
|
||||||
this.wxService.getGuideMaterialService().delGuideWordMaterial(0, "文字素材测试");
|
this.wxService.getGuideMaterialService().delGuideWordMaterial(0, "文字素材测试");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,11 @@ package com.ossez.wechat.oa.api.impl;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||||
|
import com.ossez.wechat.oa.api.test.ApiTestModule;
|
||||||
import com.ossez.wechat.oa.bean.guide.*;
|
import com.ossez.wechat.oa.bean.guide.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.assertj.core.api.Assertions;
|
import org.assertj.core.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.testng.annotations.Guice;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -20,8 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
* created on 2020-10-06
|
* created on 2020-10-06
|
||||||
*/
|
*/
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@Guice(modules = ApiTestModule.class)
|
||||||
@Slf4j
|
|
||||||
public class WxMpGuideServiceImplTest {
|
public class WxMpGuideServiceImplTest {
|
||||||
@Inject
|
@Inject
|
||||||
protected WeChatOfficialAccountService wxService;
|
protected WeChatOfficialAccountService wxService;
|
||||||
|
@ -3,25 +3,25 @@ package com.ossez.wechat.oa.api.impl;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||||
|
import com.ossez.wechat.oa.api.test.ApiTestModule;
|
||||||
import com.ossez.wechat.oa.bean.guide.WxMpGuideBuyerResp;
|
import com.ossez.wechat.oa.bean.guide.WxMpGuideBuyerResp;
|
||||||
import com.ossez.wechat.oa.bean.guide.WxMpGuideTagInfo;
|
import com.ossez.wechat.oa.bean.guide.WxMpGuideTagInfo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.assertj.core.api.Assertions;
|
import org.assertj.core.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.testng.annotations.Guice;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a>
|
* @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a>
|
||||||
* created on 2021/5/13/013
|
* created on 2021/5/13/013
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@Guice(modules = ApiTestModule.class)
|
||||||
@Slf4j
|
|
||||||
public class WxMpGuideTagServiceImplTest {
|
public class WxMpGuideTagServiceImplTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected WeChatOfficialAccountService wxService;
|
protected WeChatOfficialAccountService wxService;
|
||||||
|
|
||||||
|
@ -1,26 +1,30 @@
|
|||||||
package com.ossez.wechat.oa.api.impl;
|
package com.ossez.wechat.oa.api.impl;
|
||||||
|
|
||||||
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
|
import com.ossez.wechat.common.util.fs.FileUtils;
|
||||||
|
import com.ossez.wechat.common.service.WxImgProcService;
|
||||||
|
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||||
|
import com.ossez.wechat.oa.api.test.ApiTestModule;
|
||||||
|
import com.ossez.wechat.oa.api.test.TestConstants;
|
||||||
import com.ossez.wechat.common.bean.imgproc.WxImgProcAiCropResult;
|
import com.ossez.wechat.common.bean.imgproc.WxImgProcAiCropResult;
|
||||||
import com.ossez.wechat.common.bean.imgproc.WxImgProcQrCodeResult;
|
import com.ossez.wechat.common.bean.imgproc.WxImgProcQrCodeResult;
|
||||||
import com.ossez.wechat.common.bean.imgproc.WxImgProcSuperResolutionResult;
|
import com.ossez.wechat.common.bean.imgproc.WxImgProcSuperResolutionResult;
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
|
||||||
import com.ossez.wechat.common.service.WxImgProcService;
|
|
||||||
import com.ossez.wechat.common.util.fs.FileUtils;
|
|
||||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
|
||||||
import com.ossez.wechat.oa.api.test.TestConstants;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.assertj.core.api.Assertions;
|
import org.assertj.core.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.mockito.Matchers;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
import org.testng.annotations.Guice;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@Slf4j
|
|
||||||
|
@Test
|
||||||
|
@Guice(modules = ApiTestModule.class)
|
||||||
public class WxMpImgProcServiceImplTest {
|
public class WxMpImgProcServiceImplTest {
|
||||||
@Inject
|
@Inject
|
||||||
private WeChatOfficialAccountService mpService;
|
private WeChatOfficialAccountService mpService;
|
||||||
@ -92,120 +96,120 @@ public class WxMpImgProcServiceImplTest {
|
|||||||
public static class mockTest {
|
public static class mockTest {
|
||||||
private WeChatOfficialAccountService wxService = Mockito.mock(WeChatOfficialAccountService.class);
|
private WeChatOfficialAccountService wxService = Mockito.mock(WeChatOfficialAccountService.class);
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
// public void testQrCode() throws Exception {
|
public void testQrCode() throws Exception {
|
||||||
// String returnJson = "{\n" +
|
String returnJson = "{\n" +
|
||||||
// " \"errcode\": 0, \n" +
|
" \"errcode\": 0, \n" +
|
||||||
// " \"errmsg\": \"ok\", \n" +
|
" \"errmsg\": \"ok\", \n" +
|
||||||
// " \"code_results\": [\n" +
|
" \"code_results\": [\n" +
|
||||||
// " {\n" +
|
" {\n" +
|
||||||
// " \"type_name\": \"QR_CODE\", \n" +
|
" \"type_name\": \"QR_CODE\", \n" +
|
||||||
// " \"data\": \"https://www.qq.com\", \n" +
|
" \"data\": \"https://www.qq.com\", \n" +
|
||||||
// " \"pos\": {\n" +
|
" \"pos\": {\n" +
|
||||||
// " \"left_top\": {\n" +
|
" \"left_top\": {\n" +
|
||||||
// " \"x\": 585, \n" +
|
" \"x\": 585, \n" +
|
||||||
// " \"y\": 378\n" +
|
" \"y\": 378\n" +
|
||||||
// " }, \n" +
|
" }, \n" +
|
||||||
// " \"right_top\": {\n" +
|
" \"right_top\": {\n" +
|
||||||
// " \"x\": 828, \n" +
|
" \"x\": 828, \n" +
|
||||||
// " \"y\": 378\n" +
|
" \"y\": 378\n" +
|
||||||
// " }, \n" +
|
" }, \n" +
|
||||||
// " \"right_bottom\": {\n" +
|
" \"right_bottom\": {\n" +
|
||||||
// " \"x\": 828, \n" +
|
" \"x\": 828, \n" +
|
||||||
// " \"y\": 618\n" +
|
" \"y\": 618\n" +
|
||||||
// " }, \n" +
|
" }, \n" +
|
||||||
// " \"left_bottom\": {\n" +
|
" \"left_bottom\": {\n" +
|
||||||
// " \"x\": 585, \n" +
|
" \"x\": 585, \n" +
|
||||||
// " \"y\": 618\n" +
|
" \"y\": 618\n" +
|
||||||
// " }\n" +
|
" }\n" +
|
||||||
// " }\n" +
|
" }\n" +
|
||||||
// " }, \n" +
|
" }, \n" +
|
||||||
// " {\n" +
|
" {\n" +
|
||||||
// " \"type_name\": \"QR_CODE\", \n" +
|
" \"type_name\": \"QR_CODE\", \n" +
|
||||||
// " \"data\": \"https://mp.weixin.qq.com\", \n" +
|
" \"data\": \"https://mp.weixin.qq.com\", \n" +
|
||||||
// " \"pos\": {\n" +
|
" \"pos\": {\n" +
|
||||||
// " \"left_top\": {\n" +
|
" \"left_top\": {\n" +
|
||||||
// " \"x\": 185, \n" +
|
" \"x\": 185, \n" +
|
||||||
// " \"y\": 142\n" +
|
" \"y\": 142\n" +
|
||||||
// " }, \n" +
|
" }, \n" +
|
||||||
// " \"right_top\": {\n" +
|
" \"right_top\": {\n" +
|
||||||
// " \"x\": 396, \n" +
|
" \"x\": 396, \n" +
|
||||||
// " \"y\": 142\n" +
|
" \"y\": 142\n" +
|
||||||
// " }, \n" +
|
" }, \n" +
|
||||||
// " \"right_bottom\": {\n" +
|
" \"right_bottom\": {\n" +
|
||||||
// " \"x\": 396, \n" +
|
" \"x\": 396, \n" +
|
||||||
// " \"y\": 353\n" +
|
" \"y\": 353\n" +
|
||||||
// " }, \n" +
|
" }, \n" +
|
||||||
// " \"left_bottom\": {\n" +
|
" \"left_bottom\": {\n" +
|
||||||
// " \"x\": 185, \n" +
|
" \"x\": 185, \n" +
|
||||||
// " \"y\": 353\n" +
|
" \"y\": 353\n" +
|
||||||
// " }\n" +
|
" }\n" +
|
||||||
// " }\n" +
|
" }\n" +
|
||||||
// " }, \n" +
|
" }, \n" +
|
||||||
// " {\n" +
|
" {\n" +
|
||||||
// " \"type_name\": \"EAN_13\", \n" +
|
" \"type_name\": \"EAN_13\", \n" +
|
||||||
// " \"data\": \"5906789678957\"\n" +
|
" \"data\": \"5906789678957\"\n" +
|
||||||
// " }, \n" +
|
" }, \n" +
|
||||||
// " {\n" +
|
" {\n" +
|
||||||
// " \"type_name\": \"CODE_128\", \n" +
|
" \"type_name\": \"CODE_128\", \n" +
|
||||||
// " \"data\": \"50090500019191\"\n" +
|
" \"data\": \"50090500019191\"\n" +
|
||||||
// " }\n" +
|
" }\n" +
|
||||||
// " ], \n" +
|
" ], \n" +
|
||||||
// " \"img_size\": {\n" +
|
" \"img_size\": {\n" +
|
||||||
// " \"w\": 1000, \n" +
|
" \"w\": 1000, \n" +
|
||||||
// " \"h\": 900\n" +
|
" \"h\": 900\n" +
|
||||||
// " }\n" +
|
" }\n" +
|
||||||
// "}";
|
"}";
|
||||||
// Mockito.when(wxService.get(Matchers.anyString(), Matchers.anyString())).thenReturn(returnJson);
|
Mockito.when(wxService.get(Matchers.anyString(), Matchers.anyString())).thenReturn(returnJson);
|
||||||
// final WxImgProcService wxMpImgProcService = new WxMpImgProcServiceImpl(wxService);
|
final WxImgProcService wxMpImgProcService = new WxMpImgProcServiceImpl(wxService);
|
||||||
// final WxImgProcQrCodeResult result = wxMpImgProcService.qrCode("abc");
|
final WxImgProcQrCodeResult result = wxMpImgProcService.qrCode("abc");
|
||||||
// Assertions.assertThat(result).isNotNull();
|
Assertions.assertThat(result).isNotNull();
|
||||||
// System.out.println(result);
|
System.out.println(result);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
// public void testSuperResolution() throws Exception {
|
public void testSuperResolution() throws Exception {
|
||||||
// String returnJson = "{\n" +
|
String returnJson = "{\n" +
|
||||||
// " \"errcode\": 0, \n" +
|
" \"errcode\": 0, \n" +
|
||||||
// " \"errmsg\": \"ok\", \n" +
|
" \"errmsg\": \"ok\", \n" +
|
||||||
// " \"media_id\": \"6WXsIXkG7lXuDLspD9xfm5dsvHzb0EFl0li6ySxi92ap8Vl3zZoD9DpOyNudeJGB\"\n" +
|
" \"media_id\": \"6WXsIXkG7lXuDLspD9xfm5dsvHzb0EFl0li6ySxi92ap8Vl3zZoD9DpOyNudeJGB\"\n" +
|
||||||
// "}";
|
"}";
|
||||||
// Mockito.when(wxService.get(Matchers.anyString(), Matchers.anyString())).thenReturn(returnJson);
|
Mockito.when(wxService.get(Matchers.anyString(), Matchers.anyString())).thenReturn(returnJson);
|
||||||
// final WxImgProcService wxMpImgProcService = new WxMpImgProcServiceImpl(wxService);
|
final WxImgProcService wxMpImgProcService = new WxMpImgProcServiceImpl(wxService);
|
||||||
// final WxImgProcSuperResolutionResult result = wxMpImgProcService.superResolution("abc");
|
final WxImgProcSuperResolutionResult result = wxMpImgProcService.superResolution("abc");
|
||||||
// Assertions.assertThat(result).isNotNull();
|
Assertions.assertThat(result).isNotNull();
|
||||||
// System.out.println(result);
|
System.out.println(result);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
// public void testAiCrop() throws Exception {
|
public void testAiCrop() throws Exception {
|
||||||
// String returnJson = "{\n" +
|
String returnJson = "{\n" +
|
||||||
// " \"errcode\": 0, \n" +
|
" \"errcode\": 0, \n" +
|
||||||
// " \"errmsg\": \"ok\", \n" +
|
" \"errmsg\": \"ok\", \n" +
|
||||||
// " \"results\": [ //智能裁剪结果\n" +
|
" \"results\": [ //智能裁剪结果\n" +
|
||||||
// " {\n" +
|
" {\n" +
|
||||||
// " \"crop_left\": 112, \n" +
|
" \"crop_left\": 112, \n" +
|
||||||
// " \"crop_top\": 0, \n" +
|
" \"crop_top\": 0, \n" +
|
||||||
// " \"crop_right\": 839, \n" +
|
" \"crop_right\": 839, \n" +
|
||||||
// " \"crop_bottom\": 727\n" +
|
" \"crop_bottom\": 727\n" +
|
||||||
// " }, \n" +
|
" }, \n" +
|
||||||
// " {\n" +
|
" {\n" +
|
||||||
// " \"crop_left\": 0, \n" +
|
" \"crop_left\": 0, \n" +
|
||||||
// " \"crop_top\": 205, \n" +
|
" \"crop_top\": 205, \n" +
|
||||||
// " \"crop_right\": 965, \n" +
|
" \"crop_right\": 965, \n" +
|
||||||
// " \"crop_bottom\": 615\n" +
|
" \"crop_bottom\": 615\n" +
|
||||||
// " }\n" +
|
" }\n" +
|
||||||
// " ], \n" +
|
" ], \n" +
|
||||||
// " \"img_size\": { //图片大小\n" +
|
" \"img_size\": { //图片大小\n" +
|
||||||
// " \"w\": 966, \n" +
|
" \"w\": 966, \n" +
|
||||||
// " \"h\": 728\n" +
|
" \"h\": 728\n" +
|
||||||
// " }\n" +
|
" }\n" +
|
||||||
// "}";
|
"}";
|
||||||
// Mockito.when(wxService.get(Matchers.anyString(), Matchers.anyString())).thenReturn(returnJson);
|
Mockito.when(wxService.get(Matchers.anyString(), Matchers.anyString())).thenReturn(returnJson);
|
||||||
// final WxImgProcService wxMpImgProcService = new WxMpImgProcServiceImpl(wxService);
|
final WxImgProcService wxMpImgProcService = new WxMpImgProcServiceImpl(wxService);
|
||||||
// final WxImgProcAiCropResult result = wxMpImgProcService.aiCrop("abc");
|
final WxImgProcAiCropResult result = wxMpImgProcService.aiCrop("abc");
|
||||||
// Assertions.assertThat(result).isNotNull();
|
Assertions.assertThat(result).isNotNull();
|
||||||
// System.out.println(result);
|
System.out.println(result);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,203 +1,202 @@
|
|||||||
package com.ossez.wechat.oa.api.impl;
|
package com.ossez.wechat.oa.api.impl;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import java.io.File;
|
||||||
import com.ossez.wechat.common.constant.WeChatConstant.MsgType;
|
import java.time.Instant;
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
import java.time.temporal.ChronoUnit;
|
||||||
import com.ossez.wechat.common.model.req.CustomMessage;
|
import java.util.Date;
|
||||||
import com.ossez.wechat.common.model.req.CustomMessage.KfText;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatMsgService;
|
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||||
import com.ossez.wechat.oa.api.test.TestBase;
|
import com.ossez.wechat.oa.api.test.ApiTestModule;
|
||||||
import com.ossez.wechat.oa.api.test.TestConfigStorage;
|
import com.ossez.wechat.oa.api.test.TestConfigStorage;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import com.ossez.wechat.oa.bean.kefu.WxMpKefuMessage;
|
||||||
import org.junit.jupiter.api.Test;
|
import com.ossez.wechat.oa.bean.kefu.request.WxMpKfAccountRequest;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.assertj.core.api.Assertions;
|
||||||
import org.junit.jupiter.api.TestInstance.Lifecycle;
|
import org.testng.annotations.*;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||||
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
|
import com.ossez.wechat.oa.bean.kefu.result.WxMpKfInfo;
|
||||||
|
import com.ossez.wechat.oa.bean.kefu.result.WxMpKfList;
|
||||||
|
import com.ossez.wechat.oa.bean.kefu.result.WxMpKfMsgList;
|
||||||
|
import com.ossez.wechat.oa.bean.kefu.result.WxMpKfOnlineList;
|
||||||
|
import com.ossez.wechat.oa.bean.kefu.result.WxMpKfSessionGetResult;
|
||||||
|
import com.ossez.wechat.oa.bean.kefu.result.WxMpKfSessionList;
|
||||||
|
import com.ossez.wechat.oa.bean.kefu.result.WxMpKfSessionWaitCaseList;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试客服相关接口
|
* 测试客服相关接口
|
||||||
*
|
*
|
||||||
* @author Binary Wang
|
* @author Binary Wang
|
||||||
*/
|
*/
|
||||||
@TestInstance(Lifecycle.PER_CLASS)
|
@Test
|
||||||
@Slf4j
|
@Guice(modules = ApiTestModule.class)
|
||||||
public class WxMpKefuServiceImplTest extends TestBase {
|
public class WxMpKefuServiceImplTest {
|
||||||
@Inject
|
|
||||||
protected TestConfigStorage testConfigStorage;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected WeChatMsgService weChatMsgService;
|
protected WeChatOfficialAccountService wxService;
|
||||||
|
|
||||||
|
public void testSendKefuMpNewsMessage() throws WxErrorException {
|
||||||
|
TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
||||||
|
WxMpKefuMessage message = new WxMpKefuMessage();
|
||||||
|
message.setMsgType(WeChatConstant.KefuMsgType.MPNEWS);
|
||||||
|
message.setToUser(configStorage.getOpenid());
|
||||||
|
message.setMpNewsMediaId("52R6dL2FxDpM9N1rCY3sYBqHwq-L7K_lz1sPI71idMg");
|
||||||
|
|
||||||
// public void testSendKefuMpNewsMessage() throws WxErrorException {
|
boolean result = this.wxService.getKefuService().sendKefuMessage(message);
|
||||||
// TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
Assertions.assertThat(result).isTrue();
|
||||||
// WxMpKefuMessage message = new WxMpKefuMessage();
|
}
|
||||||
// message.setMsgType(WeChatConstant.MsgType.MPNEWS);
|
|
||||||
// message.setToUser(configStorage.getOpenid());
|
|
||||||
// message.setMpNewsMediaId("52R6dL2FxDpM9N1rCY3sYBqHwq-L7K_lz1sPI71idMg");
|
|
||||||
//
|
|
||||||
// boolean result = this.wxService.getKefuService().sendKefuMessage(message);
|
|
||||||
// Assertions.assertThat(result).isTrue();
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
public void testSendKefuMessage() throws WxErrorException {
|
||||||
|
TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
||||||
|
WxMpKefuMessage message = new WxMpKefuMessage();
|
||||||
|
message.setMsgType(WeChatConstant.KefuMsgType.TEXT);
|
||||||
|
message.setToUser(configStorage.getOpenid());
|
||||||
|
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||||
|
|
||||||
@Test
|
boolean result = this.wxService.getKefuService().sendKefuMessage(message);
|
||||||
void testSendKefuMessage() throws WxErrorException {
|
Assertions.assertThat(result).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSendKefuMessageWithKfAccount() throws WxErrorException {
|
||||||
|
TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
||||||
|
WxMpKefuMessage message = new WxMpKefuMessage();
|
||||||
|
message.setMsgType(WeChatConstant.KefuMsgType.TEXT);
|
||||||
|
message.setToUser(configStorage.getOpenid());
|
||||||
|
message.setKfAccount(configStorage.getKfAccount());
|
||||||
|
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
boolean result = this.wxService.getKefuService().sendKefuMessage(message);
|
||||||
stringBuilder.append("欢迎使用 WeChat-J API " + System.lineSeparator());
|
Assertions.assertThat(result).isTrue();
|
||||||
stringBuilder.append("回车换行测试 " + System.lineSeparator());
|
}
|
||||||
stringBuilder.append("超链接:<a href=\"https://www.ossez.com/\">OSSEZ.COM</a>");
|
|
||||||
|
|
||||||
CustomMessage.KfText kfText = new CustomMessage.KfText("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"https://www.ossez.com/\">OSSEZ.COM</a>");
|
public void testKfList() throws WxErrorException {
|
||||||
CustomMessage customMessage = new CustomMessage();
|
WxMpKfList kfList = this.wxService.getKefuService().kfList();
|
||||||
customMessage.setToUser(testConfigStorage.getOpenid());
|
assertThat(kfList).isNotNull();
|
||||||
customMessage.setMsgType(MsgType.TEXT);
|
for (WxMpKfInfo k : kfList.getKfList()) {
|
||||||
customMessage.setText(new KfText(stringBuilder.toString()));
|
System.err.println(k);
|
||||||
|
|
||||||
|
|
||||||
String result = weChatMsgService.sendMessage(customMessage);
|
|
||||||
// Assertions.assertThat(result).isTrue();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// public void testSendKefuMessageWithKfAccount() throws WxErrorException {
|
public void testKfOnlineList() throws WxErrorException {
|
||||||
// TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
WxMpKfOnlineList kfOnlineList = this.wxService.getKefuService().kfOnlineList();
|
||||||
// WxMpKefuMessage message = new WxMpKefuMessage();
|
assertThat(kfOnlineList).isNotNull();
|
||||||
// message.setMsgType(WeChatConstant.MsgType.TEXT);
|
for (WxMpKfInfo k : kfOnlineList.getKfOnlineList()) {
|
||||||
// message.setToUser(configStorage.getOpenid());
|
System.err.println(k);
|
||||||
// message.setKfAccount(configStorage.getKfAccount());
|
}
|
||||||
// message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
}
|
||||||
//
|
|
||||||
// boolean result = this.wxService.getKefuService().sendKefuMessage(message);
|
@DataProvider
|
||||||
// Assertions.assertThat(result).isTrue();
|
public Object[][] getKfAccount() {
|
||||||
// }
|
TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
||||||
//
|
return new Object[][]{{configStorage.getKfAccount()}};
|
||||||
// public void testKfList() throws WxErrorException {
|
}
|
||||||
// WxMpKfList kfList = this.wxService.getKefuService().kfList();
|
|
||||||
// assertThat(kfList).isNotNull();
|
@Test(dataProvider = "getKfAccount")
|
||||||
// for (WxMpKfInfo k : kfList.getKfList()) {
|
public void testKfAccountAdd(String kfAccount) throws WxErrorException {
|
||||||
// System.err.println(k);
|
WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
|
||||||
// }
|
.kfAccount(kfAccount).nickName("我晕").build();
|
||||||
// }
|
assertThat(this.wxService.getKefuService().kfAccountAdd(request)).isTrue();
|
||||||
//
|
}
|
||||||
// public void testKfOnlineList() throws WxErrorException {
|
|
||||||
// WxMpKfOnlineList kfOnlineList = this.wxService.getKefuService().kfOnlineList();
|
@Test(dependsOnMethods = {
|
||||||
// assertThat(kfOnlineList).isNotNull();
|
"testKfAccountAdd"}, dataProvider = "getKfAccount")
|
||||||
// for (WxMpKfInfo k : kfOnlineList.getKfOnlineList()) {
|
public void testKfAccountUpdate(String kfAccount) throws WxErrorException {
|
||||||
// System.err.println(k);
|
WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
|
||||||
// }
|
.kfAccount(kfAccount).nickName("我晕").build();
|
||||||
// }
|
assertThat(this.wxService.getKefuService().kfAccountUpdate(request)).isTrue();
|
||||||
//
|
}
|
||||||
// @DataProvider
|
|
||||||
// public Object[][] getKfAccount() {
|
@Test(dependsOnMethods = {
|
||||||
// TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
"testKfAccountAdd"}, dataProvider = "getKfAccount")
|
||||||
// return new Object[][]{{configStorage.getKfAccount()}};
|
public void testKfAccountInviteWorker(String kfAccount) throws WxErrorException {
|
||||||
// }
|
WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
|
||||||
//
|
.kfAccount(kfAccount).inviteWx(" ").build();
|
||||||
// @Test(dataProvider = "getKfAccount")
|
assertThat(this.wxService.getKefuService().kfAccountInviteWorker(request)).isTrue();
|
||||||
// public void testKfAccountAdd(String kfAccount) throws WxErrorException {
|
}
|
||||||
// WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
|
|
||||||
// .kfAccount(kfAccount).nickName("我晕").build();
|
@Test(dependsOnMethods = {"testKfAccountUpdate", "testKfAccountAdd"}, dataProvider = "getKfAccount")
|
||||||
// assertThat(this.wxService.getKefuService().kfAccountAdd(request)).isTrue();
|
public void testKfAccountUploadHeadImg(String kfAccount) throws WxErrorException {
|
||||||
// }
|
File imgFile = new File("src\\test\\resources\\mm.jpeg");
|
||||||
//
|
boolean result = this.wxService.getKefuService().kfAccountUploadHeadImg(kfAccount, imgFile);
|
||||||
// @Test(dependsOnMethods = {
|
Assertions.assertThat(result).isTrue();
|
||||||
// "testKfAccountAdd"}, dataProvider = "getKfAccount")
|
}
|
||||||
// public void testKfAccountUpdate(String kfAccount) throws WxErrorException {
|
|
||||||
// WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
|
@Test(dataProvider = "getKfAccount")
|
||||||
// .kfAccount(kfAccount).nickName("我晕").build();
|
public void testKfAccountDel(String kfAccount) throws WxErrorException {
|
||||||
// assertThat(this.wxService.getKefuService().kfAccountUpdate(request)).isTrue();
|
boolean result = this.wxService.getKefuService().kfAccountDel(kfAccount);
|
||||||
// }
|
Assertions.assertThat(result).isTrue();
|
||||||
//
|
}
|
||||||
// @Test(dependsOnMethods = {
|
|
||||||
// "testKfAccountAdd"}, dataProvider = "getKfAccount")
|
@DataProvider
|
||||||
// public void testKfAccountInviteWorker(String kfAccount) throws WxErrorException {
|
public Object[][] getKfAccountAndOpenid() {
|
||||||
// WxMpKfAccountRequest request = WxMpKfAccountRequest.builder()
|
TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
||||||
// .kfAccount(kfAccount).inviteWx(" ").build();
|
return new Object[][]{{configStorage.getKfAccount(), configStorage.getOpenid()}};
|
||||||
// assertThat(this.wxService.getKefuService().kfAccountInviteWorker(request)).isTrue();
|
}
|
||||||
// }
|
|
||||||
//
|
@Test(dataProvider = "getKfAccountAndOpenid")
|
||||||
// @Test(dependsOnMethods = {"testKfAccountUpdate", "testKfAccountAdd"}, dataProvider = "getKfAccount")
|
public void testKfSessionCreate(String kfAccount, String openid) throws WxErrorException {
|
||||||
// public void testKfAccountUploadHeadImg(String kfAccount) throws WxErrorException {
|
boolean result = this.wxService.getKefuService().kfSessionCreate(openid, kfAccount);
|
||||||
// File imgFile = new File("src\\test\\resources\\mm.jpeg");
|
Assertions.assertThat(result).isTrue();
|
||||||
// boolean result = this.wxService.getKefuService().kfAccountUploadHeadImg(kfAccount, imgFile);
|
}
|
||||||
// Assertions.assertThat(result).isTrue();
|
|
||||||
// }
|
@Test(dataProvider = "getKfAccountAndOpenid")
|
||||||
//
|
public void testKfSessionClose(String kfAccount, String openid) throws WxErrorException {
|
||||||
// @Test(dataProvider = "getKfAccount")
|
boolean result = this.wxService.getKefuService().kfSessionClose(openid, kfAccount);
|
||||||
// public void testKfAccountDel(String kfAccount) throws WxErrorException {
|
Assertions.assertThat(result).isTrue();
|
||||||
// boolean result = this.wxService.getKefuService().kfAccountDel(kfAccount);
|
}
|
||||||
// Assertions.assertThat(result).isTrue();
|
|
||||||
// }
|
@Test(dataProvider = "getKfAccountAndOpenid")
|
||||||
//
|
public void testKfSessionGet(@SuppressWarnings("unused") String kfAccount, String openid) throws WxErrorException {
|
||||||
// @DataProvider
|
WxMpKfSessionGetResult result = this.wxService.getKefuService().kfSessionGet(openid);
|
||||||
// public Object[][] getKfAccountAndOpenid() {
|
assertThat(result).isNotNull();
|
||||||
// TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
System.err.println(result);
|
||||||
// return new Object[][]{{configStorage.getKfAccount(), configStorage.getOpenid()}};
|
}
|
||||||
// }
|
|
||||||
//
|
@Test(dataProvider = "getKfAccount")
|
||||||
// @Test(dataProvider = "getKfAccountAndOpenid")
|
public void testKfSessionList(String kfAccount) throws WxErrorException {
|
||||||
// public void testKfSessionCreate(String kfAccount, String openid) throws WxErrorException {
|
WxMpKfSessionList result = this.wxService.getKefuService().kfSessionList(kfAccount);
|
||||||
// boolean result = this.wxService.getKefuService().kfSessionCreate(openid, kfAccount);
|
assertThat(result).isNotNull();
|
||||||
// Assertions.assertThat(result).isTrue();
|
System.err.println(result);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Test(dataProvider = "getKfAccountAndOpenid")
|
@Test
|
||||||
// public void testKfSessionClose(String kfAccount, String openid) throws WxErrorException {
|
public void testKfSessionGetWaitCase() throws WxErrorException {
|
||||||
// boolean result = this.wxService.getKefuService().kfSessionClose(openid, kfAccount);
|
WxMpKfSessionWaitCaseList result = this.wxService.getKefuService().kfSessionGetWaitCase();
|
||||||
// Assertions.assertThat(result).isTrue();
|
assertThat(result).isNotNull();
|
||||||
// }
|
System.err.println(result);
|
||||||
//
|
}
|
||||||
// @Test(dataProvider = "getKfAccountAndOpenid")
|
|
||||||
// public void testKfSessionGet(@SuppressWarnings("unused") String kfAccount, String openid) throws WxErrorException {
|
@Test
|
||||||
// WxMpKfSessionGetResult result = this.wxService.getKefuService().kfSessionGet(openid);
|
public void testKfMsgList() throws WxErrorException {
|
||||||
// assertThat(result).isNotNull();
|
// Date startTime = DateTime.now().minusDays(1).toDate();
|
||||||
// System.err.println(result);
|
// Date endTime = DateTime.now().minusDays(0).toDate();
|
||||||
// }
|
Date startTime = Date.from(Instant.now().minus(1, ChronoUnit.DAYS));
|
||||||
//
|
Date endTime = Date.from(Instant.now());
|
||||||
// @Test(dataProvider = "getKfAccount")
|
|
||||||
// public void testKfSessionList(String kfAccount) throws WxErrorException {
|
WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime, endTime, 1L, 50);
|
||||||
// WxMpKfSessionList result = this.wxService.getKefuService().kfSessionList(kfAccount);
|
assertThat(result).isNotNull();
|
||||||
// assertThat(result).isNotNull();
|
System.err.println(result);
|
||||||
// System.err.println(result);
|
}
|
||||||
// }
|
|
||||||
//
|
@Test
|
||||||
// @Test
|
public void testKfMsgListAll() throws WxErrorException {
|
||||||
// public void testKfSessionGetWaitCase() throws WxErrorException {
|
// Date startTime = DateTime.now().minusDays(1).toDate();
|
||||||
// WxMpKfSessionWaitCaseList result = this.wxService.getKefuService().kfSessionGetWaitCase();
|
// Date endTime = DateTime.now().minusDays(0).toDate();
|
||||||
// assertThat(result).isNotNull();
|
Date startTime = Date.from(Instant.now().minus(1, ChronoUnit.DAYS));
|
||||||
// System.err.println(result);
|
Date endTime = Date.from(Instant.now());
|
||||||
// }
|
|
||||||
//
|
WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime, endTime);
|
||||||
// @Test
|
assertThat(result).isNotNull();
|
||||||
// public void testKfMsgList() throws WxErrorException {
|
System.err.println(result);
|
||||||
// // Date startTime = DateTime.now().minusDays(1).toDate();
|
}
|
||||||
// // Date endTime = DateTime.now().minusDays(0).toDate();
|
|
||||||
// Date startTime = Date.from(Instant.now().minus(1, ChronoUnit.DAYS));
|
@Test
|
||||||
// Date endTime = Date.from(Instant.now());
|
public void testSendKfTypingState() throws WxErrorException {
|
||||||
//
|
TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
||||||
// WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime, endTime, 1L, 50);
|
boolean result = this.wxService.getKefuService().sendKfTypingState(configStorage.getOpenid(), "Typing");
|
||||||
// assertThat(result).isNotNull();
|
Assertions.assertThat(result).isTrue();
|
||||||
// System.err.println(result);
|
}
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testKfMsgListAll() throws WxErrorException {
|
|
||||||
// // Date startTime = DateTime.now().minusDays(1).toDate();
|
|
||||||
// // Date endTime = DateTime.now().minusDays(0).toDate();
|
|
||||||
// Date startTime = Date.from(Instant.now().minus(1, ChronoUnit.DAYS));
|
|
||||||
// Date endTime = Date.from(Instant.now());
|
|
||||||
//
|
|
||||||
// WxMpKfMsgList result = this.wxService.getKefuService().kfMsgList(startTime, endTime);
|
|
||||||
// assertThat(result).isNotNull();
|
|
||||||
// System.err.println(result);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void testSendKfTypingState() throws WxErrorException {
|
|
||||||
// TestConfigStorage configStorage = (TestConfigStorage) this.wxService.getWxMpConfigStorage();
|
|
||||||
// boolean result = this.wxService.getKefuService().sendKfTypingState(configStorage.getOpenid(), "Typing");
|
|
||||||
// Assertions.assertThat(result).isTrue();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,8 @@ package com.ossez.wechat.oa.api.impl;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||||
import com.ossez.wechat.common.model.entity.builder.MenuButtonBuilder;
|
import com.ossez.wechat.common.bean.menu.WxMenu;
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenu;
|
import com.ossez.wechat.common.bean.menu.WxMenuButton;
|
||||||
import com.ossez.wechat.common.model.entity.menu.MenuButton;
|
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||||
import com.ossez.wechat.oa.api.test.ApiTestModule;
|
import com.ossez.wechat.oa.api.test.ApiTestModule;
|
||||||
@ -201,7 +200,7 @@ public class WxMpMenuServiceImplTest {
|
|||||||
@DataProvider(name = "menu")
|
@DataProvider(name = "menu")
|
||||||
public Object[][] getMenu() {
|
public Object[][] getMenu() {
|
||||||
WxMenu menu = new WxMenu();
|
WxMenu menu = new WxMenu();
|
||||||
MenuButton button1 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button1 = new WxMenuButton();
|
||||||
button1.setType(WeChatConstant.MenuButtonType.CLICK);
|
button1.setType(WeChatConstant.MenuButtonType.CLICK);
|
||||||
button1.setName("今日歌曲");
|
button1.setName("今日歌曲");
|
||||||
button1.setKey("V1001_TODAY_MUSIC");
|
button1.setKey("V1001_TODAY_MUSIC");
|
||||||
@ -213,31 +212,31 @@ public class WxMpMenuServiceImplTest {
|
|||||||
// button2.setPagePath("pages/lunar/index.html");
|
// button2.setPagePath("pages/lunar/index.html");
|
||||||
// button2.setUrl("http://mp.weixin.qq.com");
|
// button2.setUrl("http://mp.weixin.qq.com");
|
||||||
|
|
||||||
MenuButton button3 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button3 = new WxMenuButton();
|
||||||
button3.setName("菜单");
|
button3.setName("菜单");
|
||||||
|
|
||||||
menu.getButtons().add(button1);
|
menu.getButtons().add(button1);
|
||||||
// menu.getButtons().add(button2);
|
// menu.getButtons().add(button2);
|
||||||
menu.getButtons().add(button3);
|
menu.getButtons().add(button3);
|
||||||
|
|
||||||
MenuButton button31 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button31 = new WxMenuButton();
|
||||||
button31.setType(WeChatConstant.MenuButtonType.VIEW);
|
button31.setType(WeChatConstant.MenuButtonType.VIEW);
|
||||||
button31.setName("搜索");
|
button31.setName("搜索");
|
||||||
button31.setUrl("http://www.soso.com/");
|
button31.setUrl("http://www.soso.com/");
|
||||||
|
|
||||||
MenuButton button32 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button32 = new WxMenuButton();
|
||||||
button32.setType(WeChatConstant.MenuButtonType.VIEW);
|
button32.setType(WeChatConstant.MenuButtonType.VIEW);
|
||||||
button32.setName("视频");
|
button32.setName("视频");
|
||||||
button32.setUrl("http://v.qq.com/");
|
button32.setUrl("http://v.qq.com/");
|
||||||
|
|
||||||
MenuButton button33 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button33 = new WxMenuButton();
|
||||||
button33.setType(WeChatConstant.MenuButtonType.CLICK);
|
button33.setType(WeChatConstant.MenuButtonType.CLICK);
|
||||||
button33.setName("赞一下我们");
|
button33.setName("赞一下我们");
|
||||||
button33.setKey("V1001_GOOD");
|
button33.setKey("V1001_GOOD");
|
||||||
|
|
||||||
// button3.getSubButtons().add(button31);
|
button3.getSubButtons().add(button31);
|
||||||
// button3.getSubButtons().add(button32);
|
button3.getSubButtons().add(button32);
|
||||||
// button3.getSubButtons().add(button33);
|
button3.getSubButtons().add(button33);
|
||||||
|
|
||||||
return new Object[][]{
|
return new Object[][]{
|
||||||
new Object[]{
|
new Object[]{
|
||||||
|
@ -1,18 +1,24 @@
|
|||||||
package com.ossez.wechat.oa.api.impl;
|
package com.ossez.wechat.oa.api.impl;
|
||||||
|
|
||||||
import com.ossez.wechat.common.bean.ocr.*;
|
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
import com.ossez.wechat.common.util.fs.FileUtils;
|
import com.ossez.wechat.common.util.fs.FileUtils;
|
||||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||||
import com.ossez.wechat.oa.api.test.ApiTestModule;
|
import com.ossez.wechat.oa.api.test.ApiTestModule;
|
||||||
import com.ossez.wechat.oa.api.test.TestConstants;
|
import com.ossez.wechat.oa.api.test.TestConstants;
|
||||||
|
import com.ossez.wechat.common.bean.ocr.WxOcrBankCardResult;
|
||||||
|
import com.ossez.wechat.common.bean.ocr.WxOcrBizLicenseResult;
|
||||||
|
import com.ossez.wechat.common.bean.ocr.WxOcrCommResult;
|
||||||
|
import com.ossez.wechat.common.bean.ocr.WxOcrDrivingLicenseResult;
|
||||||
|
import com.ossez.wechat.common.bean.ocr.WxOcrDrivingResult;
|
||||||
|
import com.ossez.wechat.common.bean.ocr.WxOcrIdCardResult;
|
||||||
import org.assertj.core.api.Assertions;
|
import org.assertj.core.api.Assertions;
|
||||||
import org.mockito.ArgumentMatchers;
|
import org.mockito.Matchers;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.testng.annotations.Guice;
|
import org.testng.annotations.Guice;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -20,364 +26,370 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author YuCheng
|
* 测试类.
|
||||||
|
*
|
||||||
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
|
* created on 2019-06-22
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@Guice(modules = ApiTestModule.class)
|
@Guice(modules = ApiTestModule.class)
|
||||||
public class WxMpOcrServiceImplTest {
|
public class WxMpOcrServiceImplTest {
|
||||||
@Inject
|
@Inject
|
||||||
private WeChatOfficialAccountService service;
|
private WeChatOfficialAccountService service;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIdCard() throws WxErrorException {
|
||||||
|
final WxOcrIdCardResult result = this.service.getOcrService().idCard(
|
||||||
|
"https://res.wx.qq.com/op_res/E_oqdHqP4ETOJsT46sQnXz1HbeHOpqDQTuhkYeaLaJTf-JKld7de3091dwxCQwa6");
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIdCard2() throws Exception {
|
||||||
|
InputStream inputStream = this.getImageStream("https://res.wx.qq.com/op_res/E_oqdHqP4ETOJsT46sQnXz1HbeHOpqDQTuhkYeaLaJTf-JKld7de3091dwxCQwa6");
|
||||||
|
File tempFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), TestConstants.FILE_JPG);
|
||||||
|
final WxOcrIdCardResult result = this.service.getOcrService().idCard(tempFile);
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBankCard() throws WxErrorException {
|
||||||
|
final WxOcrBankCardResult result = this.service.getOcrService().bankCard("https://res.wx.qq.com/op_res/eP7PObYbBJj-_19EbGBL4PWe_zQ1NwET5NXSugjEWc-4ayns4Q-HFJrp-AOog8ih");
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBankCard2() throws Exception {
|
||||||
|
InputStream inputStream = this.getImageStream("https://res.wx.qq.com/op_res/eP7PObYbBJj-_19EbGBL4PWe_zQ1NwET5NXSugjEWc-4ayns4Q-HFJrp-AOog8ih");
|
||||||
|
File tempFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), TestConstants.FILE_JPG);
|
||||||
|
final WxOcrBankCardResult result = this.service.getOcrService().bankCard(tempFile);
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDriving() throws WxErrorException {
|
||||||
|
final WxOcrDrivingResult result = this.service.getOcrService().driving("https://res.wx.qq.com/op_res/T051P5uWvh9gSJ9j78tWib53WiNi2pHSSZhoO8wnY3Av-djpsA4kA9whbtt6_Tb6");
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDriving2() throws Exception {
|
||||||
|
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg");
|
||||||
|
File tempFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), TestConstants.FILE_JPG);
|
||||||
|
final WxOcrDrivingResult result = this.service.getOcrService().driving(tempFile);
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDrivingLicense() throws WxErrorException {
|
||||||
|
final WxOcrDrivingLicenseResult result = this.service.getOcrService().drivingLicense("https://res.wx.qq.com/op_res/kD4YXjYVAW1eaQqn9uTA0rrOFoZRvVINitNDSGo5gJ7SzTCezNq_ZDDmU1I08kGn");
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDrivingLicense2() throws Exception {
|
||||||
|
InputStream inputStream = this.getImageStream("https://res.wx.qq.com/op_res/kD4YXjYVAW1eaQqn9uTA0rrOFoZRvVINitNDSGo5gJ7SzTCezNq_ZDDmU1I08kGn");
|
||||||
|
File tempFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), TestConstants.FILE_JPG);
|
||||||
|
final WxOcrDrivingLicenseResult result = this.service.getOcrService().drivingLicense(tempFile);
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBizLicense() throws WxErrorException {
|
||||||
|
final WxOcrBizLicenseResult result = this.service.getOcrService().bizLicense("https://res.wx.qq.com/op_res/apCy0YbnEdjYsa_cjW6x3FlpCc20uQ-2BYE7aXnFsrB-ALHZNgdKXhzIUcrRnDoL");
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBizLicense2() throws Exception {
|
||||||
|
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg");
|
||||||
|
File tempFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), TestConstants.FILE_JPG);
|
||||||
|
final WxOcrBizLicenseResult result = this.service.getOcrService().bizLicense(tempFile);
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testComm() throws WxErrorException {
|
||||||
|
final WxOcrCommResult result = this.service.getOcrService().comm("https://res.wx.qq.com/op_res/apCy0YbnEdjYsa_cjW6x3FlpCc20uQ-2BYE7aXnFsrB-ALHZNgdKXhzIUcrRnDoL");
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testComm2() throws Exception {
|
||||||
|
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg");
|
||||||
|
File tempFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), TestConstants.FILE_JPG);
|
||||||
|
final WxOcrCommResult result = this.service.getOcrService().comm(tempFile);
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private InputStream getImageStream(String url) {
|
||||||
|
try {
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||||
|
connection.setReadTimeout(5000);
|
||||||
|
connection.setConnectTimeout(5000);
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
if (HttpURLConnection.HTTP_OK == connection.getResponseCode()) {
|
||||||
|
return connection.getInputStream();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("获取网络图片出现异常,图片路径为:" + url);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MockTest {
|
||||||
|
private final WeChatOfficialAccountService wxService = Mockito.mock(WeChatOfficialAccountService.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIdCard() throws WxErrorException {
|
public void testIdCard() throws Exception {
|
||||||
final WxOcrIdCardResult result = this.service.getOcrService().idCard(
|
String returnJson = "{\"type\":\"Back\",\"name\":\"张三\",\"id\":\"110101199909090099\",\"valid_date\":\"20110101-20210201\"}";
|
||||||
"https://res.wx.qq.com/op_res/E_oqdHqP4ETOJsT46sQnXz1HbeHOpqDQTuhkYeaLaJTf-JKld7de3091dwxCQwa6");
|
|
||||||
Assertions.assertThat(result).isNotNull();
|
Mockito.when(wxService.post(Matchers.anyString(), Matchers.anyString())).thenReturn(returnJson);
|
||||||
System.out.println(result);
|
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
||||||
|
|
||||||
|
final WxOcrIdCardResult result = wxMpOcrService.idCard("abc");
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIdCard2() throws Exception {
|
public void testBankCard() throws Exception {
|
||||||
InputStream inputStream = this.getImageStream("https://res.wx.qq.com/op_res/E_oqdHqP4ETOJsT46sQnXz1HbeHOpqDQTuhkYeaLaJTf-JKld7de3091dwxCQwa6");
|
String returnJson = "{\"number\":\"24234234345234\"}";
|
||||||
File tempFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), TestConstants.FILE_JPG);
|
|
||||||
final WxOcrIdCardResult result = this.service.getOcrService().idCard(tempFile);
|
Mockito.when(wxService.post(Matchers.anyString(), Matchers.anyString())).thenReturn(returnJson);
|
||||||
Assertions.assertThat(result).isNotNull();
|
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
||||||
System.out.println(result);
|
|
||||||
|
final WxOcrBankCardResult result = wxMpOcrService.bankCard("abc");
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBankCard() throws WxErrorException {
|
public void testDriving() throws Exception {
|
||||||
final WxOcrBankCardResult result = this.service.getOcrService().bankCard("https://res.wx.qq.com/op_res/eP7PObYbBJj-_19EbGBL4PWe_zQ1NwET5NXSugjEWc-4ayns4Q-HFJrp-AOog8ih");
|
String returnJson = "{\n" +
|
||||||
Assertions.assertThat(result).isNotNull();
|
" \"errcode\": 0,\n" +
|
||||||
System.out.println(result);
|
" \"errmsg\": \"ok\",\n" +
|
||||||
|
" \"plate_num\": \"粤xxxxx\", //车牌号码\n" +
|
||||||
|
" \"vehicle_type\": \"小型普通客车\", //车辆类型\n" +
|
||||||
|
" \"owner\": \"东莞市xxxxx机械厂\", //所有人\n" +
|
||||||
|
" \"addr\": \"广东省东莞市xxxxx号\", //住址\n" +
|
||||||
|
" \"use_character\": \"非营运\", //使用性质\n" +
|
||||||
|
" \"model\": \"江淮牌HFCxxxxxxx\", //品牌型号\n" +
|
||||||
|
" \"vin\": \"LJ166xxxxxxxx51\", //车辆识别代号\n" +
|
||||||
|
" \"engine_num\": \"J3xxxxx3\", //发动机号码\n" +
|
||||||
|
" \"register_date\": \"2018-07-06\", //注册日期\n" +
|
||||||
|
" \"issue_date\": \"2018-07-01\", //发证日期\n" +
|
||||||
|
" \"plate_num_b\": \"粤xxxxx\", //车牌号码\n" +
|
||||||
|
" \"record\": \"441xxxxxx3\", //号牌\n" +
|
||||||
|
" \"passengers_num\": \"7人\", //核定载人数\n" +
|
||||||
|
" \"total_quality\": \"2700kg\", //总质量\n" +
|
||||||
|
" \"prepare_quality\": \"1995kg\", //整备质量\n" +
|
||||||
|
" \"overall_size\": \"4582x1795x1458mm\", //外廓尺寸\n" +
|
||||||
|
" \"card_position_front\": {//卡片正面位置(检测到卡片正面才会返回)\n" +
|
||||||
|
" \"pos\": {\n" +
|
||||||
|
" \"left_top\": {\n" +
|
||||||
|
" \"x\": 119, \n" +
|
||||||
|
" \"y\": 2925\n" +
|
||||||
|
" }, \n" +
|
||||||
|
" \"right_top\": {\n" +
|
||||||
|
" \"x\": 1435, \n" +
|
||||||
|
" \"y\": 2887\n" +
|
||||||
|
" }, \n" +
|
||||||
|
" \"right_bottom\": {\n" +
|
||||||
|
" \"x\": 1435, \n" +
|
||||||
|
" \"y\": 3793\n" +
|
||||||
|
" }, \n" +
|
||||||
|
" \"left_bottom\": {\n" +
|
||||||
|
" \"x\": 119, \n" +
|
||||||
|
" \"y\": 3831\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }, \n" +
|
||||||
|
" \"card_position_back\": {//卡片反面位置(检测到卡片反面才会返回)\n" +
|
||||||
|
" \"pos\": {\n" +
|
||||||
|
" \"left_top\": {\n" +
|
||||||
|
" \"x\": 1523, \n" +
|
||||||
|
" \"y\": 2849\n" +
|
||||||
|
" }, \n" +
|
||||||
|
" \"right_top\": {\n" +
|
||||||
|
" \"x\": 2898, \n" +
|
||||||
|
" \"y\": 2887\n" +
|
||||||
|
" }, \n" +
|
||||||
|
" \"right_bottom\": {\n" +
|
||||||
|
" \"x\": 2927, \n" +
|
||||||
|
" \"y\": 3831\n" +
|
||||||
|
" }, \n" +
|
||||||
|
" \"left_bottom\": {\n" +
|
||||||
|
" \"x\": 1523, \n" +
|
||||||
|
" \"y\": 3831\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }, \n" +
|
||||||
|
" \"img_size\": {//图片大小\n" +
|
||||||
|
" \"w\": 3120, \n" +
|
||||||
|
" \"h\": 4208\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
Mockito.when(wxService.post(Matchers.anyString(), Matchers.anyString())).thenReturn(returnJson);
|
||||||
|
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
||||||
|
|
||||||
|
final WxOcrDrivingResult result = wxMpOcrService.driving("abc");
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBankCard2() throws Exception {
|
public void testDrivingLicense() throws Exception {
|
||||||
InputStream inputStream = this.getImageStream("https://res.wx.qq.com/op_res/eP7PObYbBJj-_19EbGBL4PWe_zQ1NwET5NXSugjEWc-4ayns4Q-HFJrp-AOog8ih");
|
String returnJson = "{\n" +
|
||||||
File tempFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), TestConstants.FILE_JPG);
|
" \"errcode\": 0,\n" +
|
||||||
final WxOcrBankCardResult result = this.service.getOcrService().bankCard(tempFile);
|
" \"errmsg\": \"ok\",\n" +
|
||||||
Assertions.assertThat(result).isNotNull();
|
" \"id_num\": \"660601xxxxxxxx1234\", //证号\n" +
|
||||||
System.out.println(result);
|
" \"name\": \"张三\", //姓名\n" +
|
||||||
|
" \"sex\": \"男\", //性别\n" +
|
||||||
|
" \"nationality\": \"中国\", //国籍\n" +
|
||||||
|
" \"address\": \"广东省东莞市xxxxx号\", //住址\n" +
|
||||||
|
" \"birth_date\": \"1990-12-21\", //出生日期\n" +
|
||||||
|
" \"issue_date\": \"2012-12-21\", //初次领证日期\n" +
|
||||||
|
" \"car_class\": \"C1\", //准驾车型\n" +
|
||||||
|
" \"valid_from\": \"2018-07-06\", //有效期限起始日\n" +
|
||||||
|
" \"valid_to\": \"2020-07-01\", //有效期限终止日\n" +
|
||||||
|
" \"official_seal\": \"xx市公安局公安交通管理局\" //印章文字\n" +
|
||||||
|
"}";
|
||||||
|
Mockito.when(wxService.post(Matchers.anyString(), Matchers.anyString())).thenReturn(returnJson);
|
||||||
|
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
||||||
|
|
||||||
|
final WxOcrDrivingLicenseResult result = wxMpOcrService.drivingLicense("abc");
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDriving() throws WxErrorException {
|
public void testBizLicense() throws Exception {
|
||||||
final WxOcrDrivingResult result = this.service.getOcrService().driving("https://res.wx.qq.com/op_res/T051P5uWvh9gSJ9j78tWib53WiNi2pHSSZhoO8wnY3Av-djpsA4kA9whbtt6_Tb6");
|
String returnJson = "{\n" +
|
||||||
Assertions.assertThat(result).isNotNull();
|
" \"errcode\": 0, \n" +
|
||||||
System.out.println(result);
|
" \"errmsg\": \"ok\", \n" +
|
||||||
|
" \"reg_num\": \"123123\",//注册号\n" +
|
||||||
|
" \"serial\": \"123123\",//编号\n" +
|
||||||
|
" \"legal_representative\": \"张三\", //法定代表人姓名\n" +
|
||||||
|
" \"enterprise_name\": \"XX饮食店\", //企业名称\n" +
|
||||||
|
" \"type_of_organization\": \"个人经营\", //组成形式\n" +
|
||||||
|
" \"address\": \"XX市XX区XX路XX号\", //经营场所/企业住所\n" +
|
||||||
|
" \"type_of_enterprise\": \"xxx\", //公司类型\n" +
|
||||||
|
" \"business_scope\": \"中型餐馆(不含凉菜、不含裱花蛋糕,不含生食海产品)。\", //经营范围\n" +
|
||||||
|
" \"registered_capital\": \"200万\", //注册资本\n" +
|
||||||
|
" \"paid_in_capital\": \"200万\", //实收资本\n" +
|
||||||
|
" \"valid_period\": \"2019年1月1日\", //营业期限\n" +
|
||||||
|
" \"registered_date\": \"2018年1月1日\", //注册日期/成立日期\n" +
|
||||||
|
" \"cert_position\": { //营业执照位置\n" +
|
||||||
|
" \"pos\": {\n" +
|
||||||
|
" \"left_top\": {\n" +
|
||||||
|
" \"x\": 155, \n" +
|
||||||
|
" \"y\": 191\n" +
|
||||||
|
" }, \n" +
|
||||||
|
" \"right_top\": {\n" +
|
||||||
|
" \"x\": 725, \n" +
|
||||||
|
" \"y\": 157\n" +
|
||||||
|
" }, \n" +
|
||||||
|
" \"right_bottom\": {\n" +
|
||||||
|
" \"x\": 743, \n" +
|
||||||
|
" \"y\": 512\n" +
|
||||||
|
" }, \n" +
|
||||||
|
" \"left_bottom\": {\n" +
|
||||||
|
" \"x\": 164, \n" +
|
||||||
|
" \"y\": 525\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }\n" +
|
||||||
|
" }, \n" +
|
||||||
|
" \"img_size\": { //图片大小\n" +
|
||||||
|
" \"w\": 966, \n" +
|
||||||
|
" \"h\": 728\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}";
|
||||||
|
Mockito.when(wxService.post(Matchers.anyString(), Matchers.anyString())).thenReturn(returnJson);
|
||||||
|
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
||||||
|
|
||||||
|
final WxOcrBizLicenseResult result = wxMpOcrService.bizLicense("abc");
|
||||||
|
Assertions.assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDriving2() throws Exception {
|
public void testComm() throws Exception {
|
||||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg");
|
String returnJson = "{\n" +
|
||||||
File tempFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), TestConstants.FILE_JPG);
|
" \"errcode\": 0, \n" +
|
||||||
final WxOcrDrivingResult result = this.service.getOcrService().driving(tempFile);
|
" \"errmsg\": \"ok\", \n" +
|
||||||
Assertions.assertThat(result).isNotNull();
|
" \"items\": [ //识别结果\n" +
|
||||||
System.out.println(result);
|
" {\n" +
|
||||||
}
|
" \"text\": \"腾讯\", \n" +
|
||||||
|
" \"pos\": {\n" +
|
||||||
@Test
|
" \"left_top\": {\n" +
|
||||||
public void testDrivingLicense() throws WxErrorException {
|
" \"x\": 575, \n" +
|
||||||
final WxOcrDrivingLicenseResult result = this.service.getOcrService().drivingLicense("https://res.wx.qq.com/op_res/kD4YXjYVAW1eaQqn9uTA0rrOFoZRvVINitNDSGo5gJ7SzTCezNq_ZDDmU1I08kGn");
|
" \"y\": 519\n" +
|
||||||
Assertions.assertThat(result).isNotNull();
|
" }, \n" +
|
||||||
System.out.println(result);
|
" \"right_top\": {\n" +
|
||||||
}
|
" \"x\": 744, \n" +
|
||||||
|
" \"y\": 519\n" +
|
||||||
@Test
|
" }, \n" +
|
||||||
public void testDrivingLicense2() throws Exception {
|
" \"right_bottom\": {\n" +
|
||||||
InputStream inputStream = this.getImageStream("https://res.wx.qq.com/op_res/kD4YXjYVAW1eaQqn9uTA0rrOFoZRvVINitNDSGo5gJ7SzTCezNq_ZDDmU1I08kGn");
|
" \"x\": 744, \n" +
|
||||||
File tempFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), TestConstants.FILE_JPG);
|
" \"y\": 532\n" +
|
||||||
final WxOcrDrivingLicenseResult result = this.service.getOcrService().drivingLicense(tempFile);
|
" }, \n" +
|
||||||
Assertions.assertThat(result).isNotNull();
|
" \"left_bottom\": {\n" +
|
||||||
System.out.println(result);
|
" \"x\": 573, \n" +
|
||||||
}
|
" \"y\": 532\n" +
|
||||||
|
" }\n" +
|
||||||
@Test
|
" }\n" +
|
||||||
public void testBizLicense() throws WxErrorException {
|
" }, \n" +
|
||||||
final WxOcrBizLicenseResult result = this.service.getOcrService().bizLicense("https://res.wx.qq.com/op_res/apCy0YbnEdjYsa_cjW6x3FlpCc20uQ-2BYE7aXnFsrB-ALHZNgdKXhzIUcrRnDoL");
|
" {\n" +
|
||||||
Assertions.assertThat(result).isNotNull();
|
" \"text\": \"微信团队\", \n" +
|
||||||
System.out.println(result);
|
" \"pos\": {\n" +
|
||||||
}
|
" \"left_top\": {\n" +
|
||||||
|
" \"x\": 670, \n" +
|
||||||
@Test
|
" \"y\": 516\n" +
|
||||||
public void testBizLicense2() throws Exception {
|
" }, \n" +
|
||||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg");
|
" \"right_top\": {\n" +
|
||||||
File tempFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), TestConstants.FILE_JPG);
|
" \"x\": 762, \n" +
|
||||||
final WxOcrBizLicenseResult result = this.service.getOcrService().bizLicense(tempFile);
|
" \"y\": 517\n" +
|
||||||
Assertions.assertThat(result).isNotNull();
|
" }, \n" +
|
||||||
System.out.println(result);
|
" \"right_bottom\": {\n" +
|
||||||
}
|
" \"x\": 762, \n" +
|
||||||
|
" \"y\": 532\n" +
|
||||||
@Test
|
" }, \n" +
|
||||||
public void testComm() throws WxErrorException {
|
" \"left_bottom\": {\n" +
|
||||||
final WxOcrCommResult result = this.service.getOcrService().comm("https://res.wx.qq.com/op_res/apCy0YbnEdjYsa_cjW6x3FlpCc20uQ-2BYE7aXnFsrB-ALHZNgdKXhzIUcrRnDoL");
|
" \"x\": 670, \n" +
|
||||||
Assertions.assertThat(result).isNotNull();
|
" \"y\": 531\n" +
|
||||||
System.out.println(result);
|
" }\n" +
|
||||||
}
|
" }\n" +
|
||||||
|
" }\n" +
|
||||||
@Test
|
" ], \n" +
|
||||||
public void testComm2() throws Exception {
|
" \"img_size\": { //图片大小\n" +
|
||||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg");
|
" \"w\": 1280, \n" +
|
||||||
File tempFile = FileUtils.createTmpFile(inputStream, UUID.randomUUID().toString(), TestConstants.FILE_JPG);
|
" \"h\": 720\n" +
|
||||||
final WxOcrCommResult result = this.service.getOcrService().comm(tempFile);
|
" }\n" +
|
||||||
Assertions.assertThat(result).isNotNull();
|
"}";
|
||||||
System.out.println(result);
|
Mockito.when(wxService.post(Matchers.anyString(), Matchers.anyString())).thenReturn(returnJson);
|
||||||
}
|
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
||||||
|
|
||||||
private InputStream getImageStream(String url) {
|
final WxOcrCommResult result = wxMpOcrService.comm("abc");
|
||||||
try {
|
Assertions.assertThat(result).isNotNull();
|
||||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
System.out.println(result);
|
||||||
connection.setReadTimeout(5000);
|
|
||||||
connection.setConnectTimeout(5000);
|
|
||||||
connection.setRequestMethod("GET");
|
|
||||||
if (HttpURLConnection.HTTP_OK == connection.getResponseCode()) {
|
|
||||||
return connection.getInputStream();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.out.println("获取网络图片出现异常,图片路径为:" + url);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class MockTest {
|
|
||||||
private final WeChatOfficialAccountService wxService = Mockito.mock(WeChatOfficialAccountService.class);
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIdCard() throws Exception {
|
|
||||||
String returnJson = "{\"type\":\"Back\",\"name\":\"张三\",\"id\":\"110101199909090099\",\"valid_date\":\"20110101-20210201\"}";
|
|
||||||
|
|
||||||
Mockito.when(wxService.post(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(returnJson);
|
|
||||||
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
|
||||||
|
|
||||||
final WxOcrIdCardResult result = wxMpOcrService.idCard("abc");
|
|
||||||
Assertions.assertThat(result).isNotNull();
|
|
||||||
System.out.println(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBankCard() throws Exception {
|
|
||||||
String returnJson = "{\"number\":\"24234234345234\"}";
|
|
||||||
|
|
||||||
Mockito.when(wxService.post(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(returnJson);
|
|
||||||
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
|
||||||
|
|
||||||
final WxOcrBankCardResult result = wxMpOcrService.bankCard("abc");
|
|
||||||
Assertions.assertThat(result).isNotNull();
|
|
||||||
System.out.println(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDriving() throws Exception {
|
|
||||||
String returnJson = "{\n" +
|
|
||||||
" \"errcode\": 0,\n" +
|
|
||||||
" \"errmsg\": \"ok\",\n" +
|
|
||||||
" \"plate_num\": \"粤xxxxx\", //车牌号码\n" +
|
|
||||||
" \"vehicle_type\": \"小型普通客车\", //车辆类型\n" +
|
|
||||||
" \"owner\": \"东莞市xxxxx机械厂\", //所有人\n" +
|
|
||||||
" \"addr\": \"广东省东莞市xxxxx号\", //住址\n" +
|
|
||||||
" \"use_character\": \"非营运\", //使用性质\n" +
|
|
||||||
" \"model\": \"江淮牌HFCxxxxxxx\", //品牌型号\n" +
|
|
||||||
" \"vin\": \"LJ166xxxxxxxx51\", //车辆识别代号\n" +
|
|
||||||
" \"engine_num\": \"J3xxxxx3\", //发动机号码\n" +
|
|
||||||
" \"register_date\": \"2018-07-06\", //注册日期\n" +
|
|
||||||
" \"issue_date\": \"2018-07-01\", //发证日期\n" +
|
|
||||||
" \"plate_num_b\": \"粤xxxxx\", //车牌号码\n" +
|
|
||||||
" \"record\": \"441xxxxxx3\", //号牌\n" +
|
|
||||||
" \"passengers_num\": \"7人\", //核定载人数\n" +
|
|
||||||
" \"total_quality\": \"2700kg\", //总质量\n" +
|
|
||||||
" \"prepare_quality\": \"1995kg\", //整备质量\n" +
|
|
||||||
" \"overall_size\": \"4582x1795x1458mm\", //外廓尺寸\n" +
|
|
||||||
" \"card_position_front\": {//卡片正面位置(检测到卡片正面才会返回)\n" +
|
|
||||||
" \"pos\": {\n" +
|
|
||||||
" \"left_top\": {\n" +
|
|
||||||
" \"x\": 119, \n" +
|
|
||||||
" \"y\": 2925\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"right_top\": {\n" +
|
|
||||||
" \"x\": 1435, \n" +
|
|
||||||
" \"y\": 2887\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"right_bottom\": {\n" +
|
|
||||||
" \"x\": 1435, \n" +
|
|
||||||
" \"y\": 3793\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"left_bottom\": {\n" +
|
|
||||||
" \"x\": 119, \n" +
|
|
||||||
" \"y\": 3831\n" +
|
|
||||||
" }\n" +
|
|
||||||
" }\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"card_position_back\": {//卡片反面位置(检测到卡片反面才会返回)\n" +
|
|
||||||
" \"pos\": {\n" +
|
|
||||||
" \"left_top\": {\n" +
|
|
||||||
" \"x\": 1523, \n" +
|
|
||||||
" \"y\": 2849\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"right_top\": {\n" +
|
|
||||||
" \"x\": 2898, \n" +
|
|
||||||
" \"y\": 2887\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"right_bottom\": {\n" +
|
|
||||||
" \"x\": 2927, \n" +
|
|
||||||
" \"y\": 3831\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"left_bottom\": {\n" +
|
|
||||||
" \"x\": 1523, \n" +
|
|
||||||
" \"y\": 3831\n" +
|
|
||||||
" }\n" +
|
|
||||||
" }\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"img_size\": {//图片大小\n" +
|
|
||||||
" \"w\": 3120, \n" +
|
|
||||||
" \"h\": 4208\n" +
|
|
||||||
" }\n" +
|
|
||||||
"}";
|
|
||||||
|
|
||||||
Mockito.when(wxService.post(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(returnJson);
|
|
||||||
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
|
||||||
|
|
||||||
final WxOcrDrivingResult result = wxMpOcrService.driving("abc");
|
|
||||||
Assertions.assertThat(result).isNotNull();
|
|
||||||
System.out.println(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDrivingLicense() throws Exception {
|
|
||||||
String returnJson = "{\n" +
|
|
||||||
" \"errcode\": 0,\n" +
|
|
||||||
" \"errmsg\": \"ok\",\n" +
|
|
||||||
" \"id_num\": \"660601xxxxxxxx1234\", //证号\n" +
|
|
||||||
" \"name\": \"张三\", //姓名\n" +
|
|
||||||
" \"sex\": \"男\", //性别\n" +
|
|
||||||
" \"nationality\": \"中国\", //国籍\n" +
|
|
||||||
" \"address\": \"广东省东莞市xxxxx号\", //住址\n" +
|
|
||||||
" \"birth_date\": \"1990-12-21\", //出生日期\n" +
|
|
||||||
" \"issue_date\": \"2012-12-21\", //初次领证日期\n" +
|
|
||||||
" \"car_class\": \"C1\", //准驾车型\n" +
|
|
||||||
" \"valid_from\": \"2018-07-06\", //有效期限起始日\n" +
|
|
||||||
" \"valid_to\": \"2020-07-01\", //有效期限终止日\n" +
|
|
||||||
" \"official_seal\": \"xx市公安局公安交通管理局\" //印章文字\n" +
|
|
||||||
"}";
|
|
||||||
Mockito.when(wxService.post(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(returnJson);
|
|
||||||
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
|
||||||
|
|
||||||
final WxOcrDrivingLicenseResult result = wxMpOcrService.drivingLicense("abc");
|
|
||||||
Assertions.assertThat(result).isNotNull();
|
|
||||||
System.out.println(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBizLicense() throws Exception {
|
|
||||||
String returnJson = "{\n" +
|
|
||||||
" \"errcode\": 0, \n" +
|
|
||||||
" \"errmsg\": \"ok\", \n" +
|
|
||||||
" \"reg_num\": \"123123\",//注册号\n" +
|
|
||||||
" \"serial\": \"123123\",//编号\n" +
|
|
||||||
" \"legal_representative\": \"张三\", //法定代表人姓名\n" +
|
|
||||||
" \"enterprise_name\": \"XX饮食店\", //企业名称\n" +
|
|
||||||
" \"type_of_organization\": \"个人经营\", //组成形式\n" +
|
|
||||||
" \"address\": \"XX市XX区XX路XX号\", //经营场所/企业住所\n" +
|
|
||||||
" \"type_of_enterprise\": \"xxx\", //公司类型\n" +
|
|
||||||
" \"business_scope\": \"中型餐馆(不含凉菜、不含裱花蛋糕,不含生食海产品)。\", //经营范围\n" +
|
|
||||||
" \"registered_capital\": \"200万\", //注册资本\n" +
|
|
||||||
" \"paid_in_capital\": \"200万\", //实收资本\n" +
|
|
||||||
" \"valid_period\": \"2019年1月1日\", //营业期限\n" +
|
|
||||||
" \"registered_date\": \"2018年1月1日\", //注册日期/成立日期\n" +
|
|
||||||
" \"cert_position\": { //营业执照位置\n" +
|
|
||||||
" \"pos\": {\n" +
|
|
||||||
" \"left_top\": {\n" +
|
|
||||||
" \"x\": 155, \n" +
|
|
||||||
" \"y\": 191\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"right_top\": {\n" +
|
|
||||||
" \"x\": 725, \n" +
|
|
||||||
" \"y\": 157\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"right_bottom\": {\n" +
|
|
||||||
" \"x\": 743, \n" +
|
|
||||||
" \"y\": 512\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"left_bottom\": {\n" +
|
|
||||||
" \"x\": 164, \n" +
|
|
||||||
" \"y\": 525\n" +
|
|
||||||
" }\n" +
|
|
||||||
" }\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"img_size\": { //图片大小\n" +
|
|
||||||
" \"w\": 966, \n" +
|
|
||||||
" \"h\": 728\n" +
|
|
||||||
" }\n" +
|
|
||||||
"}";
|
|
||||||
Mockito.when(wxService.post(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(returnJson);
|
|
||||||
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
|
||||||
|
|
||||||
final WxOcrBizLicenseResult result = wxMpOcrService.bizLicense("abc");
|
|
||||||
Assertions.assertThat(result).isNotNull();
|
|
||||||
System.out.println(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testComm() throws Exception {
|
|
||||||
String returnJson = "{\n" +
|
|
||||||
" \"errcode\": 0, \n" +
|
|
||||||
" \"errmsg\": \"ok\", \n" +
|
|
||||||
" \"items\": [ //识别结果\n" +
|
|
||||||
" {\n" +
|
|
||||||
" \"text\": \"腾讯\", \n" +
|
|
||||||
" \"pos\": {\n" +
|
|
||||||
" \"left_top\": {\n" +
|
|
||||||
" \"x\": 575, \n" +
|
|
||||||
" \"y\": 519\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"right_top\": {\n" +
|
|
||||||
" \"x\": 744, \n" +
|
|
||||||
" \"y\": 519\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"right_bottom\": {\n" +
|
|
||||||
" \"x\": 744, \n" +
|
|
||||||
" \"y\": 532\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"left_bottom\": {\n" +
|
|
||||||
" \"x\": 573, \n" +
|
|
||||||
" \"y\": 532\n" +
|
|
||||||
" }\n" +
|
|
||||||
" }\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" {\n" +
|
|
||||||
" \"text\": \"微信团队\", \n" +
|
|
||||||
" \"pos\": {\n" +
|
|
||||||
" \"left_top\": {\n" +
|
|
||||||
" \"x\": 670, \n" +
|
|
||||||
" \"y\": 516\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"right_top\": {\n" +
|
|
||||||
" \"x\": 762, \n" +
|
|
||||||
" \"y\": 517\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"right_bottom\": {\n" +
|
|
||||||
" \"x\": 762, \n" +
|
|
||||||
" \"y\": 532\n" +
|
|
||||||
" }, \n" +
|
|
||||||
" \"left_bottom\": {\n" +
|
|
||||||
" \"x\": 670, \n" +
|
|
||||||
" \"y\": 531\n" +
|
|
||||||
" }\n" +
|
|
||||||
" }\n" +
|
|
||||||
" }\n" +
|
|
||||||
" ], \n" +
|
|
||||||
" \"img_size\": { //图片大小\n" +
|
|
||||||
" \"w\": 1280, \n" +
|
|
||||||
" \"h\": 720\n" +
|
|
||||||
" }\n" +
|
|
||||||
"}";
|
|
||||||
Mockito.when(wxService.post(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn(returnJson);
|
|
||||||
final WxMpOcrServiceImpl wxMpOcrService = new WxMpOcrServiceImpl(wxService);
|
|
||||||
|
|
||||||
final WxOcrCommResult result = wxMpOcrService.comm("abc");
|
|
||||||
Assertions.assertThat(result).isNotNull();
|
|
||||||
System.out.println(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import org.testng.annotations.Test;
|
|||||||
* @author rememberber
|
* @author rememberber
|
||||||
*/
|
*/
|
||||||
@Test(groups = "userAPI")
|
@Test(groups = "userAPI")
|
||||||
//@Guice(modules = ApiTestModule.class)
|
@Guice(modules = ApiTestModule.class)
|
||||||
public class WxMpShakeServiceImplTest {
|
public class WxMpShakeServiceImplTest {
|
||||||
@Inject
|
@Inject
|
||||||
private WeChatOfficialAccountService wxService;
|
private WeChatOfficialAccountService wxService;
|
||||||
|
@ -7,89 +7,92 @@ import com.ossez.wechat.oa.api.test.ApiTestModule;
|
|||||||
import com.ossez.wechat.oa.bean.wifi.WxMpWifiShopDataResult;
|
import com.ossez.wechat.oa.bean.wifi.WxMpWifiShopDataResult;
|
||||||
import com.ossez.wechat.oa.bean.wifi.WxMpWifiShopListResult;
|
import com.ossez.wechat.oa.bean.wifi.WxMpWifiShopListResult;
|
||||||
import org.assertj.core.api.Assertions;
|
import org.assertj.core.api.Assertions;
|
||||||
import org.mockito.ArgumentMatchers;
|
import org.mockito.Matchers;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.testng.annotations.Guice;
|
import org.testng.annotations.Guice;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import static com.ossez.wechat.common.enums.WxMpApiUrl.Wifi.BIZWIFI_SHOP_GET;
|
import static com.ossez.wechat.common.enums.WxMpApiUrl.Wifi.BIZWIFI_SHOP_GET;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.Matchers.eq;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change to use JUnit 5
|
* <pre>
|
||||||
|
* Created by BinaryWang on 2018/6/10.
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author YuCheng
|
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@Guice(modules = ApiTestModule.class)
|
@Guice(modules = ApiTestModule.class)
|
||||||
public class WxMpWifiServiceImplTest {
|
public class WxMpWifiServiceImplTest {
|
||||||
@Inject
|
@Inject
|
||||||
private WeChatOfficialAccountService wxService;
|
private WeChatOfficialAccountService wxService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListShop() throws WxErrorException {
|
||||||
|
final WxMpWifiShopListResult result = this.wxService.getWifiService().listShop(1, 2);
|
||||||
|
assertThat(result).isNotNull();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetShopWifiInfo() throws WxErrorException {
|
||||||
|
final WxMpWifiShopDataResult wifiInfo = this.wxService.getWifiService().getShopWifiInfo(123);
|
||||||
|
assertThat(wifiInfo).isNotNull();
|
||||||
|
System.out.println(wifiInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateShopWifiInfo() throws WxErrorException {
|
||||||
|
final boolean result = this.wxService.getWifiService()
|
||||||
|
.updateShopWifiInfo(123, "123", "345", null);
|
||||||
|
Assertions.assertThat(result).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MockTest {
|
||||||
|
private WeChatOfficialAccountService wxService = Mockito.mock(WeChatOfficialAccountService.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListShop() throws WxErrorException {
|
public void testGetShopWifiInfo() throws Exception {
|
||||||
final WxMpWifiShopListResult result = this.wxService.getWifiService().listShop(1, 2);
|
String returnJson = "{\n" +
|
||||||
assertThat(result).isNotNull();
|
" \"errcode\": 0,\n" +
|
||||||
System.out.println(result);
|
" \"data\": {\n" +
|
||||||
}
|
" \"shop_name\": \"南山店\",\n" +
|
||||||
|
" \"ssid\": \" WX123\",\n" +
|
||||||
@Test
|
" \"ssid_list\": [\n" +
|
||||||
public void testGetShopWifiInfo() throws WxErrorException {
|
" \"WX123\",\n" +
|
||||||
final WxMpWifiShopDataResult wifiInfo = this.wxService.getWifiService().getShopWifiInfo(123);
|
" \"WX456\"\n" +
|
||||||
assertThat(wifiInfo).isNotNull();
|
" ],\n" +
|
||||||
System.out.println(wifiInfo);
|
" \"ssid_password_list\": [\n" +
|
||||||
}
|
" {\n" +
|
||||||
|
" \"ssid\": \"WX123\",\n" +
|
||||||
@Test
|
" \"password\": \"123456789\"\n" +
|
||||||
public void testUpdateShopWifiInfo() throws WxErrorException {
|
" },\n" +
|
||||||
final boolean result = this.wxService.getWifiService()
|
" {\n" +
|
||||||
.updateShopWifiInfo(123, "123", "345", null);
|
" \"ssid\": \"WX456\",\n" +
|
||||||
Assertions.assertThat(result).isTrue();
|
" \"password\": \"21332465dge\"\n" +
|
||||||
}
|
" }\n" +
|
||||||
|
" ],\n" +
|
||||||
public static class MockTest {
|
" \"password\": \"123456789\",\n" +
|
||||||
private WeChatOfficialAccountService wxService = Mockito.mock(WeChatOfficialAccountService.class);
|
" \"protocol_type\": 4,\n" +
|
||||||
|
" \"ap_count\": 2,\n" +
|
||||||
@Test
|
" \"template_id\": 1,\n" +
|
||||||
public void testGetShopWifiInfo() throws Exception {
|
" \"homepage_url\": \"http://www.weixin.qq.com/\",\n" +
|
||||||
String returnJson = "{\n" +
|
" \"bar_type\": 1,\n" +
|
||||||
" \"errcode\": 0,\n" +
|
" \"sid\":\"\",\n" +
|
||||||
" \"data\": {\n" +
|
" \"poi_id\":\"285633617\"\n" +
|
||||||
" \"shop_name\": \"南山店\",\n" +
|
" }\n" +
|
||||||
" \"ssid\": \" WX123\",\n" +
|
"}";
|
||||||
" \"ssid_list\": [\n" +
|
|
||||||
" \"WX123\",\n" +
|
Mockito.when(wxService.post(Matchers.eq(BIZWIFI_SHOP_GET), Matchers.anyString())).thenReturn(returnJson);
|
||||||
" \"WX456\"\n" +
|
Mockito.when(wxService.getWifiService()).thenReturn(new WxMpWifiServiceImpl(wxService));
|
||||||
" ],\n" +
|
|
||||||
" \"ssid_password_list\": [\n" +
|
final WxMpWifiShopDataResult wifiInfo = this.wxService.getWifiService().getShopWifiInfo(123);
|
||||||
" {\n" +
|
assertThat(wifiInfo).isNotNull();
|
||||||
" \"ssid\": \"WX123\",\n" +
|
System.out.println(wifiInfo);
|
||||||
" \"password\": \"123456789\"\n" +
|
|
||||||
" },\n" +
|
|
||||||
" {\n" +
|
|
||||||
" \"ssid\": \"WX456\",\n" +
|
|
||||||
" \"password\": \"21332465dge\"\n" +
|
|
||||||
" }\n" +
|
|
||||||
" ],\n" +
|
|
||||||
" \"password\": \"123456789\",\n" +
|
|
||||||
" \"protocol_type\": 4,\n" +
|
|
||||||
" \"ap_count\": 2,\n" +
|
|
||||||
" \"template_id\": 1,\n" +
|
|
||||||
" \"homepage_url\": \"http://www.weixin.qq.com/\",\n" +
|
|
||||||
" \"bar_type\": 1,\n" +
|
|
||||||
" \"sid\":\"\",\n" +
|
|
||||||
" \"poi_id\":\"285633617\"\n" +
|
|
||||||
" }\n" +
|
|
||||||
"}";
|
|
||||||
|
|
||||||
Mockito.when(wxService.post(ArgumentMatchers.eq(BIZWIFI_SHOP_GET), ArgumentMatchers.anyString())).thenReturn(returnJson);
|
|
||||||
Mockito.when(wxService.getWifiService()).thenReturn(new WxMpWifiServiceImpl(wxService));
|
|
||||||
|
|
||||||
final WxMpWifiShopDataResult wifiInfo = this.wxService.getWifiService().getShopWifiInfo(123);
|
|
||||||
assertThat(wifiInfo).isNotNull();
|
|
||||||
System.out.println(wifiInfo);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,59 +1,52 @@
|
|||||||
package com.ossez.wechat.oa.api.test;
|
package com.ossez.wechat.oa.api.test;
|
||||||
|
|
||||||
import com.google.inject.Binder;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
import com.ossez.wechat.common.exception.WxRuntimeException;
|
|
||||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatMsgService;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatOfficialAccountServiceOkHttp;
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
|
||||||
import org.dom4j.Document;
|
|
||||||
import org.dom4j.DocumentException;
|
|
||||||
import org.dom4j.io.SAXReader;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
|
import com.ossez.wechat.common.exception.WxRuntimeException;
|
||||||
|
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||||
|
import com.ossez.wechat.oa.api.impl.okhttp.WeChatOfficialAccountServiceOkHttp;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.google.inject.Binder;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
import com.thoughtworks.xstream.XStream;
|
||||||
|
import com.ossez.wechat.common.util.xml.XStreamInitializer;
|
||||||
|
import com.ossez.wechat.common.config.ConfigStorage;
|
||||||
|
|
||||||
public class ApiTestModule implements Module {
|
public class ApiTestModule implements Module {
|
||||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||||
private static final String TEST_CONFIG_XML = "test-config.xml";
|
private static final String TEST_CONFIG_XML = "test-config.xml";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(Binder binder) {
|
public void configure(Binder binder) {
|
||||||
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) {
|
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) {
|
||||||
|
if (inputStream == null) {
|
||||||
|
throw new WxRuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
|
||||||
|
}
|
||||||
|
|
||||||
if (ObjectUtils.isEmpty(inputStream)) {
|
TestConfigStorage config = this.fromXml(TestConfigStorage.class, inputStream);
|
||||||
throw new WxRuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
|
config.setAccessTokenLock(new ReentrantLock());
|
||||||
}
|
WeChatOfficialAccountService mpService = new WeChatOfficialAccountServiceOkHttp();
|
||||||
|
|
||||||
|
mpService.setWxMpConfigStorage(config);
|
||||||
|
mpService.addConfigStorage("another", config);
|
||||||
|
|
||||||
// Init WeChat config for testing
|
binder.bind(ConfigStorage.class).toInstance(config);
|
||||||
Document document = new SAXReader().read(inputStream);
|
binder.bind(WeChatOfficialAccountService.class).toInstance(mpService);
|
||||||
TestConfigStorage config = new TestConfigStorage();
|
} catch (IOException e) {
|
||||||
config.setAppId(document.getRootElement().element("appId").getText());
|
this.log.error(e.getMessage(), e);
|
||||||
config.setSecret(document.getRootElement().element("secret").getText());
|
|
||||||
config.setToken(document.getRootElement().element("token").getText());
|
|
||||||
config.setOpenid(document.getRootElement().element("openid").getText());
|
|
||||||
config.setAccessTokenLock(new ReentrantLock());
|
|
||||||
|
|
||||||
// Init WeChat Service
|
|
||||||
WeChatOfficialAccountService weChatOfficialAccountService = new WeChatOfficialAccountServiceOkHttp();
|
|
||||||
weChatOfficialAccountService.setWxMpConfigStorage(config);
|
|
||||||
weChatOfficialAccountService.addConfigStorage("another", config);
|
|
||||||
|
|
||||||
// Init WeChatMsgService
|
|
||||||
WeChatMsgService weChatMsgService = new WeChatMsgService(weChatOfficialAccountService);
|
|
||||||
|
|
||||||
binder.bind(TestConfigStorage.class).toInstance(config);
|
|
||||||
binder.bind(WeChatOfficialAccountService.class).toInstance(weChatOfficialAccountService);
|
|
||||||
binder.bind(WeChatMsgService.class).toInstance(weChatMsgService);
|
|
||||||
} catch (IOException e) {
|
|
||||||
this.log.error(e.getMessage(), e);
|
|
||||||
} catch (DocumentException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private <T> T fromXml(Class<T> clazz, InputStream is) {
|
||||||
|
XStream xstream = XStreamInitializer.getInstance();
|
||||||
|
xstream.alias("xml", clazz);
|
||||||
|
xstream.processAnnotations(clazz);
|
||||||
|
return (T) xstream.fromXML(is);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
package com.ossez.wechat.oa.api.test;
|
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Guice;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.ossez.wechat.common.exception.WxRuntimeException;
|
|
||||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatDataCubeService;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatMenuService;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatMsgService;
|
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatOfficialAccountServiceOkHttp;
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
|
||||||
import org.dom4j.Document;
|
|
||||||
import org.dom4j.DocumentException;
|
|
||||||
import org.dom4j.io.SAXReader;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Init Guice DI
|
|
||||||
*
|
|
||||||
* @author YuCheng
|
|
||||||
*/
|
|
||||||
public class TestBase {
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(TestBase.class);
|
|
||||||
private static final String TEST_CONFIG_XML = "test-config.xml";
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public void setup() {
|
|
||||||
injector.injectMembers(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Injector injector = Guice.createInjector(new AbstractModule() {
|
|
||||||
@Override
|
|
||||||
public void configure() {
|
|
||||||
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) {
|
|
||||||
|
|
||||||
if (ObjectUtils.isEmpty(inputStream)) {
|
|
||||||
throw new WxRuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Init WeChat config for testing
|
|
||||||
Document document = new SAXReader().read(inputStream);
|
|
||||||
TestConfigStorage config = new TestConfigStorage();
|
|
||||||
config.setAppId(document.getRootElement().element("appId").getText());
|
|
||||||
config.setSecret(document.getRootElement().element("secret").getText());
|
|
||||||
config.setToken(document.getRootElement().element("token").getText());
|
|
||||||
config.setOpenid(document.getRootElement().element("openid").getText());
|
|
||||||
config.setAccessTokenLock(new ReentrantLock());
|
|
||||||
|
|
||||||
// Init WeChat Service
|
|
||||||
WeChatOfficialAccountService weChatOfficialAccountService = new WeChatOfficialAccountServiceOkHttp();
|
|
||||||
weChatOfficialAccountService.setWxMpConfigStorage(config);
|
|
||||||
weChatOfficialAccountService.addConfigStorage("another", config);
|
|
||||||
|
|
||||||
// Init WeChatMsgService
|
|
||||||
WeChatMsgService weChatMsgService = new WeChatMsgService(weChatOfficialAccountService);
|
|
||||||
WeChatDataCubeService weChatDataCubeService = new WeChatDataCubeService(weChatOfficialAccountService);
|
|
||||||
WeChatMenuService weChatMenuService = new WeChatMenuService(weChatOfficialAccountService);
|
|
||||||
|
|
||||||
bind(TestConfigStorage.class).toInstance(config);
|
|
||||||
bind(WeChatOfficialAccountService.class).toInstance(weChatOfficialAccountService);
|
|
||||||
bind(WeChatMsgService.class).toInstance(weChatMsgService);
|
|
||||||
bind(WeChatDataCubeService.class).toInstance(weChatDataCubeService);
|
|
||||||
bind(WeChatMenuService.class).toInstance(weChatMenuService);
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
} catch (DocumentException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -6,6 +6,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
|||||||
|
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
|
|
||||||
|
@XStreamAlias("xml")
|
||||||
public class TestConfigStorage extends DefaultConfigStorage {
|
public class TestConfigStorage extends DefaultConfigStorage {
|
||||||
|
|
||||||
private String openid;
|
private String openid;
|
||||||
|
@ -10,7 +10,7 @@ public class WxMpKefuMessageTest {
|
|||||||
public void testTextReply() {
|
public void testTextReply() {
|
||||||
WxMpKefuMessage reply = new WxMpKefuMessage();
|
WxMpKefuMessage reply = new WxMpKefuMessage();
|
||||||
reply.setToUser("OPENID");
|
reply.setToUser("OPENID");
|
||||||
reply.setMsgType(WeChatConstant.MsgType.TEXT);
|
reply.setMsgType(WeChatConstant.KefuMsgType.TEXT);
|
||||||
reply.setContent("sfsfdsdf");
|
reply.setContent("sfsfdsdf");
|
||||||
Assert
|
Assert
|
||||||
.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}");
|
.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}");
|
||||||
@ -25,7 +25,7 @@ public class WxMpKefuMessageTest {
|
|||||||
public void testImageReply() {
|
public void testImageReply() {
|
||||||
WxMpKefuMessage reply = new WxMpKefuMessage();
|
WxMpKefuMessage reply = new WxMpKefuMessage();
|
||||||
reply.setToUser("OPENID");
|
reply.setToUser("OPENID");
|
||||||
reply.setMsgType(WeChatConstant.MsgType.IMAGE);
|
reply.setMsgType(WeChatConstant.KefuMsgType.IMAGE);
|
||||||
reply.setMediaId("MEDIA_ID");
|
reply.setMediaId("MEDIA_ID");
|
||||||
Assert.assertEquals(reply.toJson(),
|
Assert.assertEquals(reply.toJson(),
|
||||||
"{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}");
|
"{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}");
|
||||||
@ -40,7 +40,7 @@ public class WxMpKefuMessageTest {
|
|||||||
public void testVoiceReply() {
|
public void testVoiceReply() {
|
||||||
WxMpKefuMessage reply = new WxMpKefuMessage();
|
WxMpKefuMessage reply = new WxMpKefuMessage();
|
||||||
reply.setToUser("OPENID");
|
reply.setToUser("OPENID");
|
||||||
reply.setMsgType(WeChatConstant.MsgType.VOICE);
|
reply.setMsgType(WeChatConstant.KefuMsgType.VOICE);
|
||||||
reply.setMediaId("MEDIA_ID");
|
reply.setMediaId("MEDIA_ID");
|
||||||
Assert.assertEquals(reply.toJson(),
|
Assert.assertEquals(reply.toJson(),
|
||||||
"{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}");
|
"{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}");
|
||||||
@ -55,7 +55,7 @@ public class WxMpKefuMessageTest {
|
|||||||
public void testVideoReply() {
|
public void testVideoReply() {
|
||||||
WxMpKefuMessage reply = new WxMpKefuMessage();
|
WxMpKefuMessage reply = new WxMpKefuMessage();
|
||||||
reply.setToUser("OPENID");
|
reply.setToUser("OPENID");
|
||||||
reply.setMsgType(WeChatConstant.MsgType.VIDEO);
|
reply.setMsgType(WeChatConstant.KefuMsgType.VIDEO);
|
||||||
reply.setMediaId("MEDIA_ID");
|
reply.setMediaId("MEDIA_ID");
|
||||||
reply.setThumbMediaId("MEDIA_ID");
|
reply.setThumbMediaId("MEDIA_ID");
|
||||||
reply.setTitle("TITLE");
|
reply.setTitle("TITLE");
|
||||||
@ -74,7 +74,7 @@ public class WxMpKefuMessageTest {
|
|||||||
public void testMusicReply() {
|
public void testMusicReply() {
|
||||||
WxMpKefuMessage reply = new WxMpKefuMessage();
|
WxMpKefuMessage reply = new WxMpKefuMessage();
|
||||||
reply.setToUser("OPENID");
|
reply.setToUser("OPENID");
|
||||||
reply.setMsgType(WeChatConstant.MsgType.MUSIC);
|
reply.setMsgType(WeChatConstant.KefuMsgType.MUSIC);
|
||||||
reply.setThumbMediaId("MEDIA_ID");
|
reply.setThumbMediaId("MEDIA_ID");
|
||||||
reply.setDescription("DESCRIPTION");
|
reply.setDescription("DESCRIPTION");
|
||||||
reply.setTitle("TITLE");
|
reply.setTitle("TITLE");
|
||||||
@ -100,7 +100,7 @@ public class WxMpKefuMessageTest {
|
|||||||
public void testNewsReply() {
|
public void testNewsReply() {
|
||||||
WxMpKefuMessage reply = new WxMpKefuMessage();
|
WxMpKefuMessage reply = new WxMpKefuMessage();
|
||||||
reply.setToUser("OPENID");
|
reply.setToUser("OPENID");
|
||||||
reply.setMsgType(WeChatConstant.MsgType.NEWS);
|
reply.setMsgType(WeChatConstant.KefuMsgType.NEWS);
|
||||||
|
|
||||||
WxMpKefuMessage.WxArticle article1 = new WxMpKefuMessage.WxArticle();
|
WxMpKefuMessage.WxArticle article1 = new WxMpKefuMessage.WxArticle();
|
||||||
article1.setUrl("URL");
|
article1.setUrl("URL");
|
||||||
|
@ -1,32 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<configuration>
|
||||||
<configuration debug="true">
|
|
||||||
<timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>
|
|
||||||
|
|
||||||
<appender name="STDOUT"
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
class="ch.qos.logback.core.ConsoleAppender">
|
<encoder>
|
||||||
<!-- encoders are assigned by default the type
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %replace(%caller{1}){'Caller', ''} - %msg%n</pattern>
|
||||||
ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
|
</encoder>
|
||||||
<encoder>
|
</appender>
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
|
||||||
|
|
||||||
</encoder>
|
|
||||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
|
||||||
<Pattern>
|
|
||||||
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
|
|
||||||
</Pattern>
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- LOGGER -->
|
|
||||||
<logger name="com.ossez" level="DEBUG"/>
|
|
||||||
<logger name="org.apache" level="INFO"/>
|
|
||||||
<logger name="org.hibernate" level="INFO"/>
|
|
||||||
<logger name="org.springframework" level="INFO"/>
|
|
||||||
|
|
||||||
<!-- ROOT AND APPENDER -->
|
|
||||||
<root level="debug">
|
|
||||||
<appender-ref ref="STDOUT"/>
|
|
||||||
</root>
|
|
||||||
|
|
||||||
|
<root level="debug">
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
<xml>
|
|
||||||
<appId>***</appId>
|
|
||||||
<secret>***</secret>
|
|
||||||
<token>***</token>
|
|
||||||
<aesKey>公众号EncodingAESKey</aesKey>
|
|
||||||
<accessToken>可以不填写</accessToken>
|
|
||||||
<expiresTime>可以不填写</expiresTime>
|
|
||||||
<openid>o9phd5jz_We8mPs1ovmyjud97Ock</openid>
|
|
||||||
<partnerId>微信商户平台ID</partnerId>
|
|
||||||
<partnerKey>商户平台设置的API密钥</partnerKey>
|
|
||||||
<keyPath>商户平台的证书文件地址</keyPath>
|
|
||||||
<templateId>模版消息的模版ID</templateId>
|
|
||||||
<oauth2redirectUri>网页授权获取用户信息回调地址</oauth2redirectUri>
|
|
||||||
<qrconnectRedirectUrl>网页应用授权登陆回调地址</qrconnectRedirectUrl>
|
|
||||||
<kfAccount>完整客服账号,格式为:账号前缀@公众号微信号</kfAccount>
|
|
||||||
</xml>
|
|
268
open/pom.xml
268
open/pom.xml
@ -1,147 +1,147 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project
|
<project
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0">
|
xmlns="http://maven.apache.org/POM/4.0.0">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.ossez.wechat</groupId>
|
||||||
|
<artifactId>wechat-j-open</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|
||||||
|
<parent>
|
||||||
<groupId>com.ossez.wechat</groupId>
|
<groupId>com.ossez.wechat</groupId>
|
||||||
<artifactId>wechat-j-open</artifactId>
|
<artifactId>wechat-j</artifactId>
|
||||||
<packaging>jar</packaging>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<name>WeChat Java Open</name>
|
||||||
|
<description>WeChat Open Java SDK</description>
|
||||||
|
|
||||||
|
<developers>
|
||||||
|
</developers>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ossez.wechat</groupId>
|
||||||
|
<artifactId>wechat-j-common</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ossez.wechat</groupId>
|
||||||
|
<artifactId>wechat-j-oa</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ossez.wechat</groupId>
|
||||||
|
<artifactId>wechat-j-mp</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.github.binarywang</groupId>-->
|
||||||
|
<!-- <artifactId>weixin-java-miniapp</artifactId>-->
|
||||||
|
<!-- <version>${project.version}</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jodd</groupId>
|
||||||
|
<artifactId>jodd-http</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<parent>
|
<dependency>
|
||||||
<groupId>com.ossez.wechat</groupId>
|
<groupId>org.testng</groupId>
|
||||||
<artifactId>wechat-j</artifactId>
|
<artifactId>testng</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<scope>test</scope>
|
||||||
</parent>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.inject</groupId>
|
||||||
|
<artifactId>guice</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-server</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-servlet</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>joda-time</groupId>
|
||||||
|
<artifactId>joda-time</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>redis.clients</groupId>
|
||||||
|
<artifactId>jedis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<name>WeChat Java Open</name>
|
<build>
|
||||||
<description>WeChat Open Java SDK</description>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<suiteXmlFiles>
|
||||||
|
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
|
||||||
|
</suiteXmlFiles>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<developers>
|
<profiles>
|
||||||
</developers>
|
<profile>
|
||||||
|
<id>native-image</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>false</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
|
||||||
<dependencies>
|
<build>
|
||||||
<dependency>
|
|
||||||
<groupId>com.ossez.wechat</groupId>
|
|
||||||
<artifactId>wechat-j-common</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ossez.wechat</groupId>
|
|
||||||
<artifactId>wechat-j-oa</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ossez.wechat</groupId>
|
|
||||||
<artifactId>wechat-j-mp</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.github.binarywang</groupId>-->
|
|
||||||
<!-- <artifactId>weixin-java-miniapp</artifactId>-->
|
|
||||||
<!-- <version>${project.version}</version>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jodd</groupId>
|
|
||||||
<artifactId>jodd-http</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.testng</groupId>
|
|
||||||
<artifactId>testng</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.inject</groupId>
|
|
||||||
<artifactId>guice</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
|
||||||
<artifactId>jetty-server</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
|
||||||
<artifactId>jetty-servlet</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>joda-time</groupId>
|
|
||||||
<artifactId>joda-time</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>redis.clients</groupId>
|
|
||||||
<artifactId>jedis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-classic</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.redisson</groupId>
|
|
||||||
<artifactId>redisson</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.data</groupId>
|
|
||||||
<artifactId>spring-data-redis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<version>3.5.1</version>
|
||||||
<suiteXmlFiles>
|
<configuration>
|
||||||
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
|
<annotationProcessors>
|
||||||
</suiteXmlFiles>
|
com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||||
</configuration>
|
</annotationProcessors>
|
||||||
</plugin>
|
<annotationProcessorPaths>
|
||||||
|
<path>
|
||||||
|
<groupId>com.github.binarywang</groupId>
|
||||||
|
<artifactId>weixin-graal</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</path>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
</profile>
|
||||||
<profiles>
|
</profiles>
|
||||||
<profile>
|
|
||||||
<id>native-image</id>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>false</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.5.1</version>
|
|
||||||
<configuration>
|
|
||||||
<annotationProcessors>
|
|
||||||
com.github.binarywang.wx.graal.GraalProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor,lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
|
||||||
</annotationProcessors>
|
|
||||||
<annotationProcessorPaths>
|
|
||||||
<path>
|
|
||||||
<groupId>com.github.binarywang</groupId>
|
|
||||||
<artifactId>weixin-graal</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</path>
|
|
||||||
</annotationProcessorPaths>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
54
pom.xml
54
pom.xml
@ -158,7 +158,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.inject</groupId>
|
<groupId>com.google.inject</groupId>
|
||||||
<artifactId>guice</artifactId>
|
<artifactId>guice</artifactId>
|
||||||
<version>5.1.0</version>
|
<version>4.2.3</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -263,6 +263,7 @@
|
|||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- LOGGING WITH SELF4J AND LOG4J2 -->
|
<!-- LOGGING WITH SELF4J AND LOG4J2 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
@ -300,11 +301,6 @@
|
|||||||
<groupId>com.squareup.retrofit2</groupId>
|
<groupId>com.squareup.retrofit2</groupId>
|
||||||
<artifactId>converter-gson</artifactId>
|
<artifactId>converter-gson</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.inject</groupId>
|
|
||||||
<artifactId>guice</artifactId>
|
|
||||||
<version>5.1.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- JSON -->
|
<!-- JSON -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -325,24 +321,12 @@
|
|||||||
<version>5.9.2</version>
|
<version>5.9.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.testng</groupId>
|
|
||||||
<artifactId>testng</artifactId>
|
|
||||||
<version>7.7.1</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.assertj</groupId>
|
<groupId>org.assertj</groupId>
|
||||||
<artifactId>assertj-core</artifactId>
|
<artifactId>assertj-core</artifactId>
|
||||||
<version>3.24.1</version>
|
<version>3.24.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.mockito</groupId>
|
|
||||||
<artifactId>mockito-junit-jupiter</artifactId>
|
|
||||||
<version>5.3.1</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<!--/ TEST -->
|
<!--/ TEST -->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -479,23 +463,23 @@
|
|||||||
<release>11</release>
|
<release>11</release>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- <plugin>-->
|
<plugin>
|
||||||
<!-- <groupId>org.apache.maven.plugins</groupId>-->
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<!-- <artifactId>maven-gpg-plugin</artifactId>-->
|
<artifactId>maven-gpg-plugin</artifactId>
|
||||||
<!-- <version>3.0.1</version>-->
|
<version>3.0.1</version>
|
||||||
<!-- <executions>-->
|
<executions>
|
||||||
<!-- <execution>-->
|
<execution>
|
||||||
<!-- <id>sign-artifacts</id>-->
|
<id>sign-artifacts</id>
|
||||||
<!-- <phase>verify</phase>-->
|
<phase>verify</phase>
|
||||||
<!-- <goals>-->
|
<goals>
|
||||||
<!-- <goal>sign</goal>-->
|
<goal>sign</goal>
|
||||||
<!-- </goals>-->
|
</goals>
|
||||||
<!-- <configuration>-->
|
<configuration>
|
||||||
<!-- <passphraseServerId>ossez</passphraseServerId>-->
|
<passphraseServerId>ossez</passphraseServerId>
|
||||||
<!-- </configuration>-->
|
</configuration>
|
||||||
<!-- </execution>-->
|
</execution>
|
||||||
<!-- </executions>-->
|
</executions>
|
||||||
<!-- </plugin>-->
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
11
work/pom.xml
11
work/pom.xml
@ -43,7 +43,16 @@
|
|||||||
<groupId>org.redisson</groupId>
|
<groupId>org.redisson</groupId>
|
||||||
<artifactId>redisson</artifactId>
|
<artifactId>redisson</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.testng</groupId>
|
||||||
|
<artifactId>testng</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-all</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.inject</groupId>
|
<groupId>com.google.inject</groupId>
|
||||||
<artifactId>guice</artifactId>
|
<artifactId>guice</artifactId>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ossez.wechat.wecom.api;
|
package com.ossez.wechat.wecom.api;
|
||||||
|
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenu;
|
import com.ossez.wechat.common.bean.menu.WxMenu;
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.ossez.wechat.wecom.api.impl;
|
package com.ossez.wechat.wecom.api.impl;
|
||||||
|
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenu;
|
import com.ossez.wechat.common.bean.menu.WxMenu;
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
import com.ossez.wechat.wecom.api.WxCpMenuService;
|
import com.ossez.wechat.wecom.api.WxCpMenuService;
|
||||||
import com.ossez.wechat.wecom.api.WxCpService;
|
import com.ossez.wechat.wecom.api.WxCpService;
|
||||||
|
@ -16,8 +16,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.ossez.wechat.common.constant.WeChatConstant.MsgType.TASKCARD;
|
import static com.ossez.wechat.common.constant.WeChatConstant.KefuMsgType.TASKCARD;
|
||||||
import static com.ossez.wechat.common.constant.WeChatConstant.MsgType.TEMPLATE_CARD;
|
import static com.ossez.wechat.common.constant.WeChatConstant.KefuMsgType.TEMPLATE_CARD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息.
|
* 消息.
|
||||||
|
@ -18,7 +18,7 @@ public final class FileBuilder extends BaseBuilder<FileBuilder> {
|
|||||||
* Instantiates a new File builder.
|
* Instantiates a new File builder.
|
||||||
*/
|
*/
|
||||||
public FileBuilder() {
|
public FileBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.FILE;
|
this.msgType = WeChatConstant.KefuMsgType.FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,7 @@ public final class ImageBuilder extends BaseBuilder<ImageBuilder> {
|
|||||||
* Instantiates a new Image builder.
|
* Instantiates a new Image builder.
|
||||||
*/
|
*/
|
||||||
public ImageBuilder() {
|
public ImageBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.IMAGE;
|
this.msgType = WeChatConstant.KefuMsgType.IMAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,7 @@ public class MarkdownMsgBuilder extends BaseBuilder<MarkdownMsgBuilder> {
|
|||||||
* Instantiates a new Markdown msg builder.
|
* Instantiates a new Markdown msg builder.
|
||||||
*/
|
*/
|
||||||
public MarkdownMsgBuilder() {
|
public MarkdownMsgBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.MARKDOWN;
|
this.msgType = WeChatConstant.KefuMsgType.MARKDOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,7 @@ public class MiniProgramNoticeMsgBuilder extends BaseBuilder<MiniProgramNoticeMs
|
|||||||
* Instantiates a new Mini program notice msg builder.
|
* Instantiates a new Mini program notice msg builder.
|
||||||
*/
|
*/
|
||||||
public MiniProgramNoticeMsgBuilder() {
|
public MiniProgramNoticeMsgBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.MINIPROGRAM_NOTICE;
|
this.msgType = WeChatConstant.KefuMsgType.MINIPROGRAM_NOTICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@ public final class MpnewsBuilder extends BaseBuilder<MpnewsBuilder> {
|
|||||||
* Instantiates a new Mpnews builder.
|
* Instantiates a new Mpnews builder.
|
||||||
*/
|
*/
|
||||||
public MpnewsBuilder() {
|
public MpnewsBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.MPNEWS;
|
this.msgType = WeChatConstant.KefuMsgType.MPNEWS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,7 @@ public final class NewsBuilder extends BaseBuilder<NewsBuilder> {
|
|||||||
* Instantiates a new News builder.
|
* Instantiates a new News builder.
|
||||||
*/
|
*/
|
||||||
public NewsBuilder() {
|
public NewsBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.NEWS;
|
this.msgType = WeChatConstant.KefuMsgType.NEWS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,7 @@ public class TaskCardBuilder extends BaseBuilder<TaskCardBuilder> {
|
|||||||
* Instantiates a new Task card builder.
|
* Instantiates a new Task card builder.
|
||||||
*/
|
*/
|
||||||
public TaskCardBuilder() {
|
public TaskCardBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.TASKCARD;
|
this.msgType = WeChatConstant.KefuMsgType.TASKCARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,7 +182,7 @@ public class TemplateCardBuilder extends BaseBuilder<TemplateCardBuilder> {
|
|||||||
* Instantiates a new Template card builder.
|
* Instantiates a new Template card builder.
|
||||||
*/
|
*/
|
||||||
public TemplateCardBuilder() {
|
public TemplateCardBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.TEMPLATE_CARD;
|
this.msgType = WeChatConstant.KefuMsgType.TEMPLATE_CARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,7 @@ public final class TextBuilder extends BaseBuilder<TextBuilder> {
|
|||||||
* Instantiates a new Text builder.
|
* Instantiates a new Text builder.
|
||||||
*/
|
*/
|
||||||
public TextBuilder() {
|
public TextBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.TEXT;
|
this.msgType = WeChatConstant.KefuMsgType.TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,7 @@ public class TextCardBuilder extends BaseBuilder<TextCardBuilder> {
|
|||||||
* Instantiates a new Text card builder.
|
* Instantiates a new Text card builder.
|
||||||
*/
|
*/
|
||||||
public TextCardBuilder() {
|
public TextCardBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.TEXTCARD;
|
this.msgType = WeChatConstant.KefuMsgType.TEXTCARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,7 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder> {
|
|||||||
* Instantiates a new Video builder.
|
* Instantiates a new Video builder.
|
||||||
*/
|
*/
|
||||||
public VideoBuilder() {
|
public VideoBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.VIDEO;
|
this.msgType = WeChatConstant.KefuMsgType.VIDEO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,7 @@ public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> {
|
|||||||
* Instantiates a new Voice builder.
|
* Instantiates a new Voice builder.
|
||||||
*/
|
*/
|
||||||
public VoiceBuilder() {
|
public VoiceBuilder() {
|
||||||
this.msgType = WeChatConstant.MsgType.VOICE;
|
this.msgType = WeChatConstant.KefuMsgType.VOICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,7 +2,7 @@ package com.ossez.wechat.wecom.util.json;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenu;
|
import com.ossez.wechat.common.bean.menu.WxMenu;
|
||||||
import com.ossez.wechat.common.exception.WxError;
|
import com.ossez.wechat.common.exception.WxError;
|
||||||
import com.ossez.wechat.common.util.json.WxErrorAdapter;
|
import com.ossez.wechat.common.util.json.WxErrorAdapter;
|
||||||
import com.ossez.wechat.wecom.bean.WxCpChat;
|
import com.ossez.wechat.wecom.bean.WxCpChat;
|
||||||
|
@ -3,7 +3,7 @@ package com.ossez.wechat.wecom.util.json;
|
|||||||
import com.google.gson.JsonDeserializationContext;
|
import com.google.gson.JsonDeserializationContext;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenu;
|
import com.ossez.wechat.common.bean.menu.WxMenu;
|
||||||
import com.ossez.wechat.common.util.json.WxMenuGsonAdapter;
|
import com.ossez.wechat.common.util.json.WxMenuGsonAdapter;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
@ -16,8 +16,8 @@ import java.lang.reflect.Type;
|
|||||||
*/
|
*/
|
||||||
public class WxCpMenuGsonAdapter extends WxMenuGsonAdapter {
|
public class WxCpMenuGsonAdapter extends WxMenuGsonAdapter {
|
||||||
|
|
||||||
// @Override
|
@Override
|
||||||
// public WxMenu deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public WxMenu deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
// return this.buildMenuFromJson(json.getAsJsonObject().get("button").getAsJsonArray());
|
return this.buildMenuFromJson(json.getAsJsonObject().get("button").getAsJsonArray());
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package com.ossez.wechat.wecom.api.impl;
|
package com.ossez.wechat.wecom.api.impl;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.ossez.wechat.common.model.entity.builder.MenuButtonBuilder;
|
import com.ossez.wechat.common.bean.menu.WxMenu;
|
||||||
import com.ossez.wechat.common.model.entity.menu.WxMenu;
|
import com.ossez.wechat.common.bean.menu.WxMenuButton;
|
||||||
import com.ossez.wechat.common.model.entity.menu.MenuButton;
|
|
||||||
import com.ossez.wechat.common.constant.WeChatConstant;
|
import com.ossez.wechat.common.constant.WeChatConstant;
|
||||||
import com.ossez.wechat.wecom.api.ApiTestModule;
|
import com.ossez.wechat.wecom.api.ApiTestModule;
|
||||||
import com.ossez.wechat.wecom.api.WxCpService;
|
import com.ossez.wechat.wecom.api.WxCpService;
|
||||||
@ -35,42 +34,42 @@ public class WxCpMenuServiceImplTest {
|
|||||||
@DataProvider
|
@DataProvider
|
||||||
public Object[][] menuData() {
|
public Object[][] menuData() {
|
||||||
WxMenu menu = new WxMenu();
|
WxMenu menu = new WxMenu();
|
||||||
MenuButton button1 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button1 = new WxMenuButton();
|
||||||
Object WxConsts;
|
Object WxConsts;
|
||||||
button1.setType(WeChatConstant.MenuButtonType.CLICK);
|
button1.setType(WeChatConstant.MenuButtonType.CLICK);
|
||||||
button1.setName("今日歌曲");
|
button1.setName("今日歌曲");
|
||||||
button1.setKey("V1001_TODAY_MUSIC");
|
button1.setKey("V1001_TODAY_MUSIC");
|
||||||
|
|
||||||
MenuButton button2 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button2 = new WxMenuButton();
|
||||||
button2.setType(WeChatConstant.MenuButtonType.CLICK);
|
button2.setType(WeChatConstant.MenuButtonType.CLICK);
|
||||||
button2.setName("歌手简介");
|
button2.setName("歌手简介");
|
||||||
button2.setKey("V1001_TODAY_SINGER");
|
button2.setKey("V1001_TODAY_SINGER");
|
||||||
|
|
||||||
MenuButton button3 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button3 = new WxMenuButton();
|
||||||
button3.setName("菜单");
|
button3.setName("菜单");
|
||||||
|
|
||||||
menu.getButtons().add(button1);
|
menu.getButtons().add(button1);
|
||||||
menu.getButtons().add(button2);
|
menu.getButtons().add(button2);
|
||||||
menu.getButtons().add(button3);
|
menu.getButtons().add(button3);
|
||||||
|
|
||||||
MenuButton button31 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button31 = new WxMenuButton();
|
||||||
button31.setType(WeChatConstant.MenuButtonType.VIEW);
|
button31.setType(WeChatConstant.MenuButtonType.VIEW);
|
||||||
button31.setName("搜索");
|
button31.setName("搜索");
|
||||||
button31.setUrl("http://www.soso.com/");
|
button31.setUrl("http://www.soso.com/");
|
||||||
|
|
||||||
MenuButton button32 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button32 = new WxMenuButton();
|
||||||
button32.setType(WeChatConstant.MenuButtonType.VIEW);
|
button32.setType(WeChatConstant.MenuButtonType.VIEW);
|
||||||
button32.setName("视频");
|
button32.setName("视频");
|
||||||
button32.setUrl("http://v.qq.com/");
|
button32.setUrl("http://v.qq.com/");
|
||||||
|
|
||||||
MenuButton button33 = new MenuButtonBuilder().createMenuButton();
|
WxMenuButton button33 = new WxMenuButton();
|
||||||
button33.setType(WeChatConstant.MenuButtonType.CLICK);
|
button33.setType(WeChatConstant.MenuButtonType.CLICK);
|
||||||
button33.setName("赞一下我们");
|
button33.setName("赞一下我们");
|
||||||
button33.setKey("V1001_GOOD");
|
button33.setKey("V1001_GOOD");
|
||||||
|
|
||||||
// button3.getSubButtons().add(button31);
|
button3.getSubButtons().add(button31);
|
||||||
// button3.getSubButtons().add(button32);
|
button3.getSubButtons().add(button32);
|
||||||
// button3.getSubButtons().add(button33);
|
button3.getSubButtons().add(button33);
|
||||||
|
|
||||||
return new Object[][]{
|
return new Object[][]{
|
||||||
new Object[]{
|
new Object[]{
|
||||||
|
@ -71,7 +71,7 @@ public class WxCpMessageServiceImplTest {
|
|||||||
public void testSendMessage() throws WxErrorException {
|
public void testSendMessage() throws WxErrorException {
|
||||||
WxCpMessage message = new WxCpMessage();
|
WxCpMessage message = new WxCpMessage();
|
||||||
// message.setAgentId(configStorage.getAgentId());
|
// message.setAgentId(configStorage.getAgentId());
|
||||||
message.setMsgType(WeChatConstant.MsgType.TEXT);
|
message.setMsgType(WeChatConstant.KefuMsgType.TEXT);
|
||||||
message.setToUser(configStorage.getUserId());
|
message.setToUser(configStorage.getUserId());
|
||||||
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ public class WxCpMessageServiceImplTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testSendLinkedCorpMessage() throws WxErrorException {
|
public void testSendLinkedCorpMessage() throws WxErrorException {
|
||||||
this.wxService.getMessageService().sendLinkedCorpMessage(WxCpLinkedCorpMessage.builder()
|
this.wxService.getMessageService().sendLinkedCorpMessage(WxCpLinkedCorpMessage.builder()
|
||||||
.msgType(WeChatConstant.MsgType.TEXT)
|
.msgType(WeChatConstant.KefuMsgType.TEXT)
|
||||||
.toUsers(new String[]{configStorage.getUserId()})
|
.toUsers(new String[]{configStorage.getUserId()})
|
||||||
.content("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>")
|
.content("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>")
|
||||||
.build());
|
.build());
|
||||||
|
@ -23,7 +23,7 @@ public class WxCpLinkedCorpMessageTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testToJson_text() {
|
public void testToJson_text() {
|
||||||
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
||||||
.msgType(WeChatConstant.MsgType.TEXT)
|
.msgType(WeChatConstant.KefuMsgType.TEXT)
|
||||||
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
||||||
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
||||||
.toTags(new String[]{"tagid1", "tagid2"})
|
.toTags(new String[]{"tagid1", "tagid2"})
|
||||||
@ -57,7 +57,7 @@ public class WxCpLinkedCorpMessageTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testToJson_image() {
|
public void testToJson_image() {
|
||||||
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
||||||
.msgType(WeChatConstant.MsgType.IMAGE)
|
.msgType(WeChatConstant.KefuMsgType.IMAGE)
|
||||||
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
||||||
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
||||||
.toTags(new String[]{"tagid1", "tagid2"})
|
.toTags(new String[]{"tagid1", "tagid2"})
|
||||||
@ -90,7 +90,7 @@ public class WxCpLinkedCorpMessageTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testToJson_video() {
|
public void testToJson_video() {
|
||||||
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
||||||
.msgType(WeChatConstant.MsgType.VIDEO)
|
.msgType(WeChatConstant.KefuMsgType.VIDEO)
|
||||||
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
||||||
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
||||||
.toTags(new String[]{"tagid1", "tagid2"})
|
.toTags(new String[]{"tagid1", "tagid2"})
|
||||||
@ -127,7 +127,7 @@ public class WxCpLinkedCorpMessageTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testToJson_file() {
|
public void testToJson_file() {
|
||||||
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
||||||
.msgType(WeChatConstant.MsgType.FILE)
|
.msgType(WeChatConstant.KefuMsgType.FILE)
|
||||||
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
||||||
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
||||||
.toTags(new String[]{"tagid1", "tagid2"})
|
.toTags(new String[]{"tagid1", "tagid2"})
|
||||||
@ -160,7 +160,7 @@ public class WxCpLinkedCorpMessageTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testToJson_textCard() {
|
public void testToJson_textCard() {
|
||||||
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
||||||
.msgType(WeChatConstant.MsgType.TEXTCARD)
|
.msgType(WeChatConstant.KefuMsgType.TEXTCARD)
|
||||||
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
||||||
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
||||||
.toTags(new String[]{"tagid1", "tagid2"})
|
.toTags(new String[]{"tagid1", "tagid2"})
|
||||||
@ -199,7 +199,7 @@ public class WxCpLinkedCorpMessageTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testToJson_news() {
|
public void testToJson_news() {
|
||||||
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
||||||
.msgType(WeChatConstant.MsgType.NEWS)
|
.msgType(WeChatConstant.KefuMsgType.NEWS)
|
||||||
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
||||||
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
||||||
.toTags(new String[]{"tagid1", "tagid2"})
|
.toTags(new String[]{"tagid1", "tagid2"})
|
||||||
@ -246,7 +246,7 @@ public class WxCpLinkedCorpMessageTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testToJson_mpnews() {
|
public void testToJson_mpnews() {
|
||||||
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
||||||
.msgType(WeChatConstant.MsgType.MPNEWS)
|
.msgType(WeChatConstant.KefuMsgType.MPNEWS)
|
||||||
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
||||||
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
||||||
.toTags(new String[]{"tagid1", "tagid2"})
|
.toTags(new String[]{"tagid1", "tagid2"})
|
||||||
@ -295,7 +295,7 @@ public class WxCpLinkedCorpMessageTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testToJson_markdown() {
|
public void testToJson_markdown() {
|
||||||
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
||||||
.msgType(WeChatConstant.MsgType.MARKDOWN)
|
.msgType(WeChatConstant.KefuMsgType.MARKDOWN)
|
||||||
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
||||||
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
||||||
.toTags(new String[]{"tagid1", "tagid2"})
|
.toTags(new String[]{"tagid1", "tagid2"})
|
||||||
@ -350,7 +350,7 @@ public class WxCpLinkedCorpMessageTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testToJson_miniProgramNotice() {
|
public void testToJson_miniProgramNotice() {
|
||||||
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
WxCpLinkedCorpMessage message = WxCpLinkedCorpMessage.builder()
|
||||||
.msgType(WeChatConstant.MsgType.MINIPROGRAM_NOTICE)
|
.msgType(WeChatConstant.KefuMsgType.MINIPROGRAM_NOTICE)
|
||||||
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
.toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
|
||||||
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
.toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
|
||||||
.toTags(new String[]{"tagid1", "tagid2"})
|
.toTags(new String[]{"tagid1", "tagid2"})
|
||||||
|
@ -11,8 +11,8 @@ import org.mockito.MockitoAnnotations;
|
|||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
@ -17,8 +17,8 @@ import org.testng.annotations.Test;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
@ -17,8 +17,8 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.testng.Assert.*;
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import org.testng.collections.CollectionUtils;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.*;
|
import static org.mockito.Matchers.*;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.testng.Assert.*;
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
|
@ -1,32 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<configuration>
|
||||||
<configuration debug="true">
|
|
||||||
<timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>
|
|
||||||
|
|
||||||
<appender name="STDOUT"
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
class="ch.qos.logback.core.ConsoleAppender">
|
<encoder>
|
||||||
<!-- encoders are assigned by default the type
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %replace(%caller{1}){'Caller', ''} - %msg%n</pattern>
|
||||||
ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
|
</encoder>
|
||||||
<encoder>
|
</appender>
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
|
||||||
|
|
||||||
</encoder>
|
|
||||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
|
||||||
<Pattern>
|
|
||||||
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
|
|
||||||
</Pattern>
|
|
||||||
</layout>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- LOGGER -->
|
|
||||||
<logger name="com.ossez" level="DEBUG"/>
|
|
||||||
<logger name="org.apache" level="INFO"/>
|
|
||||||
<logger name="org.hibernate" level="INFO"/>
|
|
||||||
<logger name="org.springframework" level="INFO"/>
|
|
||||||
|
|
||||||
<!-- ROOT AND APPENDER -->
|
|
||||||
<root level="debug">
|
|
||||||
<appender-ref ref="STDOUT"/>
|
|
||||||
</root>
|
|
||||||
|
|
||||||
|
<root level="debug">
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
</configuration>
|
</configuration>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user