1
1
package org .dflib .jjava .jupyter .kernel .display ;
2
2
3
3
import org .dflib .jjava .jupyter .kernel .display .mime .MIMEType ;
4
- import org .junit .Test ;
5
- import org .junit .runner .RunWith ;
6
- import org .junit .runners .Parameterized ;
4
+ import org .junit .jupiter .api .Assertions ;
5
+ import org .junit .jupiter .params .ParameterizedTest ;
6
+ import org .junit .jupiter .params .provider .Arguments ;
7
+ import org .junit .jupiter .params .provider .MethodSource ;
7
8
8
- import java .util .Arrays ;
9
- import java .util .Collection ;
10
- import java .util .Collections ;
11
9
import java .util .List ;
10
+ import java .util .stream .Stream ;
12
11
13
- import static org .junit .Assert .assertEquals ;
14
-
15
- @ RunWith (Parameterized .class )
16
12
public class RenderRequestTypesResolutionTest {
17
- @ Parameterized .Parameters
18
- public static Collection <Object []> data () {
19
- return Arrays .asList (new Object [][]{
20
- { "image/svg+xml" , "image/svg+xml" , Collections .singletonList ("image/svg+xml" ) },
21
- { "image/svg+xml" , "image/svg" , Collections .singletonList ("image/svg" ) },
22
- { "image/svg+xml" , "image/svg+xml" , Collections .singletonList ("image/*" ) },
23
- { "image/svg+xml" , "image/svg+xml" , Collections .singletonList ("image" ) },
24
- { "image/svg+xml" , "application/xml" , Collections .singletonList ("application/xml" ) },
25
- { "image/svg+xml" , "application/xml" , Collections .singletonList ("application/*" ) },
26
- { "image/svg+xml" , "application/xml" , Collections .singletonList ("application" ) },
27
- { "image/svg+xml" , "image/svg+xml" , Collections .singletonList ("*" ) },
28
-
29
- { "image/svg" , "image/svg" , Collections .singletonList ("image/svg" ) },
30
-
31
- { "image/svg" , null , Collections .singletonList ("application/xml" ) },
32
- { "image/svg+xml" , null , Collections .singletonList ("application/json" ) },
33
- });
34
- }
35
-
36
- private final MIMEType supported ;
37
- private final MIMEType expected ;
38
- private final RenderRequestTypes requestTypes ;
39
-
40
- public RenderRequestTypesResolutionTest (String supported , String expected , List <String > requestTypes ) {
41
- this .supported = supported == null ? null : MIMEType .parse (supported );
42
- this .expected = expected == null ? null : MIMEType .parse (expected );
43
13
14
+ @ ParameterizedTest
15
+ @ MethodSource ("data" )
16
+ public void test (String supported , String expected , List <String > requestTypes ) {
17
+ MIMEType supportedMime = MIMEType .parse (supported );
18
+ MIMEType expectedMime = expected == null ? null : MIMEType .parse (expected );
44
19
RenderRequestTypes .Builder builder = new RenderRequestTypes .Builder (group -> {
45
20
switch (group ) {
46
21
case "xml" :
@@ -54,13 +29,26 @@ public RenderRequestTypesResolutionTest(String supported, String expected, List<
54
29
requestTypes .stream ()
55
30
.map (MIMEType ::parse )
56
31
.forEach (builder ::withType );
57
- this .requestTypes = builder .build ();
58
- }
32
+ RenderRequestTypes renderRequestTypes = builder .build ();
59
33
60
- @ Test
61
- public void test () {
62
- MIMEType actual = this .requestTypes .resolveSupportedType (this .supported );
34
+ MIMEType actualMime = renderRequestTypes .resolveSupportedType (supportedMime );
35
+
36
+ Assertions .assertEquals (expectedMime , actualMime );
37
+ }
63
38
64
- assertEquals (expected , actual );
39
+ public static Stream <Arguments > data () {
40
+ return Stream .of (
41
+ Arguments .of ("image/svg+xml" , "image/svg+xml" , List .of ("image/svg+xml" )),
42
+ Arguments .of ("image/svg+xml" , "image/svg" , List .of ("image/svg" )),
43
+ Arguments .of ("image/svg+xml" , "image/svg+xml" , List .of ("image/*" )),
44
+ Arguments .of ("image/svg+xml" , "image/svg+xml" , List .of ("image" )),
45
+ Arguments .of ("image/svg+xml" , "application/xml" , List .of ("application/xml" )),
46
+ Arguments .of ("image/svg+xml" , "application/xml" , List .of ("application/*" )),
47
+ Arguments .of ("image/svg+xml" , "application/xml" , List .of ("application" )),
48
+ Arguments .of ("image/svg+xml" , "image/svg+xml" , List .of ("*" )),
49
+ Arguments .of ("image/svg" , "image/svg" , List .of ("image/svg" )),
50
+ Arguments .of ("image/svg" , null , List .of ("application/xml" )),
51
+ Arguments .of ("image/svg+xml" , null , List .of ("application/json" ))
52
+ );
65
53
}
66
- }
54
+ }
0 commit comments