Scan for any campaigns referring to missing data files. @throws IOException If the data path cannot be found.
()
| 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. |
nothing calls this directly
no test coverage detected