Skip to content

Commit b759e1d

Browse files
authored
Merge pull request #24 from redmaple1/feature/20200518-renxiaoya
add wechaty-puppet-mock
2 parents eba098c + 8977a56 commit b759e1d

File tree

10 files changed

+194
-13
lines changed

10 files changed

+194
-13
lines changed

pom.xml

Lines changed: 1 addition & 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>
@@ -184,13 +185,11 @@
184185
<groupId>org.mockito</groupId>
185186
<artifactId>mockito-core</artifactId>
186187
<version>3.3.3</version>
187-
<scope>test</scope>
188188
</dependency>
189189
<dependency>
190190
<groupId>junit</groupId>
191191
<artifactId>junit</artifactId>
192192
<version>4.12</version>
193-
<scope>test</scope>
194193
</dependency>
195194

196195
</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-mock/pom.xml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
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+
</dependencies>
52+
53+
<build>
54+
<!-- <sourceDirectory>src/main/kotlin</sourceDirectory>-->
55+
<plugins>
56+
<plugin>
57+
<groupId>org.jetbrains.kotlin</groupId>
58+
<artifactId>kotlin-maven-plugin</artifactId>
59+
<version>${kotlin.version}</version>
60+
<executions>
61+
<execution>
62+
<id>compile</id>
63+
<goals>
64+
<goal>compile</goal>
65+
</goals>
66+
<configuration>
67+
<sourceDirs>
68+
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
69+
<sourceDir>src/main/kotlin</sourceDir>
70+
</sourceDirs>
71+
</configuration>
72+
</execution>
73+
<execution>
74+
<id>test-compile</id>
75+
<goals>
76+
<goal>test-compile</goal>
77+
</goals>
78+
<configuration>
79+
<sourceDirs>
80+
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
81+
<sourceDir>${project.basedir}/src/test/java</sourceDir>
82+
</sourceDirs>
83+
</configuration>
84+
</execution>
85+
</executions>
86+
</plugin>
87+
<plugin>
88+
<groupId>org.apache.maven.plugins</groupId>
89+
<artifactId>maven-compiler-plugin</artifactId>
90+
<version>3.6.1</version>
91+
<configuration>
92+
<source>1.8</source>
93+
<target>1.8</target>
94+
</configuration>
95+
<executions>
96+
<!-- 替换会被 maven 特别处理的 default-compile -->
97+
<execution>
98+
<id>default-compile</id>
99+
<phase>none</phase>
100+
</execution>
101+
<!-- 替换会被 maven 特别处理的 default-testCompile -->
102+
<execution>
103+
<id>default-testCompile</id>
104+
<phase>none</phase>
105+
</execution>
106+
<execution>
107+
<id>java-compile</id>
108+
<phase>compile</phase>
109+
<goals>
110+
<goal>compile</goal>
111+
</goals>
112+
</execution>
113+
<execution>
114+
<id>java-test-compile</id>
115+
<phase>test-compile</phase>
116+
<goals>
117+
<goal>testCompile</goal>
118+
</goals>
119+
</execution>
120+
</executions>
121+
</plugin>
122+
<plugin>
123+
<groupId>org.apache.maven.plugins</groupId>
124+
<artifactId>maven-source-plugin</artifactId>
125+
<version>3.2.1</version>
126+
<executions>
127+
<execution>
128+
<phase>package</phase>
129+
<goals>
130+
<goal>jar-no-fork</goal>
131+
</goals>
132+
</execution>
133+
</executions>
134+
</plugin>
135+
<!-- Javadoc -->
136+
<plugin>
137+
<groupId>org.jetbrains.dokka</groupId>
138+
<artifactId>dokka-maven-plugin</artifactId>
139+
<version>${dokka.version}</version>
140+
<executions>
141+
<execution>
142+
<phase>pre-site</phase>
143+
<goals>
144+
<goal>javadocJar</goal>
145+
</goals>
146+
</execution>
147+
</executions>
148+
<configuration>
149+
<sourceDirectories>
150+
<dir>src/main/kotlin</dir>
151+
</sourceDirectories>
152+
</configuration>
153+
</plugin>
154+
<plugin>
155+
<groupId>org.apache.maven.plugins</groupId>
156+
<artifactId>maven-javadoc-plugin</artifactId>
157+
<version>3.2.0</version>
158+
<executions>
159+
<execution>
160+
<phase>package</phase>
161+
<goals>
162+
<goal>jar</goal>
163+
</goals>
164+
</execution>
165+
</executions>
166+
</plugin>
167+
</plugins>
168+
</build>
169+
170+
<pluginRepositories>
171+
<pluginRepository>
172+
<id>jcenter</id>
173+
<name>JCenter</name>
174+
<url>https://jcenter.bintray.com/</url>
175+
</pluginRepository>
176+
</pluginRepositories>
177+
178+
179+
</project>

