FilePersister implements Persister { @Override public Map<String, Map<String, String>> loadExpectedIds() { File file = checkFileAvailable(getExpectedIdsFile()); LOG.debug("[Load ExpectedIds] ({})", file); try { Map<String, Map<String, String>> ids = JSONUtils.readValue(file, EXPECTED_IDS_REFERENCE); LOG.trace("[Load ExpectedIds] => {}", ids); return ids; } catch (JSONException e) { LOG.debug("Failed to load ExpectedIds.", e); throw e; } } FilePersister();  FilePersister(FilePersisterConfig config); @Override void saveDiffImage(PersistMetadata metadata, BufferedImage image); @Override BufferedImage loadDiffImage(PersistMetadata metadata); @Override void saveScreenshot(PersistMetadata metadata, BufferedImage image); @Override InputStream getImageStream(PersistMetadata metadata); @Override BufferedImage loadScreenshot(PersistMetadata metadata); @Override void saveTargetResults(PersistMetadata metadata, List<TargetResult> results); @Override List<TargetResult> loadTargetResults(final PersistMetadata metadata); @Override void saveTestResult(PersistMetadata metadata, TestResult result); @Override TestResult loadTestResult(PersistMetadata metadata); @Override void saveExpectedIds(Map<String, Map<String, String>> expectedIds); @Override Map<String, Map<String, String>> loadExpectedIds(); File getResultDirectoryFile(); File getExpectedIdsFile(); File getTestResultFile(PersistMetadata metadata); File getTargetResultsFile(PersistMetadata metadata); File getScreenshotImageFile(PersistMetadata metadata); File getDiffImageFile(PersistMetadata metadata); String getExpectedIdsFileName(); String getTestResultFileName(); String getTargetResultsFileName(PersistMetadata metadata); String getScreenshotImageFileName(PersistMetadata metadata); String getDiffImageFileName(PersistMetadata metadata); static final String DEFAULT_EXPECTED_IDS_FILE_NAME; static final String DEFAULT_TEST_RESULT_FILE_NAME; }
@Test public void testLoadExpectedIds() throws Exception { Map<String, Map<String, String>> expectedIds = JSONUtils.readValue( getClass().getResourceAsStream("FilePersister_ExpectedIds.json"), new TypeReference<Map<String, Map<String, String>>>() { }); File file = new File(BASE_DIRECTORY, "currentExpectedIds.json"); file.getParentFile().mkdirs(); JSONUtils.writeValue(file, expectedIds); Map<String, Map<String, String>> loadedIds = persister.loadExpectedIds(); assertThat(loadedIds, is(expectedIds)); }
@Test public void testLoadExpectedIds_not_found() throws Exception { expectedException.expect(ResourceUnavailableException.class); persister.loadExpectedIds(); }