Skip to content

Commit a832827

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # wechaty-puppet-mock/src/main/kotlin/io/github/wechaty/MockPuppet.kt
2 parents b812ea0 + 0018167 commit a832827

File tree

17 files changed

+360
-45
lines changed

17 files changed

+360
-45
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,11 @@ We decided to use Kotlin to develop the Java Wechaty!
292292

293293
## Related Projects
294294

295-
- [Wechaty](https://github.com/wechaty/wechaty) - WeChat Bot SDK for Individual Account in TypeScript
296-
- [Python Wechaty](https://github.com/wechaty/python-wechaty) - Python WeChat Bot SDK for Individual Account.
297-
- [Go Wechaty](https://github.com/wechaty/go-wechaty) - Go WeChat Bot SDK for Individual Account.
295+
- [Wechaty](https://github.com/wechaty/wechaty) - Conversatioanl AI Chatot SDK for Wechaty Individual Accounts (TypeScript)
296+
- [Python Wechaty](https://github.com/wechaty/python-wechaty) - Python WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Python)
297+
- [Go Wechaty](https://github.com/wechaty/go-wechaty) - Go WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Go)
298+
- [Java Wechaty](https://github.com/wechaty/java-wechaty) - Java WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Java)
299+
- [Scala Wechaty](https://github.com/wechaty/scala-wechaty) - Scala WeChaty Conversational AI Chatbot SDK for WechatyIndividual Accounts (Scala)
298300

299301
## Committers
300302

pom.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<module>wechaty</module>
3131
<module>wechaty-puppet</module>
3232
<module>wechaty-puppet-hostie</module>
33+
<module>wechaty-puppet-mock</module>
3334
</modules>
3435

3536
<dependencyManagement>
@@ -168,13 +169,16 @@
168169
<groupId>org.mockito</groupId>
169170
<artifactId>mockito-core</artifactId>
170171
<version>3.3.3</version>
171-
<scope>test</scope>
172172
</dependency>
173173
<dependency>
174174
<groupId>junit</groupId>
175175
<artifactId>junit</artifactId>
176176
<version>4.12</version>
177-
<scope>test</scope>
177+
</dependency>
178+
<dependency>
179+
<groupId>com.github.javafaker</groupId>
180+
<artifactId>javafaker</artifactId>
181+
<version>1.0.2</version>
178182
</dependency>
179183

180184
</dependencies>

wechaty-puppet-hostie/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
<artifactId>wechaty-puppet-hostie</artifactId>
1111
<packaging>jar</packaging>
1212

13-
<properties>
14-
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
15-
<dokka.version>0.10.1</dokka.version>
16-
</properties>
17-
1813
<dependencies>
1914

2015
<dependency>

wechaty-puppet-hostie/src/main/kotlin/io/github/wechaty/grpc/GrpcPuppet.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import org.apache.commons.lang3.StringUtils
1717
import org.apache.commons.lang3.math.NumberUtils
1818
import org.slf4j.LoggerFactory
1919
import java.util.concurrent.CompletableFuture
20-
import java.util.concurrent.CountDownLatch
2120
import java.util.concurrent.Executors.newFixedThreadPool
2221
import java.util.concurrent.Future
2322
import java.util.concurrent.TimeUnit
@@ -406,7 +405,7 @@ class GrpcPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
406405
payload.province = response.province
407406
payload.signature = response.signature
408407
payload.star = response.star
409-
payload.type = ContractType.getByCode(response.type.number)
408+
payload.type = ContactType.getByCode(response.type.number)
410409
payload.weixin = response.weixin
411410
payload
412411
}

wechaty-puppet-mock/pom.xml

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>wechaty-parent</artifactId>
7+
<groupId>io.github.wechaty</groupId>
8+
<version>0.1.1-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>wechaty-puppet-mock</artifactId>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.jetbrains.kotlin</groupId>
17+
<artifactId>kotlin-stdlib</artifactId>
18+
</dependency>
19+
<dependency>
20+
<groupId>io.github.wechaty</groupId>
21+
<artifactId>wechaty-puppet</artifactId>
22+
<version>${project.version}</version>
23+
</dependency>
24+
25+
<!-- <dependency>-->
26+
<!-- <groupId>org.apache.logging.log4j</groupId>-->
27+
<!-- <artifactId>log4j-api</artifactId>-->
28+
<!-- </dependency>-->
29+
<!-- <dependency>-->
30+
<!-- <groupId>org.apache.logging.log4j</groupId>-->
31+
<!-- <artifactId>log4j-core</artifactId>-->
32+
<!-- </dependency>-->
33+
<!-- <dependency>-->
34+
<!-- <groupId>org.apache.logging.log4j</groupId>-->
35+
<!-- <artifactId>log4j-slf4j-impl</artifactId>-->
36+
<!-- </dependency>-->
37+
<!-- <dependency>-->
38+
<!-- <groupId>org.slf4j</groupId>-->
39+
<!-- <artifactId>slf4j-api</artifactId>-->
40+
<!-- </dependency>-->
41+
42+
<dependency>
43+
<groupId>org.mockito</groupId>
44+
<artifactId>mockito-core</artifactId>
45+
<version>3.3.3</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>junit</groupId>
49+
<artifactId>junit</artifactId>
50+
</dependency>
51+
<dependency>
52+
<groupId>com.github.javafaker</groupId>
53+
<artifactId>javafaker</artifactId>
54+
</dependency>
55+
</dependencies>
56+
57+
<build>
58+
<!-- <sourceDirectory>src/main/kotlin</sourceDirectory>-->
59+
<plugins>
60+
<plugin>
61+
<groupId>org.jetbrains.kotlin</groupId>
62+
<artifactId>kotlin-maven-plugin</artifactId>
63+
<version>${kotlin.version}</version>
64+
<executions>
65+
<execution>
66+
<id>compile</id>
67+
<goals>
68+
<goal>compile</goal>
69+
</goals>
70+
<configuration>
71+
<sourceDirs>
72+
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
73+
<sourceDir>src/main/kotlin</sourceDir>
74+
</sourceDirs>
75+
</configuration>
76+
</execution>
77+
<execution>
78+
<id>test-compile</id>
79+
<goals>
80+
<goal>test-compile</goal>
81+
</goals>
82+
<configuration>
83+
<sourceDirs>
84+
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
85+
<sourceDir>${project.basedir}/src/test/java</sourceDir>
86+
</sourceDirs>
87+
</configuration>
88+
</execution>
89+
</executions>
90+
</plugin>
91+
<plugin>
92+
<groupId>org.apache.maven.plugins</groupId>
93+
<artifactId>maven-compiler-plugin</artifactId>
94+
<version>3.6.1</version>
95+
<configuration>
96+
<source>1.8</source>
97+
<target>1.8</target>
98+
</configuration>
99+
<executions>
100+
<!-- 替换会被 maven 特别处理的 default-compile -->
101+
<execution>
102+
<id>default-compile</id>
103+
<phase>none</phase>
104+
</execution>
105+
<!-- 替换会被 maven 特别处理的 default-testCompile -->
106+
<execution>
107+
<id>default-testCompile</id>
108+
<phase>none</phase>
109+
</execution>
110+
<execution>
111+
<id>java-compile</id>
112+
<phase>compile</phase>
113+
<goals>
114+
<goal>compile</goal>
115+
</goals>
116+
</execution>
117+
<execution>
118+
<id>java-test-compile</id>
119+
<phase>test-compile</phase>
120+
<goals>
121+
<goal>testCompile</goal>
122+
</goals>
123+
</execution>
124+
</executions>
125+
</plugin>
126+
<plugin>
127+
<groupId>org.apache.maven.plugins</groupId>
128+
<artifactId>maven-source-plugin</artifactId>
129+
<version>3.2.1</version>
130+
<executions>
131+
<execution>
132+
<phase>package</phase>
133+
<goals>
134+
<goal>jar-no-fork</goal>
135+
</goals>
136+
</execution>
137+
</executions>
138+
</plugin>
139+
<!-- Javadoc -->
140+
<plugin>
141+
<groupId>org.jetbrains.dokka</groupId>
142+
<artifactId>dokka-maven-plugin</artifactId>
143+
<version>${dokka.version}</version>
144+
<executions>
145+
<execution>
146+
<phase>pre-site</phase>
147+
<goals>
148+
<goal>javadocJar</goal>
149+
</goals>
150+
</execution>
151+
</executions>
152+
<configuration>
153+
<sourceDirectories>
154+
<dir>src/main/kotlin</dir>
155+
</sourceDirectories>
156+
</configuration>
157+
</plugin>
158+
<plugin>
159+
<groupId>org.apache.maven.plugins</groupId>
160+
<artifactId>maven-javadoc-plugin</artifactId>
161+
<version>3.2.0</version>
162+
<executions>
163+
<execution>
164+
<phase>package</phase>
165+
<goals>
166+
<goal>jar</goal>
167+
</goals>
168+
</execution>
169+
</executions>
170+
</plugin>
171+
</plugins>
172+
</build>
173+
174+
<pluginRepositories>
175+
<pluginRepository>
176+
<id>jcenter</id>
177+
<name>JCenter</name>
178+
<url>https://jcenter.bintray.com/</url>
179+
</pluginRepository>
180+
</pluginRepositories>
181+
182+
183+
</project>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package io.github.wechaty
2+
3+
import com.github.javafaker.Faker
4+
import io.github.wechaty.filebox.FileBox
5+
import io.github.wechaty.schemas.*
6+
import java.util.*
7+
8+
/**
9+
* Data for mock
10+
* @author renxiaoya
11+
* @date 2020-06-01
12+
**/
13+
class MockData {
14+
15+
companion object {
16+
private val faker = Faker()
17+
18+
fun getFakeContactPayload(): ContactPayload {
19+
val contactPayload = ContactPayload(UUID.randomUUID().toString())
20+
contactPayload.address = faker.address().streetAddress()
21+
contactPayload.avatar = faker.avatar().toString()
22+
contactPayload.city = faker.address().city()
23+
contactPayload.friend = true
24+
contactPayload.gender = ContractGender.Male
25+
contactPayload.name = faker.name().firstName()
26+
contactPayload.province = faker.address().state()
27+
contactPayload.signature = faker.lorem().sentence()
28+
contactPayload.star = false
29+
contactPayload.type = ContactType.Personal
30+
return contactPayload
31+
}
32+
33+
fun getFakeImageFileBox(): FileBox {
34+
return FileBox.fromUrl(faker.avatar().image(), null)
35+
}
36+
37+
fun getMessagePayload(fromId: String, toId: String): MessagePayload {
38+
val messagePayload = getFakeMessagePayload()
39+
messagePayload.fromId = fromId
40+
messagePayload.toId = toId
41+
return messagePayload
42+
}
43+
44+
fun getFakeMessagePayload(): MessagePayload {
45+
val messagePayload = MessagePayload(UUID.randomUUID().toString())
46+
messagePayload.fromId = UUID.randomUUID().toString()
47+
messagePayload.mentionIdList = listOf()
48+
messagePayload.text = faker.lorem().sentence()
49+
messagePayload.timestamp = Date().time
50+
messagePayload.toId = UUID.randomUUID().toString()
51+
messagePayload.type = MessageType.Text
52+
messagePayload.roomId = "${UUID.randomUUID().toString()}@chatroom"
53+
messagePayload.filename = faker.file().fileName()
54+
return messagePayload
55+
}
56+
}
57+
58+
}

0 commit comments

Comments
 (0)