File tree Expand file tree Collapse file tree 2 files changed +5
-28
lines changed
algorithm-exercises-java/src/test/java/ae/hackerrank/interview_preparation_kit/arrays Expand file tree Collapse file tree 2 files changed +5
-28
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import static org .junit .jupiter .api .Assertions .assertEquals ;
4
4
5
- import com .fasterxml .jackson .databind .ObjectMapper ;
6
- import java .io .File ;
7
5
import java .io .IOException ;
8
6
import java .util .List ;
9
7
import org .junit .jupiter .api .BeforeAll ;
10
8
import org .junit .jupiter .api .Test ;
11
9
import org .junit .jupiter .api .TestInstance ;
12
10
import org .junit .jupiter .api .TestInstance .Lifecycle ;
13
-
11
+ import util . JsonLoader ;
14
12
15
13
@ TestInstance (Lifecycle .PER_CLASS )
16
14
class CrushBruteForceTest {
@@ -26,22 +24,12 @@ public static class CrushBruteForceTestCase {
26
24
27
25
@ BeforeAll
28
26
public void setup () throws IOException {
29
- ObjectMapper objectMapper = new ObjectMapper ();
30
27
31
28
String path = String .join ("/" , "hackerrank" ,
32
29
"interview_preparation_kit" ,
33
30
"arrays" ,
34
31
"crush.testcases.json" );
35
- File file = new File (
36
- this .getClass ()
37
- .getClassLoader ()
38
- .getResource (path )
39
- .getFile ()
40
- );
41
-
42
- ObjectMapper mapper = new ObjectMapper ();
43
- this .testCases = mapper .readerForListOf (CrushBruteForceTestCase .class )
44
- .readValue (objectMapper .readTree (file ));
32
+ this .testCases = JsonLoader .loadJson (path , CrushBruteForceTestCase .class );
45
33
}
46
34
47
35
@ Test void testArrayManipulation () {
Original file line number Diff line number Diff line change 2
2
3
3
import static org .junit .jupiter .api .Assertions .assertEquals ;
4
4
5
- import com .fasterxml .jackson .databind .ObjectMapper ;
6
- import java .io .File ;
7
5
import java .io .IOException ;
8
6
import java .util .List ;
9
7
import org .junit .jupiter .api .BeforeAll ;
10
8
import org .junit .jupiter .api .Test ;
11
9
import org .junit .jupiter .api .TestInstance ;
12
10
import org .junit .jupiter .api .TestInstance .Lifecycle ;
11
+ import util .JsonLoader ;
13
12
14
13
15
14
@ TestInstance (Lifecycle .PER_CLASS )
@@ -26,22 +25,12 @@ public static class CrushTestCase {
26
25
27
26
@ BeforeAll
28
27
public void setup () throws IOException {
29
- ObjectMapper objectMapper = new ObjectMapper ();
30
-
31
28
String path = String .join ("/" , "hackerrank" ,
32
29
"interview_preparation_kit" ,
33
30
"arrays" ,
34
31
"crush.testcases.json" );
35
- File file = new File (
36
- this .getClass ()
37
- .getClassLoader ()
38
- .getResource (path )
39
- .getFile ()
40
- );
41
-
42
- ObjectMapper mapper = new ObjectMapper ();
43
- this .testCases = mapper .readerForListOf (CrushTestCase .class )
44
- .readValue (objectMapper .readTree (file ));
32
+
33
+ this .testCases = JsonLoader .loadJson (path , CrushTestCase .class );
45
34
}
46
35
47
36
@ Test void testArrayManipulation () {
You can’t perform that action at this time.
0 commit comments