Skip to content

Commit 3dfc75a

Browse files
committed
AttachmentTest unit test polish
1 parent 39f6048 commit 3dfc75a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

client/src/test/java/cn/vika/client/api/AttachmentTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package cn.vika.client.api;
2020

2121
import java.io.File;
22+
import java.net.URL;
2223

2324
import cn.vika.client.api.model.Attachment;
2425
import cn.vika.core.http.ClassPathResourceLoader;
@@ -70,7 +71,11 @@ public void testUploadWithUrlResource() throws JsonProcessingException {
7071
@Test
7172
@Order(3)
7273
public void testUploadWithFileResource() throws JsonProcessingException {
73-
File file = new File("/Users/shawndeng/Documents/Project/vika.java/client/src/test/resources/test.docx");
74+
ClassLoader classLoader = getClass().getClassLoader();
75+
URL url = classLoader.getResource("test.txt");
76+
assertThat(url).isNotNull();
77+
File file = new File(url.getFile());
78+
assertThat(file).isNotNull();
7479
Attachment attachment = vikaApiClient.getAttachmentApi().upload(TEST_DATASHEET_ID.get(), new FileResourceLoader(file));
7580
assertThat(attachment).isNotNull();
7681
System.out.println(JacksonJsonUtil.toJson(attachment, true));
@@ -79,7 +84,11 @@ public void testUploadWithFileResource() throws JsonProcessingException {
7984
@Test
8085
@Order(4)
8186
public void testUploadWithFile() throws JsonProcessingException {
82-
File file = new File("/Users/shawndeng/Documents/Project/vika.java/client/src/test/resources/test.docx");
87+
ClassLoader classLoader = getClass().getClassLoader();
88+
URL url = classLoader.getResource("test.txt");
89+
assertThat(url).isNotNull();
90+
File file = new File(url.getFile());
91+
assertThat(file).isNotNull();
8392
Attachment attachment = vikaApiClient.getAttachmentApi().upload(TEST_DATASHEET_ID.get(), file);
8493
assertThat(attachment).isNotNull();
8594
System.out.println(JacksonJsonUtil.toJson(attachment, true));

0 commit comments

Comments
 (0)