| | 127 | public void testSubtitlesWithInitialFilenameAbsoluteSuccess() throws Exception |
| | 128 | { |
| | 129 | IProject project = ProjectFactory.createNew(); |
| | 130 | IVideo video = DOFactory.createVideo(DOFactory.getEmptyPNGFile(parentDir)); |
| | 131 | File subtitleFile = File.createTempFile("subtitle", ".txt", parentDir); |
| | 132 | video.setSubtitles(subtitleFile.getAbsolutePath()); |
| | 133 | |
| | 134 | UoW.getCurrent().commit(); |
| | 135 | UoW.newCurrent(); |
| | 136 | |
| | 137 | final String basePath = dataFile.getParentFile().getAbsolutePath(); |
| | 138 | |
| | 139 | Request request = new Request(); |
| | 140 | request.set("id", project.getId()); |
| | 141 | request.set("basePath", basePath); |
| | 142 | Response response = new Response(); |
| | 143 | new AdjustToRelativePathsCommand(request, response).execute(); |
| | 144 | Collection<IMedia> actualMedia = (Collection<IMedia>)response.get("media"); |
| | 145 | IVideo actualVideo = (IVideo)actualMedia.iterator().next(); |
| | 146 | |
| | 147 | Assert.assertEquals(Boolean.TRUE, response.getBoolean("status")); |
| | 148 | Assert.assertEquals(subtitleFile.getAbsolutePath(), basePath + File.separator + actualVideo.getSubtitles()); |
| | 149 | } |
| | 150 | public void testSubtitlesWithInitialFilenameRelativeSuccess() throws Exception |
| | 151 | { |
| | 152 | IProject project = ProjectFactory.createNew(); |
| | 153 | IVideo video = DOFactory.createVideo(DOFactory.getEmptyPNGFile(parentDir)); |
| | 154 | File subtitleFile = File.createTempFile("subtitle", ".txt", parentDir); |
| | 155 | final String basePath = dataFile.getParentFile().getAbsolutePath(); |
| | 156 | video.setSubtitles(subtitleFile.getAbsolutePath().substring(basePath.length()+1)); |
| | 157 | |
| | 158 | UoW.getCurrent().commit(); |
| | 159 | UoW.newCurrent(); |
| | 160 | |
| | 161 | |
| | 162 | Request request = new Request(); |
| | 163 | request.set("id", project.getId()); |
| | 164 | request.set("basePath", basePath); |
| | 165 | Response response = new Response(); |
| | 166 | new AdjustToRelativePathsCommand(request, response).execute(); |
| | 167 | Collection<IMedia> actualMedia = (Collection<IMedia>)response.get("media"); |
| | 168 | IVideo actualVideo = (IVideo)actualMedia.iterator().next(); |
| | 169 | |
| | 170 | Assert.assertEquals(Boolean.TRUE, response.getBoolean("status")); |
| | 171 | Assert.assertEquals(subtitleFile.getAbsolutePath(), basePath + File.separator + actualVideo.getSubtitles()); |
| | 172 | } |