@Test public void testFilesToUpdate() throws OrnidroidException, IOException { final File testDir = buildOrnidroidHomeTest(TEST_DIRECTORY + "/testDir"); final File imagesDir = new File(testDir.getAbsolutePath() + File.separator + Constants.IMAGES_DIRECTORY); FileHelper.forceMkdir(new File(imagesDir.getAbsolutePath() + File.separator + "bird_1")); FileHelper.doCopyFile(new File( "./src/test/resources/images/bird_1/contents.properties"), new File(imagesDir.getAbsolutePath() + File.separator + "bird_1" + File.separator + "contents.properties")); final Bird bird1 = new BirdFactoryImpl().createBird(1, null, null, null, "bird_1", null, null, null, null, null, null, null, null); List<String> filesToUpdate = this.ornidroidIOService.filesToUpdate( imagesDir.getAbsolutePath(), bird1, OrnidroidFileType.PICTURE); Assert.assertEquals("bird 1 has one image to download", 1, filesToUpdate.size()); Assert.assertEquals("3.jpg", filesToUpdate.get(0)); FileHelper.forceMkdir(new File(imagesDir.getAbsolutePath() + File.separator + "bird_2")); final Bird bird2 = new BirdFactoryImpl().createBird(1, null, null, null, "bird_2", null, null, null, null, null, null, null, null); filesToUpdate = this.ornidroidIOService.filesToUpdate( imagesDir.getAbsolutePath(), bird2, OrnidroidFileType.PICTURE); Assert.assertEquals(0, filesToUpdate.size()); FileHelper.forceMkdir(new File(imagesDir.getAbsolutePath() + File.separator + "bird_3")); FileHelper.doCopyFile(new File( "./src/test/resources/images/bird_3/contents.properties"), new File(imagesDir.getAbsolutePath() + File.separator + "bird_3" + File.separator + "contents.properties")); final Bird bird3 = new BirdFactoryImpl().createBird(1, null, null, null, "bird_3", null, null, null, null, null, null, null, null); filesToUpdate = this.ornidroidIOService.filesToUpdate( imagesDir.getAbsolutePath(), bird3, OrnidroidFileType.PICTURE); Assert.assertEquals("bird 3 is uptodate", 0, filesToUpdate.size()); }
public List<String> filesToUpdate(final String mediaHomeDirectory, final Bird bird, final OrnidroidFileType fileType) throws OrnidroidException { final List<String> filesToUpdate = new ArrayList<String>(); final List<String> localFilesList = loadContentFile(true, mediaHomeDirectory, bird, fileType); final List<String> remoteFilesList = loadContentFile(false, mediaHomeDirectory, bird, fileType); for (final String remoteFile : remoteFilesList) { if (!localFilesList.contains(remoteFile)) { filesToUpdate.add(remoteFile); } } return filesToUpdate; }
OrnidroidIOServiceImpl implements IOrnidroidIOService { public List<String> filesToUpdate(final String mediaHomeDirectory, final Bird bird, final OrnidroidFileType fileType) throws OrnidroidException { final List<String> filesToUpdate = new ArrayList<String>(); final List<String> localFilesList = loadContentFile(true, mediaHomeDirectory, bird, fileType); final List<String> remoteFilesList = loadContentFile(false, mediaHomeDirectory, bird, fileType); for (final String remoteFile : remoteFilesList) { if (!localFilesList.contains(remoteFile)) { filesToUpdate.add(remoteFile); } } return filesToUpdate; } }
OrnidroidIOServiceImpl implements IOrnidroidIOService { public List<String> filesToUpdate(final String mediaHomeDirectory, final Bird bird, final OrnidroidFileType fileType) throws OrnidroidException { final List<String> filesToUpdate = new ArrayList<String>(); final List<String> localFilesList = loadContentFile(true, mediaHomeDirectory, bird, fileType); final List<String> remoteFilesList = loadContentFile(false, mediaHomeDirectory, bird, fileType); for (final String remoteFile : remoteFilesList) { if (!localFilesList.contains(remoteFile)) { filesToUpdate.add(remoteFile); } } return filesToUpdate; } OrnidroidIOServiceImpl(); }
OrnidroidIOServiceImpl implements IOrnidroidIOService { public List<String> filesToUpdate(final String mediaHomeDirectory, final Bird bird, final OrnidroidFileType fileType) throws OrnidroidException { final List<String> filesToUpdate = new ArrayList<String>(); final List<String> localFilesList = loadContentFile(true, mediaHomeDirectory, bird, fileType); final List<String> remoteFilesList = loadContentFile(false, mediaHomeDirectory, bird, fileType); for (final String remoteFile : remoteFilesList) { if (!localFilesList.contains(remoteFile)) { filesToUpdate.add(remoteFile); } } return filesToUpdate; } OrnidroidIOServiceImpl(); void addCustomMediaFile(final String birdDirectory,
			final OrnidroidFileType fileType, final String selectedFileName,
			final File selectedFile, final String comment); void checkAndCreateDirectory(final File fileDirectory); void checkOrnidroidHome(final String ornidroidHome); void downloadMediaFiles(final String mediaHomeDirectory,
			final Bird bird, final OrnidroidFileType fileType); List<String> filesToUpdate(final String mediaHomeDirectory,
			final Bird bird, final OrnidroidFileType fileType); void loadMediaFiles(final String fileDirectory, final Bird bird,
			final OrnidroidFileType fileType); void removeCustomMediaFile(final OrnidroidFile ornidroidFile); @Override void resetExistingDirectory(File directoryToReset); void downloadZipPackage(String zipname, String mediaHomeDirectory); boolean isEnoughFreeSpace(OrnidroidFileType fileType); ZipPackage getZipname(OrnidroidFileType fileType); int getZipDownloadProgressPercent(OrnidroidFileType fileType,
			int folderSizeBeforeDownload); int getInstallProgressPercent(OrnidroidFileType fileType); }
OrnidroidIOServiceImpl implements IOrnidroidIOService { public List<String> filesToUpdate(final String mediaHomeDirectory, final Bird bird, final OrnidroidFileType fileType) throws OrnidroidException { final List<String> filesToUpdate = new ArrayList<String>(); final List<String> localFilesList = loadContentFile(true, mediaHomeDirectory, bird, fileType); final List<String> remoteFilesList = loadContentFile(false, mediaHomeDirectory, bird, fileType); for (final String remoteFile : remoteFilesList) { if (!localFilesList.contains(remoteFile)) { filesToUpdate.add(remoteFile); } } return filesToUpdate; } OrnidroidIOServiceImpl(); void addCustomMediaFile(final String birdDirectory,
			final OrnidroidFileType fileType, final String selectedFileName,
			final File selectedFile, final String comment); void checkAndCreateDirectory(final File fileDirectory); void checkOrnidroidHome(final String ornidroidHome); void downloadMediaFiles(final String mediaHomeDirectory,
			final Bird bird, final OrnidroidFileType fileType); List<String> filesToUpdate(final String mediaHomeDirectory,
			final Bird bird, final OrnidroidFileType fileType); void loadMediaFiles(final String fileDirectory, final Bird bird,
			final OrnidroidFileType fileType); void removeCustomMediaFile(final OrnidroidFile ornidroidFile); @Override void resetExistingDirectory(File directoryToReset); void downloadZipPackage(String zipname, String mediaHomeDirectory); boolean isEnoughFreeSpace(OrnidroidFileType fileType); ZipPackage getZipname(OrnidroidFileType fileType); int getZipDownloadProgressPercent(OrnidroidFileType fileType,
			int folderSizeBeforeDownload); int getInstallProgressPercent(OrnidroidFileType fileType);  }