88import io .frictionlessdata .datapackage .exceptions .DataPackageException ;
99import io .frictionlessdata .tableschema .schema .Schema ;
1010import io .frictionlessdata .tableschema .util .JsonUtil ;
11- import org .junit .Assert ;
12- import org .junit .Rule ;
1311import org .junit .jupiter .api .Assertions ;
1412import org .junit .jupiter .api .DisplayName ;
1513import org .junit .jupiter .api .Test ;
16- import org .junit .rules .ExpectedException ;
1714
1815import java .io .File ;
1916import java .math .BigInteger ;
@@ -46,9 +43,6 @@ public class ResourceTest {
4643 testResources .add (resource2 );
4744 }
4845
49- @ Rule
50- public final ExpectedException exception = ExpectedException .none ();
51-
5246 @ Test
5347 public void testIterateDataFromUrlPath () throws Exception {
5448
@@ -74,9 +68,9 @@ public void testIterateDataFromUrlPath() throws Exception{
7468 String year = record [1 ];
7569 String population = record [2 ];
7670
77- Assert .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
78- Assert .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
79- Assert .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
71+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
72+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
73+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
8074
8175 expectedDataIndex ++;
8276 }
@@ -103,9 +97,9 @@ public void testIterateDataFromFilePath() throws Exception{
10397 String year = record [1 ];
10498 String population = record [2 ];
10599
106- Assert .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
107- Assert .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
108- Assert .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
100+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
101+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
102+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
109103
110104 expectedDataIndex ++;
111105 }
@@ -146,8 +140,8 @@ public void testIterateDataFromMultipartFilePath() throws Exception{
146140 String city = record [0 ];
147141 String coords = record [1 ];
148142
149- Assert .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
150- Assert .assertEquals (expectedData .get (expectedDataIndex )[1 ], coords );
143+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
144+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[1 ], coords );
151145
152146 expectedDataIndex ++;
153147 }
@@ -190,8 +184,8 @@ public void testIterateDataFromMultipartURLPath() throws Exception{
190184 String city = record [0 ];
191185 String coords = record [1 ];
192186
193- Assert .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
194- Assert .assertEquals (expectedData .get (expectedDataIndex )[1 ], coords );
187+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
188+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[1 ], coords );
195189
196190 expectedDataIndex ++;
197191 }
@@ -216,9 +210,9 @@ public void testIterateDataWithCast() throws Exception{
216210 while (iter .hasNext ()){
217211 Object [] record = iter .next ();
218212
219- Assert .assertEquals (String .class , record [0 ].getClass ());
220- Assert .assertEquals (Year .class , record [1 ].getClass ());
221- Assert .assertEquals (BigInteger .class , record [2 ].getClass ());
213+ Assertions .assertEquals (String .class , record [0 ].getClass ());
214+ Assertions .assertEquals (Year .class , record [1 ].getClass ());
215+ Assertions .assertEquals (BigInteger .class , record [2 ].getClass ());
222216 }
223217 }
224218
@@ -245,9 +239,9 @@ public void testIterateDataFromCsvFormat() throws Exception{
245239 String year = record [1 ];
246240 String population = record [2 ];
247241
248- Assert .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
249- Assert .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
250- Assert .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
242+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
243+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
244+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
251245
252246 expectedDataIndex ++;
253247 }
@@ -273,9 +267,9 @@ public void testBuildAndIterateDataFromCsvFormat() throws Exception{
273267 String year = record [1 ];
274268 String population = record [2 ];
275269
276- Assert .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
277- Assert .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
278- Assert .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
270+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
271+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
272+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
279273
280274 expectedDataIndex ++;
281275 }
@@ -300,9 +294,9 @@ public void testBuildAndIterateDataFromTabseparatedCsvFormat() throws Exception{
300294 String year = record [1 ];
301295 String population = record [2 ];
302296
303- Assert .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
304- Assert .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
305- Assert .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
297+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
298+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
299+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
306300
307301 expectedDataIndex ++;
308302 }
@@ -351,9 +345,9 @@ public void testIterateDataFromJSONFormat() throws Exception{
351345 String year = record [1 ];
352346 String population = record [2 ];
353347
354- Assert .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
355- Assert .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
356- Assert .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
348+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
349+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
350+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
357351
358352 expectedDataIndex ++;
359353 }
@@ -402,9 +396,9 @@ public void testIterateDataFromJSONFormatAlternateSchema() throws Exception{
402396 String year = record [1 ];
403397 String population = record [2 ];
404398
405- Assert .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
406- Assert .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
407- Assert .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
399+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
400+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
401+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
408402
409403 expectedDataIndex ++;
410404 }
@@ -430,43 +424,14 @@ public void testBuildAndIterateDataFromJSONFormat() throws Exception{
430424 String year = record [1 ];
431425 String population = record [2 ];
432426
433- Assert .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
434- Assert .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
435- Assert .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
427+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[0 ], city );
428+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[1 ], year );
429+ Assertions .assertEquals (expectedData .get (expectedDataIndex )[2 ], population );
436430
437431 expectedDataIndex ++;
438432 }
439433 }
440434
441-
442- /*
443- FIXME: since strongly typed, those don't work anymore
444- @Test
445- public void testCreatingJSONResourceWithInvalidFormatNullValue() throws Exception {
446- URL url = new URL("https://raw.githubusercontent.com/frictionlessdata/" +
447- "datapackage-java/master/src/test/resources/fixtures/multi_data_datapackage.json");
448- Package dp = new Package(url, true);
449-
450- // format property is null but data is not null.
451- Resource resource = new JSONDataResource("resource-name", testResources, (String)null);
452-
453- exception.expectMessage("Invalid Resource. The data and format properties cannot be null.");
454- dp.addResource(resource);
455- }
456-
457- @Test
458- public void testCreatingResourceWithInvalidFormatDataValue() throws Exception {
459- URL url = new URL("https://raw.githubusercontent.com/frictionlessdata/datapackage-java/master/src/test/resources/fixtures/multi_data_datapackage.json");
460- Package dp = new Package(url, true);
461-
462- // data property is null but format is not null.
463- Resource resource = new JSONDataResource("resource-name", (String)null, "csv");
464-
465- exception.expectMessage("Invalid Resource. The path property or the data and format properties cannot be null.");
466- dp.addResource(resource);
467- }
468-
469- */
470435 @ Test
471436 public void testRead () throws Exception {
472437 Resource resource = buildResource ("/fixtures/data/population.csv" );
@@ -475,7 +440,7 @@ public void testRead() throws Exception{
475440 resource .setProfile (Profile .PROFILE_TABULAR_DATA_RESOURCE );
476441
477442 // Assert
478- Assert .assertEquals (3 , resource .getData (false , false , false , false ).size ());
443+ Assertions .assertEquals (3 , resource .getData (false , false , false , false ).size ());
479444 }
480445
481446 @ Test
@@ -496,9 +461,9 @@ public void testHeadings() throws Exception{
496461 resource .setProfile (Profile .PROFILE_TABULAR_DATA_RESOURCE );
497462
498463 // Assert
499- Assert .assertEquals ("city" , resource .getHeaders ()[0 ]);
500- Assert .assertEquals ("year" , resource .getHeaders ()[1 ]);
501- Assert .assertEquals ("population" , resource .getHeaders ()[2 ]);
464+ Assertions .assertEquals ("city" , resource .getHeaders ()[0 ]);
465+ Assertions .assertEquals ("year" , resource .getHeaders ()[1 ]);
466+ Assertions .assertEquals ("population" , resource .getHeaders ()[2 ]);
502467 }
503468
504469
0 commit comments