Skip to content

Commit e168c65

Browse files
committed
1. change method on(Event:String,Listener:listener) to onEvent(Listener:listener). See examples
2. update version to 0.1.2 3. update wechaty grpc to 0.16.1 4. move examples from wechaty to independent module. Make example easy to use.
1 parent a832827 commit e168c65

File tree

5 files changed

+9
-31
lines changed

5 files changed

+9
-31
lines changed

pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,6 @@
147147
<artifactId>okhttp</artifactId>
148148
<version>4.6.0</version>
149149
</dependency>
150-
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/io.grpc/grpc-kotlin-stub &ndash;&gt;-->
151-
<!-- <dependency>-->
152-
<!-- <groupId>io.grpc</groupId>-->
153-
<!-- <artifactId>grpc-kotlin-stub</artifactId>-->
154-
<!-- <version>0.1.1</version>-->
155-
<!-- </dependency>-->
156150

157151
<dependency>
158152
<groupId>org.hamcrest</groupId>

wechaty-puppet-mock/pom.xml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>wechaty-parent</artifactId>
77
<groupId>io.github.wechaty</groupId>
8-
<version>0.1.1-SNAPSHOT</version>
8+
<version>0.1.2-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

@@ -21,24 +21,6 @@
2121
<artifactId>wechaty-puppet</artifactId>
2222
<version>${project.version}</version>
2323
</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-
4224
<dependency>
4325
<groupId>org.mockito</groupId>
4426
<artifactId>mockito-core</artifactId>

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.wechaty
22

33
import io.github.wechaty.filebox.FileBox
4+
import io.github.wechaty.io.github.wechaty.schemas.EventEnum
45
import io.github.wechaty.schemas.*
56
import org.slf4j.LoggerFactory
67
import java.util.*
@@ -30,15 +31,15 @@ class MockPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
3031
*/
3132
val eventScanPayload = EventScanPayload(ScanStatus.Cancel)
3233
eventScanPayload.qrcode = "https://github.com/wechaty/java-wechaty/wechaty-puppet-mock"
33-
emit("scan", eventScanPayload)
34+
emit(EventEnum.SCAN, eventScanPayload)
3435

3536

3637
val userPayload = MockData.getFakeContactPayload()
3738
cacheContactPayload.put(userPayload.id, userPayload)
3839

3940
setId(userPayload.id)
4041

41-
emit("login", EventLoginPayload(userPayload.id))
42+
emit(EventEnum.LOGIN, EventLoginPayload(userPayload.id))
4243

4344
timer.scheduleAtFixedRate(0, 5000) {
4445
val fromContactPayload = MockData.getFakeContactPayload()
@@ -47,7 +48,7 @@ class MockPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
4748

4849
cacheMessagePayload.put(messagePayload.id, messagePayload)
4950
log.info("MockPuppet start() schedule pretending received a new message:${messagePayload.id}")
50-
emit("message", EventMessagePayload(messagePayload.id))
51+
emit(EventEnum.MESSAGE, EventMessagePayload(messagePayload.id))
5152
}
5253
return CompletableFuture.completedFuture(null)
5354
}
@@ -74,15 +75,15 @@ class MockPuppet(puppetOptions: PuppetOptions) : Puppet(puppetOptions) {
7475
log.info("MockPuppet logout()")
7576
val id = getId() ?: throw Exception("logout before login?")
7677

77-
emit("logout", EventLogoutPayload(id, "test"))
78+
emit(EventEnum.LOGOUT, EventLogoutPayload(id, "test"))
7879
setId(null)
7980

8081
return CompletableFuture.completedFuture(null)
8182
}
8283

8384
override fun ding(data: String?) {
8485
log.info("MockPuppet ding(${data ?: ""})")
85-
emit("dong", EventDongPayload(data ?: ""))
86+
emit(EventEnum.DONG, EventDongPayload(data ?: ""))
8687
}
8788

8889
override fun contactSelfName(name: String): Future<Void> {

wechaty/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<groupId>io.github.wechaty</groupId>
3434
<artifactId>wechaty-puppet-mock</artifactId>
3535
<version>${project.version}</version>
36+
<scope>test</scope>
3637
</dependency>
3738

3839
<dependency>

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,6 +1,7 @@
11
package io.github.wechaty.user
22

33
import io.github.wechaty.Wechaty
4+
import io.github.wechaty.utils.MockitoHelper
45
import org.junit.After
56
import org.junit.Before
67
import org.junit.Ignore
@@ -9,7 +10,6 @@ import org.mockito.ArgumentMatchers
910
import org.mockito.Mockito
1011
import org.mockito.Mockito.`when`
1112
import org.mockito.Mockito.verify
12-
import io.github.wechaty.utils.MockitoHelper
1313

1414
/**
1515
* @author renxiaoya

0 commit comments

Comments
 (0)