diff --git a/README.md b/README.md index 67dac7b..d9c2127 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,5 @@ [![Maintainability](https://api.codeclimate.com/v1/badges/441c3660842a050f496d/maintainability)](https://codeclimate.com/github/SaliAbdullaeva/java-project-71/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/441c3660842a050f496d/test_coverage)](https://codeclimate.com/github/SaliAbdullaeva/java-project-71/test_coverage) [![asciicast](https://asciinema.org/a/673710.svg)](https://asciinema.org/a/673710) -[![asciicast](https://asciinema.org/a/674626.svg)](https://asciinema.org/a/674626) \ No newline at end of file +[![asciicast](https://asciinema.org/a/674626.svg)](https://asciinema.org/a/674626) +[![asciicast](https://asciinema.org/a/675009.svg)](https://asciinema.org/a/675009) \ No newline at end of file diff --git a/app/src/main/java/hexlet/code/App.java b/app/src/main/java/hexlet/code/App.java index efa5d73..4427d07 100644 --- a/app/src/main/java/hexlet/code/App.java +++ b/app/src/main/java/hexlet/code/App.java @@ -10,33 +10,39 @@ @Command(name = "gendiff", mixinStandardHelpOptions = true, - description = "Calculates the differences between files.") + description = "Compares two configuration files and shows a difference.") +public final class App implements Callable { + private static final int SUCCESS_EXIT_CODE = 0; + private static final int ERROR_EXIT_CODE = 15; -public class App implements Callable { - - @Option(names = {"-f", "--format"}, paramLabel = "format", description = "output format [default: stylish]") - String format = "stylish"; @Parameters(index = "0", paramLabel = "filepath1", description = "Path to first file") - String filepath1; + private String filePath1; + @Parameters(index = "1", paramLabel = "filepath2", description = "Path to second file") - String filepath2; + private String filePath2; + + @Option(names = {"-f", "--format"}, + paramLabel = "format", + description = "output format [default: stylish]", + defaultValue = "stylish") + private String format; @Override public Integer call() { try { - String result = Differ.generate(filepath1, filepath2, format); + String result = Differ.generate(filePath1, filePath2, format); System.out.println(result); - return 0; // Успешное завершение } catch (IOException e) { - System.err.println("Error processing files: " + e.getMessage()); - return 2; // Код ошибки - } catch (Exception e) { - System.err.println("Unexpected error: " + e.getMessage()); - return 1; // Код ошибки + System.out.println(e.getMessage()); + return ERROR_EXIT_CODE; } + + return SUCCESS_EXIT_CODE; } + public static void main(String[] args) { int exitCode = new CommandLine(new App()).execute(args); System.exit(exitCode); } + } diff --git a/app/src/main/java/hexlet/code/Differ.java b/app/src/main/java/hexlet/code/Differ.java index 3924736..2d8cdc4 100644 --- a/app/src/main/java/hexlet/code/Differ.java +++ b/app/src/main/java/hexlet/code/Differ.java @@ -1,103 +1,32 @@ package hexlet.code; +import java.io.IOException; import java.nio.file.Path; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -public class Differ { - public static String generate(String filePath1, String filePath2, String format) throws Exception { - // Чтение содержимого файлов - String fileContent1 = ReadFile.readFile(Path.of(filePath1)); - String fileContent2 = ReadFile.readFile(Path.of(filePath2)); +import java.util.Map; +import java.util.List; - // Получение расширения файлов для парсинга - String extension1 = ReadFile.getFileExtension(Path.of(filePath1)); - String extension2 = ReadFile.getFileExtension(Path.of(filePath2)); +public final class Differ { - // Парсинг содержимого файлов в Map - Map map1 = Parser.parseString(fileContent1, extension1); - Map map2 = Parser.parseString(fileContent2, extension2); + public static String generate(String filePath1, String filePath2, String format) throws IOException { + Path path1 = Reader.getPath(filePath1); + Path path2 = Reader.getPath(filePath2); - // Создание отсортированного набора ключей - Set allKeys = new TreeSet<>(); - allKeys.addAll(map1.keySet()); - allKeys.addAll(map2.keySet()); + Map data1 = Parser.parseString( + Reader.readFile(path1), + Reader.getFileExtension(path1) + ); + Map data2 = Parser.parseString( + Reader.readFile(path2), + Reader.getFileExtension(path2) + ); - // Формирование результата в зависимости от формата - return switch (format) { - case "plain" -> formatPlain(allKeys, map1, map2); - case "json" -> formatJson(allKeys, map1, map2); - default -> formatStylish(allKeys, map1, map2); // формат по умолчанию - }; + List> differDifferNodeList = DifferListComposer.composeList(data1, data2); + return Formatter.formatString(differDifferNodeList, format); } - private static String formatStylish(Set allKeys, Map map1, Map map2) { - StringBuilder result = new StringBuilder("{\n"); - - for (String key : allKeys) { - Object value1 = map1.get(key); - Object value2 = map2.get(key); - - if (value1 == null && value2 != null) { - result.append(" + ").append(key).append(": ").append(value2).append("\n"); - } else if (value1 != null && value2 == null) { - result.append(" - ").append(key).append(": ").append(value1).append("\n"); - } else if (value1 != null && value2 != null && !value1.equals(value2)) { - result.append(" - ").append(key).append(": ").append(value1).append("\n"); - result.append(" + ").append(key).append(": ").append(value2).append("\n"); - } else if (value1 != null && value2 != null && value1.equals(value2)) { - result.append(" ").append(key).append(": ").append(value1).append("\n"); - } - } - - result.append("}"); - return result.toString(); + public static String generate(String filePath1, String filePath2) throws IOException { + return generate(filePath1, filePath2, "stylish"); } - private static String formatPlain(Set allKeys, Map map1, Map map2) { - StringBuilder result = new StringBuilder(); - - for (String key : allKeys) { - Object value1 = map1.get(key); - Object value2 = map2.get(key); - - if (value1 == null) { - result.append("Property '").append(key).append("' was added with value: ").append(value2).append("\n"); - } else if (value2 == null) { - result.append("Property '").append(key).append("' was removed").append("\n"); - } else if (!value1.equals(value2)) { - result.append("Property '").append(key).append("' was updated. From ").append(value1).append(" to ").append(value2).append("\n"); - } - } - - return result.toString().trim(); - } - - private static String formatJson(Set allKeys, Map map1, Map map2) { - StringBuilder result = new StringBuilder("{"); - - for (String key : allKeys) { - Object value1 = map1.get(key); - Object value2 = map2.get(key); - - if (value1 == null) { - result.append("\"").append(key).append("\": ").append(value2).append(", "); - } else if (value2 == null) { - result.append("\"").append(key).append("\": ").append(value1).append(", "); - } else if (!value1.equals(value2)) { - result.append("\"").append(key).append("\": ").append(value2).append(", "); - } else { - result.append("\"").append(key).append("\": ").append(value1).append(", "); - } - } - - // Удаляем последнюю запятую и пробел, если они есть - if (result.length() > 1) { - result.setLength(result.length() - 2); - } - - result.append("}"); - return result.toString(); - } -} +} \ No newline at end of file diff --git a/app/src/main/java/hexlet/code/DifferListComposer.java b/app/src/main/java/hexlet/code/DifferListComposer.java new file mode 100644 index 0000000..5f75e5d --- /dev/null +++ b/app/src/main/java/hexlet/code/DifferListComposer.java @@ -0,0 +1,54 @@ +package hexlet.code; + +import java.util.Optional; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.LinkedHashMap; +import java.util.Set; +import java.util.TreeSet; + +public final class DifferListComposer { + + public static List> composeList( + Map data1, + Map data2 + ) { + List> differNodeList = new ArrayList<>(); + + Set keys = new TreeSet<>(data1.keySet()); + keys.addAll(data2.keySet()); + for (String key : keys) { + differNodeList.add(makeDifferNode(key, data1, data2)); + } + + return differNodeList; + } + + private static Map makeDifferNode( + String key, + Map data1, + Map data2 + ) { + Map differNode = new LinkedHashMap<>(); + Optional value1 = Optional.ofNullable(data1.get(key)); + Optional value2 = Optional.ofNullable(data2.get(key)); + + differNode.put("key", key); + if (!data1.containsKey(key)) { + differNode.put("condition", "ADDED"); + differNode.put("value", value2.orElse(null)); + } else if (!data2.containsKey(key)) { + differNode.put("condition", "DELETED"); + differNode.put("value", value1.orElse(null)); + } else if (value1.equals(value2)) { + differNode.put("condition", "UNCHANGED"); + differNode.put("value", value1.orElse(null)); + } else { + differNode.put("condition", "CHANGED"); + differNode.put("value1", value1.orElse(null)); + differNode.put("value2", value2.orElse(null)); + } + return differNode; + } +} \ No newline at end of file diff --git a/app/src/main/java/hexlet/code/Formatter.java b/app/src/main/java/hexlet/code/Formatter.java new file mode 100644 index 0000000..56197b2 --- /dev/null +++ b/app/src/main/java/hexlet/code/Formatter.java @@ -0,0 +1,29 @@ +package hexlet.code; + +import hexlet.code.formatters.Json; +import hexlet.code.formatters.StringFormatter; +import hexlet.code.formatters.Stylish; +import hexlet.code.formatters.Plain; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +public final class Formatter { + + public static String formatString(List> differEntryList, String format) throws IOException { + StringFormatter formatter = getFormatter(format); + return formatter.format(differEntryList); + } + + private static StringFormatter getFormatter(String format) throws IOException { + return switch (format) { + case "stylish" -> new Stylish(); + case "plain" -> new Plain(); + case "json" -> new Json(); + default -> + throw new IOException("File should have 'stylish', 'plain' or 'json' format! (was '%s')" + .formatted(format)); + }; + } +} \ No newline at end of file diff --git a/app/src/main/java/hexlet/code/ReadFile.java b/app/src/main/java/hexlet/code/Reader.java similarity index 97% rename from app/src/main/java/hexlet/code/ReadFile.java rename to app/src/main/java/hexlet/code/Reader.java index 1fe0de7..519b6e8 100644 --- a/app/src/main/java/hexlet/code/ReadFile.java +++ b/app/src/main/java/hexlet/code/Reader.java @@ -5,7 +5,7 @@ import java.nio.file.Paths; import java.nio.file.Files; -class ReadFile { +class Reader { public static String readFile(Path filePath) throws IOException { return Files.readString(filePath); } diff --git a/app/src/main/java/hexlet/code/formatters/Json.java b/app/src/main/java/hexlet/code/formatters/Json.java new file mode 100644 index 0000000..ec86306 --- /dev/null +++ b/app/src/main/java/hexlet/code/formatters/Json.java @@ -0,0 +1,16 @@ +package hexlet.code.formatters; + +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; + +import java.util.List; +import java.util.Map; + +public final class Json implements StringFormatter { + + @Override + public String format(List> differNodeList) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.writeValueAsString(differNodeList); + } +} \ No newline at end of file diff --git a/app/src/main/java/hexlet/code/formatters/Plain.java b/app/src/main/java/hexlet/code/formatters/Plain.java new file mode 100644 index 0000000..803c693 --- /dev/null +++ b/app/src/main/java/hexlet/code/formatters/Plain.java @@ -0,0 +1,51 @@ +package hexlet.code.formatters; + +import java.util.List; +import java.util.Map; + +public final class Plain implements StringFormatter { + + @Override + public String format(List> differNodeList) { + List> filteredList = differNodeList.stream() + .filter(node -> !node.get("condition").equals("UNCHANGED")) + .toList(); + + StringBuilder sb = new StringBuilder(); + + for (Map node : filteredList) { + String condition = (String) node.get("condition"); + switch (condition) { + case "ADDED" -> { + String value = formatComplexValue(node.get("value")); + sb.append("Property '%s' was added with value: %s%n" + .formatted(node.get("key"), value)); + } + case "DELETED" -> sb.append("Property '%s' was removed%n" + .formatted(node.get("key"))); + case "CHANGED" -> { + String value1 = formatComplexValue(node.get("value1")); + String value2 = formatComplexValue(node.get("value2")); + sb.append("Property '%s' was updated. From %s to %s%n" + .formatted(node.get("key"), value1, value2)); + } + default -> throw new IllegalStateException("Unexpected value: " + condition); + } + } + + return sb.deleteCharAt(sb.length() - 1).toString(); + } + + private static String formatComplexValue(Object value) { + if (value == null) { + return null; + } + if (value instanceof List || value instanceof Map) { + return "[complex value]"; + } + if (value instanceof String) { + return String.format("'%s'", value); + } + return value.toString(); + } +} \ No newline at end of file diff --git a/app/src/main/java/hexlet/code/formatters/StringFormatter.java b/app/src/main/java/hexlet/code/formatters/StringFormatter.java new file mode 100644 index 0000000..63c469f --- /dev/null +++ b/app/src/main/java/hexlet/code/formatters/StringFormatter.java @@ -0,0 +1,9 @@ +package hexlet.code.formatters; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +public interface StringFormatter { + String format(List> differEntryList) throws IOException; +} \ No newline at end of file diff --git a/app/src/main/java/hexlet/code/formatters/Stylish.java b/app/src/main/java/hexlet/code/formatters/Stylish.java new file mode 100644 index 0000000..edcf5d6 --- /dev/null +++ b/app/src/main/java/hexlet/code/formatters/Stylish.java @@ -0,0 +1,36 @@ +package hexlet.code.formatters; + +import java.util.List; +import java.util.Map; + + +public final class Stylish implements StringFormatter { + + @Override + public String format(List> differDifferNodeList) { + StringBuilder sb = new StringBuilder("{\n"); + final int indentation = 2; + + for (Map node : differDifferNodeList) { + String condition = (String) node.get("condition"); + switch (condition) { + case "ADDED" -> sb.append(" ".repeat(indentation)) + .append("+ %s: %s%n".formatted(node.get("key"), node.get("value"))); + case "DELETED" -> sb.append(" ".repeat(indentation)) + .append("- %s: %s%n".formatted(node.get("key"), node.get("value"))); + case "CHANGED" -> { + sb.append(" ".repeat(indentation)) + .append("- %s: %s%n".formatted(node.get("key"), node.get("value1"))); + sb.append(" ".repeat(indentation)) + .append("+ %s: %s%n".formatted(node.get("key"), node.get("value2"))); + } + case "UNCHANGED" -> sb.append(" ".repeat(indentation)) + .append(" %s: %s%n".formatted(node.get("key"), node.get("value"))); + default -> throw new IllegalStateException("Unexpected value: " + condition); + } + } + sb.append("}"); + + return sb.toString(); + } +} \ No newline at end of file diff --git a/app/src/test/java/hexlet/code/AppTest.java b/app/src/test/java/hexlet/code/AppTest.java index ff4a964..e34155e 100644 --- a/app/src/test/java/hexlet/code/AppTest.java +++ b/app/src/test/java/hexlet/code/AppTest.java @@ -29,12 +29,12 @@ public final class AppTest { @BeforeEach void setUp() throws Exception { System.setOut(new PrintStream(output)); - Path pathStylish = ReadFile.getPath(getPathToFixture("EXPECTED_STYLISH")); - expectedStylish = ReadFile.readFile(pathStylish); - Path pathPlain = ReadFile.getPath(getPathToFixture("EXPECTED_PLAIN")); - expectedPlain = ReadFile.readFile(pathPlain); - Path pathJson = ReadFile.getPath(getPathToFixture("EXPECTED_JSON")); - expectedJson = ReadFile.readFile(pathJson); + Path pathStylish = Reader.getPath(getPathToFixture("EXPECTED_STYLISH")); + expectedStylish = Reader.readFile(pathStylish); + Path pathPlain = Reader.getPath(getPathToFixture("EXPECTED_PLAIN")); + expectedPlain = Reader.readFile(pathPlain); + Path pathJson = Reader.getPath(getPathToFixture("EXPECTED_JSON")); + expectedJson = Reader.readFile(pathJson); } @Test @@ -53,8 +53,8 @@ void testSuccessExitCode() throws Exception { String[] argsYamlPlain = new String[]{ "-f=plain", - getPathToFixture("fileNested1.yml"), - getPathToFixture("fileNested2.yaml") + getPathToFixture("fileNested3.yml"), + getPathToFixture("fileNested4.yml") }; int exitCode2 = new CommandLine(new App()).execute(argsYamlPlain); assertEquals(expectedPlain, output.toString(StandardCharsets.UTF_8).trim()); @@ -64,7 +64,7 @@ void testSuccessExitCode() throws Exception { String[] argsYamlJson = new String[]{ "-f=json", - getPathToFixture("fileNested1.yml"), + getPathToFixture("fileNested3.yml"), getPathToFixture("fileNested2.json") }; int exitCode3 = new CommandLine(new App()).execute(argsYamlJson); @@ -86,8 +86,8 @@ void testErrorExitCode() { String[] argsFileNotExist = new String[]{ "-f=stylish", - getPathToFixture("fil.yml"), - getPathToFixture("fileNested2.yaml") + getPathToFixture("file.yml"), + getPathToFixture("fileNested3.yml") }; int exitCode3 = new CommandLine(new App()).execute(argsFileNotExist); assertEquals(ERROR_EXIT_CODE, exitCode3); diff --git a/app/src/test/java/hexlet/code/DifferTest.java b/app/src/test/java/hexlet/code/DifferTest.java index 78dcfaa..099ebc3 100644 --- a/app/src/test/java/hexlet/code/DifferTest.java +++ b/app/src/test/java/hexlet/code/DifferTest.java @@ -1,55 +1,100 @@ package hexlet.code; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.skyscreamer.jsonassert.JSONAssert; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import static org.junit.jupiter.api.Assertions.*; -public class DifferTest { +import java.nio.file.Path; + +public final class DifferTest { + private String expectedStylish; + private String expectedPlain; + private String expectedJson; - private static String readFileFromResources(String fileName) throws IOException { - return new String(Files.readAllBytes(Paths.get("src/test/resources/" + fileName))); + @BeforeEach + void setUp() throws Exception { + Path validPathStylish = Reader.getPath(getPathToFixture("EXPECTED_STYLISH")); + expectedStylish = Reader.readFile(validPathStylish); + Path validPathPlain = Reader.getPath(getPathToFixture("EXPECTED_PLAIN")); + expectedPlain = Reader.readFile(validPathPlain); + Path validPathJson = Reader.getPath(getPathToFixture("EXPECTED_JSON")); + expectedJson = Reader.readFile(validPathJson); } @Test - public void testGenerateJsonWithDifferences() throws Exception { - // Используем файлы из ресурсов - String filePath1 = "testFile1.json"; - String filePath2 = "testFile2.json"; - - // Ожидаемый результат - String expectedJson = "{\n" + - " - key2: \"value2\"\n" + - " + key3: \"value3\"\n" + - " key1: \"value1\"\n" + - "}"; - - // Выполняем метод и проверяем результат - String result = Differ.generate(readFileFromResources(filePath1), readFileFromResources(filePath2)); - assertEquals(expectedJson, result); + @DisplayName("'generate' method using two arguments works correctly") + void testGenerateWithTwoArgs() throws Exception { + String actualStylish = Differ.generate( + getPathToFixture("fileNested1.json"), + getPathToFixture("fileNested3.yml") + ); + + assertEquals(expectedStylish, actualStylish); } + @Test - public void testGenerateJsonNoDifferences() throws Exception { - // Используем файлы из ресурсов - String filePath1 = "testFile1.json"; - String filePath2 = "testFile2.json"; - - // Ожидаемый результат - String expectedJson = "{\n" + - " key1: \"value1\"\n" + - " key2: \"value2\"\n" + - "}"; - - // Выполняем метод и проверяем результат - String result = Differ.generate(readFileFromResources(filePath1), readFileFromResources(filePath2)); - assertEquals(expectedJson, result); + @DisplayName("'generate' method using three arguments works correctly") + void testGenerateWithThreeArgs() throws Exception { + String actualStylish = Differ.generate( + getPathToFixture("fileNested1.json"), + getPathToFixture("fileNested3.yml"), + "stylish" + ); + assertEquals(expectedStylish, actualStylish); } @Test - public void testGenerateJsonEmptyFiles() throws Exception { - // Используем файлы из ресурсов - String filePath1 = "emptyFile.json"; + @DisplayName("'generate' method with JSON files works correctly") + void testGenerateWithJson() throws Exception { + String actualStylish = Differ.generate( + getPathToFixture("fileNested1.json"), + getPathToFixture("fileNested2.json"), + "stylish" + ); + assertEquals(expectedStylish, actualStylish); + String actualPlain = Differ.generate( + getPathToFixture("fileNested1.json"), + getPathToFixture("fileNested2.json"), + "plain" + ); + assertEquals(expectedPlain, actualPlain); + String actualJson = Differ.generate( + getPathToFixture("fileNested1.json"), + getPathToFixture("fileNested2.json"), + "json" + ); + JSONAssert.assertEquals(expectedJson, actualJson, JSONCompareMode.STRICT); + } + + @Test + @DisplayName("'generate' method with YAML files works correctly") + void testGenerateWithYaml() throws Exception { + String actualStylish = Differ.generate( + getPathToFixture("fileNested3.yml"), + getPathToFixture("fileNested4.yml"), + "stylish" + ); + assertEquals(expectedStylish, actualStylish); + String actualPlain = Differ.generate( + getPathToFixture("fileNested3.yml"), + getPathToFixture("fileNested4.yml"), + "plain" + ); + assertEquals(expectedPlain, actualPlain); + String actualJson = Differ.generate( + getPathToFixture("fileNested3.yml"), + getPathToFixture("fileNested4.yml"), + "json" + ); + JSONAssert.assertEquals(expectedJson, actualJson, JSONCompareMode.STRICT); + } + + private String getPathToFixture(String file) { + return "./src/test/resources/" + file; } -} +} \ No newline at end of file diff --git a/app/src/test/resources/EXPECTED_JSON b/app/src/test/resources/EXPECTED_JSON new file mode 100644 index 0000000..5e75eab --- /dev/null +++ b/app/src/test/resources/EXPECTED_JSON @@ -0,0 +1 @@ +[{"key":"chars1","condition":"UNCHANGED","value":["a","b","c"]},{"key":"chars2","condition":"CHANGED","value1":["d","e","f"],"value2":false},{"key":"checked","condition":"CHANGED","value1":false,"value2":true},{"key":"default","condition":"CHANGED","value1":null,"value2":["value1","value2"]},{"key":"id","condition":"CHANGED","value1":45,"value2":null},{"key":"key1","condition":"DELETED","value":"value1"},{"key":"key2","condition":"ADDED","value":"value2"},{"key":"numbers1","condition":"UNCHANGED","value":[1,2,3,4]},{"key":"numbers2","condition":"CHANGED","value1":[2,3,4,5],"value2":[22,33,44,55]},{"key":"numbers3","condition":"DELETED","value":[3,4,5]},{"key":"numbers4","condition":"ADDED","value":[4,5,6]},{"key":"obj1","condition":"ADDED","value":{"nestedKey":"value","isNested":true}},{"key":"setting1","condition":"CHANGED","value1":"Some value","value2":"Another value"},{"key":"setting2","condition":"CHANGED","value1":200,"value2":300},{"key":"setting3","condition":"CHANGED","value1":true,"value2":"none"}] \ No newline at end of file diff --git a/app/src/test/resources/EXPECTED_PLAIN b/app/src/test/resources/EXPECTED_PLAIN new file mode 100644 index 0000000..8038f7c --- /dev/null +++ b/app/src/test/resources/EXPECTED_PLAIN @@ -0,0 +1,13 @@ +Property 'chars2' was updated. From [complex value] to false +Property 'checked' was updated. From false to true +Property 'default' was updated. From null to [complex value] +Property 'id' was updated. From 45 to null +Property 'key1' was removed +Property 'key2' was added with value: 'value2' +Property 'numbers2' was updated. From [complex value] to [complex value] +Property 'numbers3' was removed +Property 'numbers4' was added with value: [complex value] +Property 'obj1' was added with value: [complex value] +Property 'setting1' was updated. From 'Some value' to 'Another value' +Property 'setting2' was updated. From 200 to 300 +Property 'setting3' was updated. From true to 'none' \ No newline at end of file diff --git a/app/src/test/resources/EXPECTED_STYLISH b/app/src/test/resources/EXPECTED_STYLISH new file mode 100644 index 0000000..d999b67 --- /dev/null +++ b/app/src/test/resources/EXPECTED_STYLISH @@ -0,0 +1,25 @@ +{ + chars1: [a, b, c] + - chars2: [d, e, f] + + chars2: false + - checked: false + + checked: true + - default: null + + default: [value1, value2] + - id: 45 + + id: null + - key1: value1 + + key2: value2 + numbers1: [1, 2, 3, 4] + - numbers2: [2, 3, 4, 5] + + numbers2: [22, 33, 44, 55] + - numbers3: [3, 4, 5] + + numbers4: [4, 5, 6] + + obj1: {nestedKey=value, isNested=true} + - setting1: Some value + + setting1: Another value + - setting2: 200 + + setting2: 300 + - setting3: true + + setting3: none +} \ No newline at end of file diff --git a/app/src/test/resources/file1.json b/app/src/test/resources/file1.json deleted file mode 100644 index 6212a97..0000000 --- a/app/src/test/resources/file1.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "host": "hexlet.io", - "timeout": 50, - "proxy": "123.234.53.22", - "follow": false -} \ No newline at end of file diff --git a/app/src/test/resources/file2.json b/app/src/test/resources/file2.json deleted file mode 100644 index c97f279..0000000 --- a/app/src/test/resources/file2.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "timeout": 20, - "verbose": true, - "host": "hexlet.io" -} \ No newline at end of file diff --git a/app/src/test/resources/file3.yaml b/app/src/test/resources/file3.yaml deleted file mode 100644 index c0e4188..0000000 --- a/app/src/test/resources/file3.yaml +++ /dev/null @@ -1,4 +0,0 @@ -host: hexlet.io -timeout: 50 -proxy: 123.234.53.22 -follow: false \ No newline at end of file diff --git a/app/src/test/resources/file4.yaml b/app/src/test/resources/file4.yaml deleted file mode 100644 index bd635d4..0000000 --- a/app/src/test/resources/file4.yaml +++ /dev/null @@ -1,3 +0,0 @@ -timeout: 20 -verbose: true -host: "hexlet.io" \ No newline at end of file diff --git a/app/src/test/resources/fileNested1.json b/app/src/test/resources/fileNested1.json new file mode 100644 index 0000000..ff478df --- /dev/null +++ b/app/src/test/resources/fileNested1.json @@ -0,0 +1,14 @@ +{ + "setting1": "Some value", + "setting2": 200, + "setting3": true, + "key1": "value1", + "numbers1": [1, 2, 3, 4], + "numbers2": [2, 3, 4, 5], + "id": 45, + "default": null, + "checked": false, + "numbers3": [3, 4, 5], + "chars1": ["a", "b", "c"], + "chars2": ["d", "e", "f"] +} \ No newline at end of file diff --git a/app/src/test/resources/fileNested2.json b/app/src/test/resources/fileNested2.json new file mode 100644 index 0000000..420b96f --- /dev/null +++ b/app/src/test/resources/fileNested2.json @@ -0,0 +1,18 @@ +{ + "setting1": "Another value", + "setting2": 300, + "setting3": "none", + "key2": "value2", + "numbers1": [1, 2, 3, 4], + "numbers2": [22, 33, 44, 55], + "id": null, + "default": ["value1", "value2"], + "checked": true, + "numbers4": [4, 5, 6], + "chars1": ["a", "b", "c"], + "chars2": false, + "obj1": { + "nestedKey": "value", + "isNested": true + } +} diff --git a/app/src/test/resources/fileNested3.yml b/app/src/test/resources/fileNested3.yml new file mode 100644 index 0000000..991d4f4 --- /dev/null +++ b/app/src/test/resources/fileNested3.yml @@ -0,0 +1,12 @@ +setting1: "Some value" +setting2: 200 +setting3: true +key1: "value1" +numbers1: [ 1, 2, 3, 4 ] +numbers2: [ 2, 3, 4, 5 ] +id: 45 +default: null +checked: false +numbers3: [ 3, 4, 5 ] +chars1: [ "a", "b", "c" ] +chars2: [ "d", "e", "f" ] \ No newline at end of file diff --git a/app/src/test/resources/fileNested4.yml b/app/src/test/resources/fileNested4.yml new file mode 100644 index 0000000..9090142 --- /dev/null +++ b/app/src/test/resources/fileNested4.yml @@ -0,0 +1,15 @@ +setting1: "Another value" +setting2: 300 +setting3: "none" +key2: "value2" +numbers1: [ 1, 2, 3, 4 ] +numbers2: [ 22, 33, 44, 55 ] +id: null +default: [ "value1", "value2" ] +checked: true +numbers4: [ 4, 5, 6 ] +chars1: [ "a", "b", "c" ] +chars2: false +obj1: + nestedKey: "value" + isNested: true \ No newline at end of file