wechaty/src/test/kotlin/io/github/wechaty/MockPuppet.kt renamed to wechaty-puppet-mock/src/main/kotlin/wechaty/MockPuppet.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
package io.github.wechaty
1+
package wechaty
22

3+
import io.github.wechaty.Puppet
34
import io.github.wechaty.filebox.FileBox
45
import io.github.wechaty.schemas.*
56
import org.slf4j.LoggerFactory
67
import java.util.concurrent.Future
78

89
class MockPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
910
override fun start(): Future<Void> {
10-
TODO("Not yet implemented")
11+
1112
log.info("MockPuppet start()")
1213

1314
//TODO("StateSwitch")
@@ -26,6 +27,7 @@ class MockPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
2627
eventScanPayload.qrcode = "https://github.com/wechaty/wechaty-puppet-mock"
2728
emit("scan", eventScanPayload)
2829

30+
TODO("Not yet implemented")
2931

3032
}
3133

wechaty/src/test/kotlin/io/github/wechaty/util/MockitoHelper.kt renamed to wechaty-puppet-mock/src/main/kotlin/wechaty/utils/MockitoHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.wechaty.util
1+
package wechaty.utils
22

33
import org.mockito.Mockito
44

wechaty/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
<version>${project.version}</version>
3030
</dependency>
3131

32+
<dependency>
33+
<groupId>io.github.wechaty</groupId>
34+
<artifactId>wechaty-puppet-mock</artifactId>
35+
<version>${project.version}</version>
36+
</dependency>
37+
3238
<dependency>
3339
<groupId>org.jetbrains.kotlin</groupId>
3440
<artifactId>kotlin-stdlib</artifactId>

wechaty/src/main/kotlin/io/github/wechaty/Wechaty.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.github.wechaty;
22

3-
//import io.github.wechaty.user.Room
3+
//import io.github.io.github.user.Room
44

55
import io.github.wechaty.eventEmitter.EventEmitter
66
import io.github.wechaty.eventEmitter.Listener

wechaty/src/main/kotlin/io/github/wechaty/user/Message.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ open class Message(wechaty: Wechaty,val id: String) : Sayable, Accessory(wechaty
285285

286286

287287
override fun toString():String{
288-
TODO()
288+
return "Message(payload=$payload,id=$id)"
289289
}
290290

291291
companion object{

wechaty/src/test/kotlin/io/github/wechaty/user/RoomTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.github.wechaty.user
22

33
import io.github.wechaty.Wechaty
4-
import io.github.wechaty.util.MockitoHelper
54
import org.junit.After
65
import org.junit.Before
76
import org.junit.Ignore
@@ -10,6 +9,7 @@ import org.mockito.ArgumentMatchers
109
import org.mockito.Mockito
1110
import org.mockito.Mockito.`when`
1211
import org.mockito.Mockito.verify
12+
import wechaty.utils.MockitoHelper
1313

1414
/**
1515
* @author renxiaoya

0 commit comments

Comments
 (0)