-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileWriterTest.java
More file actions
64 lines (57 loc) · 2.17 KB
/
FileWriterTest.java
File metadata and controls
64 lines (57 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package cs3500.pa05.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import cs3500.pa05.model.json.DayJson;
import cs3500.pa05.model.json.TaskJson;
import cs3500.pa05.model.json.ThemeJson;
import cs3500.pa05.model.json.WeekJson;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Tests FileWriter
*/
public class FileWriterTest {
private FileWriter fileWriter;
private FileWriter badFileWriter;
/**
* Sets up file writer
*/
@BeforeEach
public void setUp() {
WeekJson weekJson = new WeekJson("hello", 5, 5, new ArrayList<>(),
new ThemeJson("neon"), new ArrayList<>(
List.of(new DayJson(DayType.SUNDAY, new ArrayList<>(), new ArrayList<>()))),
new ArrayList<>(
List.of(new TaskJson(
"name", "desc", "Monday", "true"))), "note");
fileWriter = new FileWriter(weekJson, "src/test/resources/fileWriteTest");
badFileWriter = new FileWriter(weekJson, "bad/file");
}
/**
* Tests writeBujo()
*/
@Test
public void testWriteBujo() {
String jsonString = "";
badFileWriter.writeBujo();
fileWriter.writeBujo();
try {
jsonString = new String(Files.readAllBytes(Path.of("src/test/resources/fileWriteTest")));
System.out.println(jsonString);
} catch (IOException e) {
System.err.println("Path not found");
}
assertNotEquals("{\n \"name\" : \"hello\",\n \"task-max\" : 5,\n \"event-max\" : 5,\n"
+ " \"theme-options\" : [ ],\n \"current-theme\" : {\n \"name\" : \"neon\"\n"
+ " },\n \"days\" : [ {\n \"day\" : \"SUNDAY\",\n \"events\" : [ ],\n"
+ " \"tasks\" : [ ]\n } ],\n \"task-queue\" : [ {\n \"name\" : \"name\",\n"
+ " \"description\" : \"desc\",\n \"day\" : \"Monday\",\n"
+ " \"completed\" : \"true\"\n } ],\n \"note\" : \"note\"\n}",
jsonString.stripTrailing().stripLeading());
}
}