ExportJob implements AsyncJob { public static ExportJobConfig createJobConfig() { return new ExportJobConfig(); } @Inject  ExportJob(ManifestManager manifestManager); @Override void execute(JobExecutionContext context); static ExportJobConfig createJobConfig(); static final String JOB_KEY; static final String JOB_NAME; }
@Test public void testJobConfigSetConsumer() { Owner owner = this.createTestOwner("owner_key", "log_level"); Consumer consumer = TestUtil.createDistributor(owner); JobConfig config = ExportJob.createJobConfig() .setConsumer(consumer); JobArguments args = config.getJobArguments(); assertTrue(args.containsKey(ExportJob.CONSUMER_KEY)); assertEquals(consumer.getUuid(), args.getAsString(ExportJob.CONSUMER_KEY)); }
@Test public void testJobConfigSetOwner() { Owner owner = this.createTestOwner("owner_key", "log_level"); JobConfig config = ExportJob.createJobConfig() .setOwner(owner); assertEquals(owner, config.getContextOwner()); }
@Test public void testJobConfigSetCdnLabel() { String label = "test_label"; JobConfig config = ExportJob.createJobConfig() .setCdnLabel(label); JobArguments args = config.getJobArguments(); assertTrue(args.containsKey(ExportJob.CDN_LABEL)); assertEquals(label, args.getAsString(ExportJob.CDN_LABEL)); }
@Test public void testJobConfigSetWebAppPrefix() { String prefix = "test_prefix"; JobConfig config = ExportJob.createJobConfig() .setWebAppPrefix(prefix); JobArguments args = config.getJobArguments(); assertTrue(args.containsKey(ExportJob.WEBAPP_PREFIX)); assertEquals(prefix, args.getAsString(ExportJob.WEBAPP_PREFIX)); }
@Test public void testJobConfigSetApiUrl() { String url = "test_url"; JobConfig config = ExportJob.createJobConfig() .setApiUrl(url); JobArguments args = config.getJobArguments(); assertTrue(args.containsKey(ExportJob.API_URL)); assertEquals(url, args.getAsString(ExportJob.API_URL)); }
@Test public void testJobConfigSetExtensionData() { Map<String, String> data = new HashMap<>(); data.put("key-1", "val-1"); data.put("key-2", "val-2"); data.put("key-3", "val-3"); JobConfig config = ExportJob.createJobConfig() .setExtensionData(data); JobArguments args = config.getJobArguments(); assertTrue(args.containsKey(ExportJob.EXTENSION_DATA)); assertEquals(data, args.getAs(ExportJob.EXTENSION_DATA, Map.class)); }
@Test public void testValidate() throws JobConfigValidationException { Owner owner = this.createTestOwner("owner_key", "log_level"); Consumer consumer = TestUtil.createDistributor(owner); JobConfig config = ExportJob.createJobConfig() .setConsumer(consumer) .setCdnLabel("test_label"); config.validate(); }
@Test public void testValidateCDNLabelNotRequired() throws JobConfigValidationException { Owner owner = this.createTestOwner("owner_key", "log_level"); Consumer consumer = TestUtil.createDistributor(owner); JobConfig config = ExportJob.createJobConfig() .setConsumer(consumer); config.validate(); }
@Test public void testValidateNoConsumer() { Owner owner = this.createTestOwner("owner_key", "log_level"); Consumer consumer = TestUtil.createDistributor(owner); JobConfig config = ExportJob.createJobConfig() .setCdnLabel("test_label"); assertThrows(JobConfigValidationException.class, config::validate); }