99import org .cryptomator .cloudaccess .api .CloudItemType ;
1010import org .cryptomator .cloudaccess .api .ProgressListener ;
1111import org .cryptomator .cloudaccess .api .exceptions .AlreadyExistsException ;
12- import org .junit .Assert ;
1312import org .junit .jupiter .api .Assertions ;
1413import org .junit .jupiter .api .BeforeEach ;
1514import org .junit .jupiter .api .DisplayName ;
1615import org .junit .jupiter .api .Test ;
16+ import org .junit .jupiter .params .ParameterizedTest ;
17+ import org .junit .jupiter .params .provider .ValueSource ;
1718import org .mockito .ArgumentMatchers ;
1819import org .mockito .Mockito ;
1920
@@ -53,7 +54,7 @@ public void testItemMetadata() throws IOException {
5354
5455 final var itemMetadata = webDavClient .itemMetadata (Path .of ("/Nextcloud Manual.pdf" ));
5556
56- Assert .assertEquals (testFileManual , itemMetadata );
57+ Assertions .assertEquals (testFileManual , itemMetadata );
5758 }
5859
5960 @ Test
@@ -65,9 +66,9 @@ public void testList() throws IOException {
6566
6667 final var expectedList = List .of (testFolderDocuments , testFileManual , testFileIntro , testFilePng , testFolderPhotos );
6768
68- Assert .assertEquals (expectedList , nodeList .getItems ());
69+ Assertions .assertEquals (expectedList , nodeList .getItems ());
6970
70- Assert .assertTrue (nodeList .getNextPageToken ().isEmpty ());
71+ Assertions .assertTrue (nodeList .getNextPageToken ().isEmpty ());
7172 }
7273
7374 @ Test
@@ -87,8 +88,8 @@ public void testListExhaustively() throws IOException {
8788
8889 final var expectedList = List .of (testFolderDocuments , testFileManual , testFileIntro , testFilePng , testFolderPhotos , testFileAbout , testFileAboutTxt , testFileFlyer , testFileCoast , testFileHummingbird , testFileCommunity , testFileNut );
8990
90- Assert .assertEquals (expectedList , nodeList .getItems ());
91- Assert .assertTrue (nodeList .getNextPageToken ().isEmpty ());
91+ Assertions .assertEquals (expectedList , nodeList .getItems ());
92+ Assertions .assertTrue (nodeList .getNextPageToken ().isEmpty ());
9293 }
9394
9495 @ Test
@@ -99,7 +100,7 @@ public void testRead() throws IOException {
99100 final var inputStream = webDavClient .read (Path .of ("/Documents/About.txt" ), ProgressListener .NO_PROGRESS_AWARE );
100101 final var content = new BufferedReader (new InputStreamReader (inputStream , StandardCharsets .UTF_8 )).lines ().collect (Collectors .joining ("\n " ));
101102
102- Assert .assertEquals (load ("item-read-response.txt" ), content );
103+ Assertions .assertEquals (load ("item-read-response.txt" ), content );
103104 }
104105
105106 @ Test
@@ -110,22 +111,13 @@ public void testRandomAccessRead() throws IOException {
110111 final var inputStream = webDavClient .read (Path .of ("/Documents/About.txt" ), 4 , 2 , ProgressListener .NO_PROGRESS_AWARE );
111112 final var content = new BufferedReader (new InputStreamReader (inputStream , StandardCharsets .UTF_8 )).lines ().collect (Collectors .joining ("\n " ));
112113
113- Assert .assertEquals (load ("item-partial-read-response.txt" ), content );
114+ Assertions .assertEquals (load ("item-partial-read-response.txt" ), content );
114115 }
115116
116- @ Test
117117 @ DisplayName ("write to /foo.txt (non-existing)" )
118- public void testWriteToNewFile () throws IOException {
119- testWriteToNewFile (true );
120- }
121-
122- @ Test
123- @ DisplayName ("write to /foo.txt (non-existing)" )
124- public void testWriteToNewFileReplaceIsFalse () throws IOException {
125- testWriteToNewFile (false );
126- }
127-
128- private void testWriteToNewFile (boolean replace ) throws IOException {
118+ @ ParameterizedTest (name = "replace: {0}" )
119+ @ ValueSource (booleans = {true , false })
120+ public void testWriteToNewFile (boolean replace ) throws IOException {
129121 Mockito .when (webDavCompatibleHttpClient .execute (ArgumentMatchers .any ()))
130122 .thenReturn (getInterceptedResponse (baseUrl ))
131123 .thenReturn (getInterceptedResponse (baseUrl , "item-write-response.xml" ));
@@ -135,7 +127,7 @@ private void testWriteToNewFile(boolean replace) throws IOException {
135127 InputStream inputStream = getClass ().getResourceAsStream ("/progress-request-text.txt" );
136128 final var cloudItemMetadata = webDavClient .write (Path .of ("/foo.txt" ), replace , inputStream , ProgressListener .NO_PROGRESS_AWARE );
137129
138- Assert .assertEquals (writtenItemMetadata , cloudItemMetadata );
130+ Assertions .assertEquals (writtenItemMetadata , cloudItemMetadata );
139131 }
140132
141133 @ Test
@@ -148,7 +140,7 @@ public void testWriteToExistingFile() throws IOException {
148140
149141 Assertions .assertThrows (AlreadyExistsException .class , () -> {
150142 final var cloudItemMetadataUsingReplaceFalse = webDavClient .write (Path .of ("/foo.txt" ), false , inputStream , ProgressListener .NO_PROGRESS_AWARE );
151- Assert .assertNull (cloudItemMetadataUsingReplaceFalse );
143+ Assertions .assertNull (cloudItemMetadataUsingReplaceFalse );
152144 });
153145 }
154146
@@ -164,7 +156,7 @@ public void testWriteToAndReplaceExistingFile() throws IOException {
164156 InputStream inputStream = getClass ().getResourceAsStream ("/progress-request-text.txt" );
165157 final var cloudItemMetadata = webDavClient .write (Path .of ("/foo.txt" ), true , inputStream , ProgressListener .NO_PROGRESS_AWARE );
166158
167- Assert .assertEquals (writtenItemMetadata , cloudItemMetadata );
159+ Assertions .assertEquals (writtenItemMetadata , cloudItemMetadata );
168160 }
169161
170162 @ Test
@@ -175,7 +167,7 @@ public void testCreateFolder() throws IOException {
175167
176168 final var path = webDavClient .createFolder (Path .of ("/foo" ));
177169
178- Assert .assertEquals (Path .of ("/foo" ), path );
170+ Assertions .assertEquals (Path .of ("/foo" ), path );
179171 }
180172
181173 @ Test
@@ -204,7 +196,7 @@ public void testMoveToNonExisting() throws IOException {
204196
205197 final var targetPath = webDavClient .move (Path .of ("/foo" ), Path .of ("/bar" ), false );
206198
207- Assert .assertEquals (Path .of ("/bar" ), targetPath );
199+ Assertions .assertEquals (Path .of ("/bar" ), targetPath );
208200 }
209201
210202 @ Test
@@ -215,7 +207,7 @@ public void testMoveToExisting() throws IOException {
215207
216208 Assertions .assertThrows (AlreadyExistsException .class , () -> {
217209 final var targetPath = webDavClient .move (Path .of ("/foo" ), Path .of ("/bar" ), false );
218- Assert .assertNull (targetPath );
210+ Assertions .assertNull (targetPath );
219211 });
220212 }
221213
@@ -227,7 +219,7 @@ public void testMoveToAndReplaceExisting() throws IOException {
227219
228220 final var targetPath = webDavClient .move (Path .of ("/foo" ), Path .of ("/bar" ), true );
229221
230- Assert .assertEquals (Path .of ("/bar" ), targetPath );
222+ Assertions .assertEquals (Path .of ("/bar" ), targetPath );
231223 }
232224
233225 @ Test
0 commit comments