55import static org .junit .jupiter .api .Assertions .assertEquals ;
66
77class DifferTest {
8-
9- @ Test
10- void testGenerateDiffJson () throws IOException {
11- // Указываем пути к фикстурам
12- String filePath1 = "file1.json" ;
13- String filePath2 = "file2.json" ;
14-
15- // Ожидаемый результат сравнения JSON-файлов
16- String expectedDiff = """
8+ private static final String EXPECTED_DIFF = """
179 {
18- - follow: false
19- host: hexlet.io
20- - proxy: 123.234.53.22
21- - timeout: 50
22- + timeout: 20
23- + verbose: true
10+ chars1: [a, b, c]
11+ - chars2: [d, e, f]
12+ + chars2: false
13+ - checked: false
14+ + checked: true
15+ - default: null
16+ + default: [value1, value2]
17+ - id: 45
18+ + id: null
19+ - key1: value1
20+ + key2: value2
21+ numbers1: [1, 2, 3, 4]
22+ - numbers2: [2, 3, 4, 5]
23+ + numbers2: [22, 33, 44, 55]
24+ - numbers3: [3, 4, 5]
25+ + numbers4: [4, 5, 6]
26+ + obj1: {nestedKey=value, isNested=true}
27+ - setting1: Some value
28+ + setting1: Another value
29+ - setting2: 200
30+ + setting2: 300
31+ - setting3: true
32+ + setting3: none
2433 }
2534 """ ;
2635
27- // Запускаем метод сравнения
36+ @ Test
37+ void testGenerateDiffForJson () throws IOException {
38+ String filePath1 = "file1.json" ;
39+ String filePath2 = "file2.json" ;
2840 String actualDiff = Differ .generate (filePath1 , filePath2 );
29-
30- // Проверяем, что результат совпадает с ожидаемым
31- assertEquals (expectedDiff .trim (), actualDiff .trim ());
32- System .out .println ("ВСЕ РАБОТАЕТ!!" );
41+ assertEquals (EXPECTED_DIFF .trim (), actualDiff .trim ());
42+ System .out .println ("ВСЕ РАБОТАЕТ!" );
3343 }
3444
3545 @ Test
36- void testGenerateDiffYml () throws IOException {
37- // Указываем пути к фикстурам
46+ void testGenerateDiffForYaml () throws IOException {
3847 String filePath1 = "file1.yml" ;
3948 String filePath2 = "file2.yml" ;
40-
41- // Ожидаемый результат сравнения YML-файлов
42- String expectedDiff = """
43- {
44- - follow: false
45- host: hexlet.io
46- - proxy: 123.234.53.22
47- - timeout: 50
48- + timeout: 20
49- + verbose: true
50- }
51- """ ;
52-
53- // Запускаем метод сравнения
5449 String actualDiff = Differ .generate (filePath1 , filePath2 );
55-
56- // Проверяем, что результат совпадает с ожидаемым
57- assertEquals (expectedDiff .trim (), actualDiff .trim ());
50+ assertEquals (EXPECTED_DIFF .trim (), actualDiff .trim ());
5851 System .out .println ("ВСЕ РАБОТАЕТ! лала!" );
5952 }
60- }
53+
54+ }
55+
56+
57+
58+
59+ //
60+ //@Test
61+ //void testGenerateDiffJson() throws IOException {
62+ // // Указываем пути к фикстурам
63+ // String filePath1 = "file1.json";
64+ // String filePath2 = "file2.json";
65+ //
66+ // // Ожидаемый результат сравнения JSON-файлов
67+ // String expectedDiff = """
68+ // {
69+ // - follow: false
70+ // host: hexlet.io
71+ // - proxy: 123.234.53.22
72+ // - timeout: 50
73+ // + timeout: 20
74+ // + verbose: true
75+ // }
76+ // """;
77+ //
78+ // // Запускаем метод сравнения
79+ // String actualDiff = Differ.generate(filePath1, filePath2);
80+ //
81+ // // Проверяем, что результат совпадает с ожидаемым
82+ // assertEquals(expectedDiff.trim(), actualDiff.trim());
83+ // System.out.println("ВСЕ РАБОТАЕТ!!");
84+ //}
85+ //
86+ //@Test
87+ //void testGenerateDiffYml() throws IOException {
88+ // // Указываем пути к фикстурам
89+ // String filePath1 = "file1.yml";
90+ // String filePath2 = "file2.yml";
91+ //
92+ // // Ожидаемый результат сравнения YML-файлов
93+ // String expectedDiff = """
94+ // {
95+ // - follow: false
96+ // host: hexlet.io
97+ // - proxy: 123.234.53.22
98+ // - timeout: 50
99+ // + timeout: 20
100+ // + verbose: true
101+ // }
102+ // """;
103+ //
104+ // // Запускаем метод сравнения
105+ // String actualDiff = Differ.generate(filePath1, filePath2);
106+ //
107+ // // Проверяем, что результат совпадает с ожидаемым
108+ // assertEquals(expectedDiff.trim(), actualDiff.trim());
109+ // System.out.println("ВСЕ РАБОТАЕТ! лала!");
110+ //}
0 commit comments