Skip to content

Commit 49bb672

Browse files
fix filebox load fromJson bug and add test case for the change
1 parent 74dd31f commit 49bb672

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

wechaty-puppet/pom.xml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,20 @@
104104
<groupId>com.squareup.okhttp3</groupId>
105105
<artifactId>okhttp</artifactId>
106106
</dependency>
107-
107+
<dependency>
108+
<groupId>org.hamcrest</groupId>
109+
<artifactId>hamcrest-core</artifactId>
110+
</dependency>
111+
<dependency>
112+
<groupId>org.mockito</groupId>
113+
<artifactId>mockito-core</artifactId>
114+
<scope>test</scope>
115+
</dependency>
116+
<dependency>
117+
<groupId>junit</groupId>
118+
<artifactId>junit</artifactId>
119+
<scope>test</scope>
120+
</dependency>
108121

109122
</dependencies>
110123

wechaty-puppet/src/main/kotlin/io/github/wechaty/filebox/FileBox.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ class FileBox(options: FileBoxOptions) {
202202

203203
FileBoxType.Url.code -> {
204204
fileBox = fromUrl(
205-
jsonNode.findValue("name").asText(),
206-
jsonNode.findValue("remoteUrl").asText()
205+
jsonNode.findValue("remoteUrl").asText(),
206+
jsonNode.findValue("name").asText()
207207
)
208208
}
209209

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package io.github.wechaty.filebox
2+
3+
import junit.framework.Assert.assertEquals
4+
import org.junit.Test
5+
6+
const val EXPECTED_FILEBOX_URL = "http://testurl"
7+
const val EXPECTED_FILEBOX_NAME = "fileboxname"
8+
9+
class FileBoxTest {
10+
11+
@Test
12+
fun testFileBoxFromURLShallHaveCorrectNameAndURL() {
13+
14+
var filebox : FileBox = FileBox.fromJson("{\"remoteUrl\":\"" + EXPECTED_FILEBOX_URL + "\"," +
15+
"\"name\":\"" + EXPECTED_FILEBOX_NAME + "\"," +
16+
"\"boxType\":2}")
17+
18+
assertEquals(EXPECTED_FILEBOX_URL, filebox.remoteUrl)
19+
assertEquals(EXPECTED_FILEBOX_NAME, filebox.name)
20+
}
21+
}

0 commit comments

Comments
 (0)