ImportJob implements AsyncJob { public static ImportJobConfig createJobConfig() { return new ImportJobConfig(); } @Inject  ImportJob(OwnerCurator ownerCurator, ManifestManager manifestManager); @Override void execute(JobExecutionContext context); static ImportJobConfig createJobConfig(); static final String JOB_KEY; static final String JOB_NAME; }
@Test public void testJobConfigSetOwner() { Owner owner = this.createTestOwner("owner_key", "log_level"); JobConfig config = ImportJob.createJobConfig() .setOwner(owner); JobArguments args = config.getJobArguments(); String argKey = args.keySet().iterator().next(); assertNotNull(argKey); assertFalse(argKey.isEmpty()); assertEquals(owner.getKey(), args.getAsString(argKey)); assertEquals(owner, config.getContextOwner()); }
@Test public void testJobConfigSetUploadFileName() { String fileName = "file_name_1"; JobConfig config = ImportJob.createJobConfig() .setUploadedFileName(fileName); JobArguments args = config.getJobArguments(); String argKey = args.keySet().iterator().next(); assertNotNull(argKey); assertFalse(argKey.isEmpty()); assertEquals(fileName, args.getAsString(argKey)); }
@Test public void testJobConfigSetStoredFileId() { String storedFileId = "stored_file_id_1"; JobConfig config = ImportJob.createJobConfig() .setStoredFileId(storedFileId); JobArguments args = config.getJobArguments(); String argKey = args.keySet().iterator().next(); assertNotNull(argKey); assertFalse(argKey.isEmpty()); assertEquals(storedFileId, args.getAsString(argKey)); }
@Test public void testJobConfigSetConflictOverrides() { ConflictOverrides conflictOverrides = new ConflictOverrides( Importer.Conflict.DISTRIBUTOR_CONFLICT, Importer.Conflict.MANIFEST_SAME); JobConfig config = ImportJob.createJobConfig() .setConflictOverrides(conflictOverrides); JobArguments args = config.getJobArguments(); assertNotNull(args); assertEquals(1, args.size()); String argKey = args.keySet().iterator().next(); assertNotNull(argKey); assertFalse(argKey.isEmpty()); assertArrayEquals(conflictOverrides.asStringArray(), args.getAs(argKey, String[].class)); }
@Test public void testValidate() throws JobConfigValidationException { Owner owner = this.createTestOwner("owner_key", "log_level"); JobConfig config = ImportJob.createJobConfig() .setOwner(owner) .setStoredFileId("stored_field_id_1") .setUploadedFileName("upload_file_name_1"); config.validate(); }
@Test public void testValidateNoOwner() { JobConfig config = ImportJob.createJobConfig() .setStoredFileId("stored_field_id_1") .setUploadedFileName("upload_file_name_1"); try { config.validate(); fail("an expected exception was not thrown"); } catch (JobConfigValidationException e) { } }
@Test public void testValidateNoStoredFileId() { Owner owner = this.createTestOwner("owner_key_1", "log_level_1"); JobConfig config = ImportJob.createJobConfig() .setOwner(owner) .setUploadedFileName("upload_file_name_1"); assertThrows(JobConfigValidationException.class, config::validate); }
@Test public void testValidateNoUploadedFileName() { Owner owner = this.createTestOwner("owner_key_1", "log_level_1"); JobConfig config = ImportJob.createJobConfig() .setOwner(owner) .setStoredFileId("stored_field_id_1"); assertThrows(JobConfigValidationException.class, config::validate); }