@Test public void whenMediaFolderFileDoesNotExist_shouldGetAllMethodReturnEmptyArray() { FormsDao formsDao = mock(FormsDao.class); when(formsDao.getFormMediaPath("1", "1")).thenReturn("/samplePath/"); assertThat(new DatabaseMediaFileRepository(formsDao, new FileUtil()).getAll("1", "1").size(), is(0)); }
@Override public List<File> getAll(String jrFormID, String formVersion) { String formMediaPath = formsDao.getFormMediaPath(jrFormID, formVersion); return formMediaPath == null ? new ArrayList<>() : fileUtil.listFiles(fileUtil.getFileAtPath(formMediaPath)); }
DatabaseMediaFileRepository implements MediaFileRepository { @Override public List<File> getAll(String jrFormID, String formVersion) { String formMediaPath = formsDao.getFormMediaPath(jrFormID, formVersion); return formMediaPath == null ? new ArrayList<>() : fileUtil.listFiles(fileUtil.getFileAtPath(formMediaPath)); } }
DatabaseMediaFileRepository implements MediaFileRepository { @Override public List<File> getAll(String jrFormID, String formVersion) { String formMediaPath = formsDao.getFormMediaPath(jrFormID, formVersion); return formMediaPath == null ? new ArrayList<>() : fileUtil.listFiles(fileUtil.getFileAtPath(formMediaPath)); } DatabaseMediaFileRepository(FormsDao formsDao, FileUtil fileUtil); }
DatabaseMediaFileRepository implements MediaFileRepository { @Override public List<File> getAll(String jrFormID, String formVersion) { String formMediaPath = formsDao.getFormMediaPath(jrFormID, formVersion); return formMediaPath == null ? new ArrayList<>() : fileUtil.listFiles(fileUtil.getFileAtPath(formMediaPath)); } DatabaseMediaFileRepository(FormsDao formsDao, FileUtil fileUtil); @Override List<File> getAll(String jrFormID, String formVersion); }
DatabaseMediaFileRepository implements MediaFileRepository { @Override public List<File> getAll(String jrFormID, String formVersion) { String formMediaPath = formsDao.getFormMediaPath(jrFormID, formVersion); return formMediaPath == null ? new ArrayList<>() : fileUtil.listFiles(fileUtil.getFileAtPath(formMediaPath)); } DatabaseMediaFileRepository(FormsDao formsDao, FileUtil fileUtil); @Override List<File> getAll(String jrFormID, String formVersion);  }