AnimateServiceImpl extends AbstractJobProducer implements AnimateService, ManagedService { @Override public Job animate(URI animation, Map<String, String> metadata, List<String> arguments) throws AnimateServiceException { Gson gson = new Gson(); List<String> jobArguments = Arrays.asList(animation.toString(), gson.toJson(metadata), gson.toJson(arguments)); try { logger.debug("Create animate service job"); return serviceRegistry.createJob(JOB_TYPE, OPERATION, jobArguments, jobLoad); } catch (ServiceRegistryException e) { throw new AnimateServiceException(e); } } AnimateServiceImpl(); @Override @Activate void activate(ComponentContext cc); @Override void updated(Dictionary properties); @Override Job animate(URI animation, Map<String, String> metadata, List<String> arguments); @Reference void setWorkspace(Workspace workspace); @Reference void setServiceRegistry(ServiceRegistry jobManager); @Reference void setSecurityService(SecurityService securityService); @Reference void setUserDirectoryService(UserDirectoryService userDirectoryService); @Reference void setOrganizationDirectoryService(OrganizationDirectoryService organizationDirectoryService); static final String SYNFIG_BINARY_DEFAULT; }
@Test public void testAnimate() throws Exception { URI animation = getClass().getResource("/synfig-test-animation.sif").toURI(); Map<String, String> metadata = new HashMap<>(); metadata.put("episode.title", "Test"); metadata.put("episode.author", "John Doe"); metadata.put("series.title", "The Art Of Animation"); List<String> options = new ArrayList<>(2); options.add("-t"); options.add("ffmpeg"); Job job = animateService.animate(animation, metadata, options); File output = new File(new URI(job.getPayload())); Assert.assertTrue(output.isFile()); }
@Test public void testBrokenEncodingOptions() throws Exception { URI animation = getClass().getResource("/synfig-test-animation.sif").toURI(); Map<String, String> metadata = new HashMap<>(); List<String> options = new ArrayList<>(0); options.add("-t"); options.add("santa-claus"); Job job = null; try { job = animateService.animate(animation, metadata, options); logger.error("The test should have never reached this."); } catch (Exception e) { } Assert.assertNull(job); }