@@ -65,34 +65,12 @@ void emitErrorStateForInvalidPath() throws IOException {
65
65
66
66
@ Test
67
67
void watchForFileUpdatesAndEmitThem () throws IOException {
68
- final String initial = "{\n " +
69
- " \" flags\" : {\n " +
70
- " \" myBoolFlag\" : {\n " +
71
- " \" state\" : \" ENABLED\" ,\n " +
72
- " \" variants\" : {\n " +
73
- " \" on\" : true,\n " +
74
- " \" off\" : false\n " +
75
- " },\n " +
76
- " \" defaultVariant\" : \" on\" \n " +
77
- " }\n " +
78
- " }\n " +
79
- "}" ;
80
- final String updatedFlags = "{\n " +
81
- " \" flags\" : {\n " +
82
- " \" myBoolFlag\" : {\n " +
83
- " \" state\" : \" ENABLED\" ,\n " +
84
- " \" variants\" : {\n " +
85
- " \" on\" : true,\n " +
86
- " \" off\" : false\n " +
87
- " },\n " +
88
- " \" defaultVariant\" : \" off\" \n " +
89
- " }\n " +
90
- " }\n " +
91
- "}" ;
68
+ final String initial = "{\" flags\" :{\" myBoolFlag\" :{\" state\" :\" ENABLED\" ,\" variants\" :{\" on\" :true,\" off\" :false},\" defaultVariant\" :\" on\" }}}" ;
69
+ final String updatedFlags = "{\" flags\" :{\" myBoolFlag\" :{\" state\" :\" ENABLED\" ,\" variants\" :{\" on\" :true,\" off\" :false},\" defaultVariant\" :\" off\" }}}" ;
92
70
93
71
// given
94
72
final Path updPath = Paths .get (getResourcePath (UPDATABLE_FILE ));
95
- Files .write (updPath , initial .getBytes (), StandardOpenOption .WRITE );
73
+ Files .write (updPath , initial .getBytes (), StandardOpenOption .WRITE , StandardOpenOption . TRUNCATE_EXISTING );
96
74
97
75
final FileConnector connector = new FileConnector (updPath .toString ());
98
76
@@ -111,7 +89,7 @@ void watchForFileUpdatesAndEmitThem() throws IOException {
111
89
assertEquals (initial , payload [0 ].getData ());
112
90
113
91
// then update the flags
114
- Files .write (updPath , updatedFlags .getBytes (), StandardOpenOption .WRITE );
92
+ Files .write (updPath , updatedFlags .getBytes (), StandardOpenOption .WRITE , StandardOpenOption . TRUNCATE_EXISTING );
115
93
116
94
// finally wait for updated payload
117
95
assertTimeoutPreemptively (Duration .ofSeconds (10 ), () -> {
0 commit comments