OrnidroidIOServiceImpl implements IOrnidroidIOService { public void downloadMediaFiles(final String mediaHomeDirectory, final Bird bird, final OrnidroidFileType fileType) throws OrnidroidException { switch (fileType) { case PICTURE: bird.setPictures(lookForOrnidroidFiles(mediaHomeDirectory, bird.getBirdDirectoryName(), OrnidroidFileType.PICTURE, true)); break; case AUDIO: bird.setSounds(lookForOrnidroidFiles(mediaHomeDirectory, bird.getBirdDirectoryName(), OrnidroidFileType.AUDIO, true)); break; case WIKIPEDIA_PAGE: bird.setWikipediaPage(downloadWikipediaPage(bird)); break; } } 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);  }
@Test public void testDownLoadMediaFiles() throws InterruptedException, OrnidroidException { Bird bird = this.birdFactory.createBird(1, "taxon", "", null, "barge_a_queue_noire", "", null, "", "", "", null, null, null); Assert.assertNull("list of pictures should be null", bird.getPictures()); Assert.assertNull("list of sounds should be null", bird.getSounds()); this.ornidroidIOService.downloadMediaFiles(TEST_DIRECTORY + File.separator + BasicConstants.IMAGES_DIRECTORY, bird, OrnidroidFileType.PICTURE); Assert.assertNotNull(bird.getPictures()); Assert.assertEquals(2, bird.getNumberOfPictures()); this.ornidroidIOService.downloadMediaFiles(TEST_DIRECTORY + File.separator + BasicConstants.AUDIO_DIRECTORY, bird, OrnidroidFileType.AUDIO); Assert.assertNotNull(bird.getPictures()); Assert.assertEquals(2, bird.getNumberOfPictures()); Assert.assertNotNull(bird.getSounds()); Assert.assertEquals(1, bird.getNumberOfSounds()); Thread.sleep(1000); final Date date = new Date(); Thread.sleep(1000); bird = this.birdFactory.createBird(1, "taxon", "", null, "barge_a_queue_noire", "", null, "", "", "", null, null, null); Assert.assertNull("list of pictures should be null", bird.getPictures()); this.ornidroidIOService.loadMediaFiles(TEST_DIRECTORY + File.separator + "/images", bird, OrnidroidFileType.PICTURE); Assert.assertNotNull(bird.getPictures()); Assert.assertTrue(bird.getNumberOfPictures() == 2); Assert.assertTrue(isFileOlder(new File(TEST_DIRECTORY + File.separator + BasicConstants.IMAGES_DIRECTORY + File.separator + "barge_a_queue_noire/barge_a_queue_noire_1.jpg"), date)); }