EntitleByProductsJob implements AsyncJob { public static EntitleByProductsJobConfig createConfig() { return new EntitleByProductsJobConfig(); } @Inject  EntitleByProductsJob(Entitler entitler); @Override void execute(final JobExecutionContext context); static EntitleByProductsJobConfig createConfig(); static final String JOB_KEY; static final String JOB_NAME; }
@Test void allMandatoryValuesPresent() { final String[] pids = { "pid1", "pid2", "pid3" }; final List<String> fromPools = Collections.singletonList("pool_id1"); final JobConfig config = EntitleByProductsJob.createConfig() .setConsumer(consumer) .setProductIds(pids) .setEntitleDate(new Date()) .setPools(fromPools); assertDoesNotThrow(config::validate); }
@Test void consumerMustBePresent() { final String[] pids = { "pid1", "pid2", "pid3" }; final List<String> fromPools = Collections.singletonList("pool_id1"); final JobConfig config = EntitleByProductsJob.createConfig() .setProductIds(pids) .setEntitleDate(new Date()) .setPools(fromPools); assertThrows(JobConfigValidationException.class, config::validate); }
@Test void consumerCannotBeBlank() { final String[] pids = { "pid1", "pid2", "pid3" }; final List<String> fromPools = Collections.singletonList("pool_id1"); consumer.setUuid(""); final JobConfig config = EntitleByProductsJob.createConfig() .setConsumer(consumer) .setProductIds(pids) .setEntitleDate(new Date()) .setPools(fromPools); assertThrows(JobConfigValidationException.class, config::validate); }
@Test void productIdsCanBeMissing() { final List<String> fromPools = Collections.singletonList("pool_id1"); final JobConfig config = EntitleByProductsJob.createConfig() .setConsumer(consumer) .setEntitleDate(new Date()) .setPools(fromPools); assertDoesNotThrow(config::validate); }
@Test void productIdsCanBeEmpty() { final String[] pids = {}; final List<String> fromPools = Collections.singletonList("pool_id1"); final JobConfig config = EntitleByProductsJob.createConfig() .setConsumer(consumer) .setProductIds(pids) .setEntitleDate(new Date()) .setPools(fromPools); assertDoesNotThrow(config::validate); }
@Test void entitleDateIsOptional() { final String[] pids = { "pid1", "pid2", "pid3" }; final List<String> fromPools = Collections.singletonList("pool_id1"); final JobConfig config = EntitleByProductsJob.createConfig() .setConsumer(consumer) .setProductIds(pids) .setPools(fromPools); assertDoesNotThrow(config::validate); }
@Test void fromPoolsMustBePresent() { final String[] pids = { "pid1", "pid2", "pid3" }; final JobConfig config = EntitleByProductsJob.createConfig() .setConsumer(consumer) .setProductIds(pids) .setEntitleDate(new Date()); assertThrows(JobConfigValidationException.class, config::validate); }