From 0bfff2719e14a62c56633160c545cee3c6eb4b47 Mon Sep 17 00:00:00 2001 From: Rithvik Sriram Date: Thu, 4 Dec 2025 22:37:45 +0100 Subject: [PATCH 1/4] fundamental print logic implemented --- client/src/main/java/client/utils/PrintExportService.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 client/src/main/java/client/utils/PrintExportService.java diff --git a/client/src/main/java/client/utils/PrintExportService.java b/client/src/main/java/client/utils/PrintExportService.java new file mode 100644 index 0000000..cd226fe --- /dev/null +++ b/client/src/main/java/client/utils/PrintExportService.java @@ -0,0 +1,4 @@ +package client.utils; + +public class PrintExportService { +} From 91fbefb3923d88503ce8e92927809b858c9b9623 Mon Sep 17 00:00:00 2001 From: Rithvik Sriram Date: Fri, 5 Dec 2025 13:54:56 +0100 Subject: [PATCH 2/4] Basic print functionality done with comments --- .../java/client/utils/PrintExportService.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/client/src/main/java/client/utils/PrintExportService.java b/client/src/main/java/client/utils/PrintExportService.java index cd226fe..5198c41 100644 --- a/client/src/main/java/client/utils/PrintExportService.java +++ b/client/src/main/java/client/utils/PrintExportService.java @@ -1,4 +1,67 @@ package client.utils; +import commons.Recipe; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + public class PrintExportService { + + /** + * Builds the String with all the recipe data in a human-readable format and returns said string + * @param recipe - Recipe Object that needs to be converted + * @return - String Result that is the converted recipe object + */ + public static String buildRecipeText(Recipe recipe){ + String result = "Title: " + recipe.getName() + "\nRecipe ID: " + recipe.getId() + "\n" + + "Ingredients: "; //Starts the string with name and recipe ID + for(int i =0; i Date: Fri, 5 Dec 2025 15:21:19 +0100 Subject: [PATCH 3/4] Print export Unit tests are written --- .../java/client/utils/PrintExportService.java | 2 +- .../java/client/scenes/PrintExportTest.java | 69 +++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 client/src/test/java/client/scenes/PrintExportTest.java diff --git a/client/src/main/java/client/utils/PrintExportService.java b/client/src/main/java/client/utils/PrintExportService.java index 5198c41..17c947c 100644 --- a/client/src/main/java/client/utils/PrintExportService.java +++ b/client/src/main/java/client/utils/PrintExportService.java @@ -19,7 +19,7 @@ public class PrintExportService { for(int i =0; i ingredients = new ArrayList<>(); + ingredients.add("Banana"); + ingredients.add("Bread"); + List preparationSteps = new ArrayList<>(); + preparationSteps.add("Mix Ingredients"); + preparationSteps.add("Heat in Oven"); + Recipe recipe1 = new Recipe(1234L, "Banana Bread", ingredients, preparationSteps); + + assertEquals(""" + Title: Banana Bread + Recipe ID: 1234 + Ingredients: Banana, Bread,\s + Steps: + 1: Mix Ingredients + 2: Heat in Oven + """, PrintExportService.buildRecipeText(recipe1)); + + } + + @TempDir + Path tempDir; + @Test + public void validateFolderWithValidFolderTest(){ + assertDoesNotThrow(() -> PrintExportService.validateFolder(tempDir)); + } + + @Test + public void validateFolderWithNullPathTest(){ + IllegalArgumentException i = assertThrows(IllegalArgumentException.class, + ()->PrintExportService.validateFolder(null)); + assertEquals("Path is empty", i.getMessage()); + } + + @Test + public void validateFolderWithFilePathTest() throws IOException { + Path filePath = Files.createFile(tempDir.resolve("TestFile")); + IllegalArgumentException i = assertThrows(IllegalArgumentException.class, + ()->PrintExportService.validateFolder(filePath)); + assertEquals("Given path is not a folder", i.getMessage()); + } + +} From b38e0e7482d94db613bbcc1b70bad882e8881767 Mon Sep 17 00:00:00 2001 From: Rithvik Sriram Date: Fri, 5 Dec 2025 15:27:53 +0100 Subject: [PATCH 4/4] fixed all pipeline errors --- client/src/test/java/client/scenes/PrintExportTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/test/java/client/scenes/PrintExportTest.java b/client/src/test/java/client/scenes/PrintExportTest.java index a46be2b..897c88d 100644 --- a/client/src/test/java/client/scenes/PrintExportTest.java +++ b/client/src/test/java/client/scenes/PrintExportTest.java @@ -28,10 +28,11 @@ public class PrintExportTest { List ingredients = new ArrayList<>(); ingredients.add("Banana"); ingredients.add("Bread"); + final long testRecipeId = 1234L; List preparationSteps = new ArrayList<>(); preparationSteps.add("Mix Ingredients"); preparationSteps.add("Heat in Oven"); - Recipe recipe1 = new Recipe(1234L, "Banana Bread", ingredients, preparationSteps); + Recipe recipe1 = new Recipe(testRecipeId, "Banana Bread", ingredients, preparationSteps); assertEquals(""" Title: Banana Bread