MCPcopy Create free account
hub / github.com/PCGen/pcgen / missingFilesTest

Method missingFilesTest

code/src/test/pcgen/persistence/lst/DataTest.java:153–186  ·  view source on GitHub ↗

Scan for any campaigns referring to missing data files. @throws IOException If the data path cannot be found.

()

Source from the content-addressed store, hash-verified

151 * @throws IOException If the data path cannot be found.
152 */
153 @Test
154 public void missingFilesTest() throws IOException
155 {
156 File dataFolder = new File(ConfigurationSettings.getPccFilesDir());
157 int dataPathLen = dataFolder.getCanonicalPath().length();
158
159 Collection<Object[]> missingLstFiles = new ArrayList<>();
160
161 for (Campaign campaign : Globals.getCampaignList())
162 {
163 List<CampaignSourceEntry> cseList =
164 getLstFilesForCampaign(campaign);
165 cseList.stream()
166 .map(cse -> new File(cse.getURI()))
167 .filter(lstFile -> !lstFile.exists())
168 .map(lstFile -> new Object[]{campaign, lstFile})
169 .forEach(missingLstFiles::add);
170 }
171
172 String report = missingLstFiles.stream()
173 .map(missing -> "Missing file " + ((File) missing[1]).getPath()
174 .substring(dataPathLen + 1)
175 + " used by "
176 + (new File(((Campaign) missing[0]).getSourceURI())).getPath()
177 .substring(
178 dataPathLen
179 + 1)
180 + "<br>\r\n")
181 .collect(Collectors.joining());
182
183 // Flag any missing files
184 assertEquals(
185 "", report, "Some data files are missing.");
186 }
187
188 /**
189 * Scan for any data files that are not referred to by any campaign.

Callers

nothing calls this directly

Calls 10

getPccFilesDirMethod · 0.95
getCampaignListMethod · 0.95
forEachMethod · 0.80
streamMethod · 0.80
getPathMethod · 0.80
joiningMethod · 0.80
getURIMethod · 0.65
getSourceURIMethod · 0.65
existsMethod · 0.45

Tested by

no test coverage detected