use of org.candlepin.sync.file.ManifestFile in project candlepin by candlepin.
the class ManifestManagerTest method testManifestImportAsync.
@Test
public void testManifestImportAsync() throws Exception {
Owner owner = TestUtil.createOwner();
File file = mock(File.class);
String filename = "manifest.zip";
ConflictOverrides overrides = new ConflictOverrides(Conflict.DISTRIBUTOR_CONFLICT);
UserPrincipal principal = TestUtil.createOwnerPrincipal();
when(principalProvider.get()).thenReturn(principal);
ManifestFile manifest = mock(ManifestFile.class);
when(fileService.store(ManifestFileType.IMPORT, file, principal.getName(), owner.getKey())).thenReturn(manifest);
JobDetail job = manager.importManifestAsync(owner, file, filename, overrides);
JobDataMap jobData = job.getJobDataMap();
assertEquals(owner.getKey(), jobData.get("owner_id"));
assertEquals(JobStatus.TargetType.OWNER, jobData.get("target_type"));
assertEquals(owner.getKey(), jobData.get("target_id"));
assertEquals(manifest.getId(), jobData.get("stored_manifest_file_id"));
assertEquals(filename, jobData.get("uploaded_file_name"));
ConflictOverrides retrievedOverrides = new ConflictOverrides((String[]) jobData.get("conflict_overrides"));
assertTrue(retrievedOverrides.isForced(Conflict.DISTRIBUTOR_CONFLICT));
verify(fileService).store(eq(ManifestFileType.IMPORT), eq(file), eq(principal.getName()), eq(owner.getKey()));
}
Aggregations