@@ -36,6 +36,7 @@ public class DirIdCheckTest {
36
36
AA/aaaa/baz=.c9r/symlink.c9r = linktarget
37
37
BB/bbbb/foo=.c9r/dir.c9r = CCcccc
38
38
BB/bbbb/bar=.c9r/dir.c9r = ffffffffffff-aaaaaaaaaaaa-tttttttttttt
39
+ BB/bbbb/baz=.c9r/dir.c9r = [EMPTY]
39
40
BB/bbbb/foo=.c9r/unrelated/dir.c9r = unrelatedfile
40
41
CC/cccc/foo=.c9r = file
41
42
""" ;
@@ -121,16 +122,32 @@ public void testVisitorDetectsObeseDirId() throws IOException {
121
122
MatcherAssert .assertThat (resultCaptor .getAllValues (), Matchers .hasItem (CustomMatchers .matching (ObeseDirFile .class , expectedObeseFile , "Obese dir file: /d/BB/bbbb/bar=.c9r/dir.c9r" )));
122
123
}
123
124
125
+ @ Test
126
+ @ DisplayName ("detects empty dirID file in /d/BB/bbbb/baz=.c9r/dir.c9r" )
127
+ public void testVisitorDetectsEmptyDirId () throws IOException {
128
+ Files .walkFileTree (dataRoot , Set .of (), 4 , visitor );
129
+
130
+ Predicate <EmptyDirFile > expectedEmptyFile = emptyDirFile -> "/d/BB/bbbb/baz=.c9r/dir.c9r" .equals (emptyDirFile .dirFile .toString ());
131
+ ArgumentCaptor <DiagnosticResult > resultCaptor = ArgumentCaptor .forClass (DiagnosticResult .class );
132
+ Mockito .verify (resultsCollector , Mockito .atLeastOnce ()).accept (resultCaptor .capture ());
133
+ MatcherAssert .assertThat (resultCaptor .getAllValues (), Matchers .hasItem (CustomMatchers .matching (EmptyDirFile .class , expectedEmptyFile , "Empty dir file: /d/BB/bbbb/baz=.c9r/dir.c9r" )));
134
+ }
135
+
124
136
}
125
137
126
138
private static void initDirStructure (Path root , String line ) throws UncheckedIOException {
127
139
try {
128
140
if (line .contains (" = " )) {
129
141
var sep = line .indexOf (" = " );
130
- var file = line .substring (0 , sep );
142
+ var file = root . resolve ( line .substring (0 , sep ) );
131
143
var contents = line .substring (sep + 3 );
132
- Files .createDirectories (root .resolve (file ).getParent ());
133
- Files .writeString (root .resolve (file ), contents , StandardCharsets .US_ASCII , StandardOpenOption .CREATE_NEW );
144
+ Files .createDirectories (file .getParent ());
145
+ if (contents .equals ("[EMPTY]" )) {
146
+ Files .createFile (file );
147
+ } else {
148
+ Files .writeString (file , contents , StandardCharsets .US_ASCII , StandardOpenOption .CREATE_NEW );
149
+
150
+ }
134
151
} else {
135
152
Files .createDirectories (root .resolve (line ));
136
153
}
0 commit comments