@Test
public void testImportRecordSuccessWithFilename()
throws IOException, ImporterException {
Importer importer = mock(Importer.class);
EventSink es = mock(EventSink.class);
OwnerResource thisOwnerResource = new OwnerResource(ownerCurator, null,
null, null, null, i18n, es, null, null, null, importer, null, null,
null, importRecordCurator, null, null, null, null, null,
null, null, null, contentOverrideValidator,
serviceLevelValidator, null);
MultipartInput input = mock(MultipartInput.class);
InputPart part = mock(InputPart.class);
File archive = mock(File.class);
List<InputPart> parts = new ArrayList<InputPart>();
parts.add(part);
MultivaluedMap<String, String> mm = new MultivaluedMapImpl<String, String>();
List<String> contDis = new ArrayList<String>();
contDis.add("form-data; name=\"upload\"; filename=\"test_file.zip\"");
mm.put("Content-Disposition", contDis);
when(input.getParts()).thenReturn(parts);
when(part.getHeaders()).thenReturn(mm);
when(part.getBody(any(GenericType.class))).thenReturn(archive);
when(importer.loadExport(eq(owner), any(File.class), any(ConflictOverrides.class)))
.thenReturn(new HashMap<String, Object>());
thisOwnerResource.importManifest(owner.getKey(), new String [] {}, input);
List<ImportRecord> records = importRecordCurator.findRecords(owner);
ImportRecord ir = records.get(0);
assertEquals("test_file.zip", ir.getFileName());
assertEquals(owner, ir.getOwner());
assertEquals(ImportRecord.Status.SUCCESS, ir.getStatus());