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()); + } + +}