@Test public void testInitialFilenameAbsoluteSuccess() throws Exception { IProject project = DOFactory.createDefaultTestProject(parentDir); Assert.assertFalse(project.getMedia().isEmpty()); HashMap<IMedia, String> absolutePathMap = new HashMap<IMedia, String>(); final String basePath = dataFile.getParentFile().getAbsolutePath(); // System.out.println(String.format("BasePath: %s", basePath)); for (IMedia medium : project.getMedia()) { // System.out.println("Media: " + medium.getFilename()); Assert.assertTrue(new File(medium.getAbsoluteFilename()).exists()); absolutePathMap.put(medium, medium.getAbsoluteFilename()); UoW.getCurrent().registerDirty(medium); } UoW.getCurrent().commit(); UoW.newCurrent(); Request request = new Request(); request.set("id", project.getId()); Response response = new Response(); new AdjustToAbsolutePathsCommand(request, response).execute(); Collection<IMedia> actualMedia = (Collection<IMedia>) response.get("media"); for (IMedia medium : actualMedia) { String absolutePath = absolutePathMap.get(medium); Assert.assertEquals(absolutePath, medium.getFilename()); } }
@Test public void testSubtitlesWithInitialFilenameAbsoluteSuccess() throws Exception { IProject project = ProjectFactory.createNew(); IVideo video = DOFactory.createVideo(DOFactory.getEmptyPNGFile(parentDir)); File subtitleFile = File.createTempFile("subtitle", ".txt", parentDir); video.setSubtitles(subtitleFile.getAbsolutePath()); UoW.getCurrent().commit(); UoW.newCurrent(); final String basePath = dataFile.getParentFile().getAbsolutePath(); Request request = new Request(); request.set("id", project.getId()); Response response = new Response(); new AdjustToAbsolutePathsCommand(request, response).execute(); Collection<IMedia> actualMedia = (Collection<IMedia>) response.get("media"); IVideo actualVideo = (IVideo) actualMedia.iterator().next(); Assert.assertEquals(subtitleFile.getAbsolutePath(), actualVideo.getSubtitles()); }