### Question:
WorkObject extends ContentContainerObject { public FileObject addDataFile(URI storageUri, String filename, String mimetype, String sha1Checksum, String md5Checksum) { return addDataFile(null, storageUri, filename, mimetype, sha1Checksum, md5Checksum, null); } protected  WorkObject(PID pid, RepositoryObjectDriver driver, RepositoryObjectFactory repoObjFactory); @Override WorkObject validateType(); void clearPrimaryObject(); void setPrimaryObject(PID primaryPid); FileObject getPrimaryObject(); @Override ContentContainerObject addMember(ContentObject member); FileObject addDataFile(URI storageUri, String filename, String mimetype,
            String sha1Checksum, String md5Checksum); FileObject addDataFile(URI storageUri, String filename,
            String mimetype, String sha1Checksum, String md5Checksum, Model model); FileObject addDataFile(PID filePid, URI storageUri, String filename,
            String mimetype, String sha1Checksum, String md5Checksum, Model model);  }### Answer:
@Test public void addDataFileTest() { when(repoObjFactory.createFileObject(any(Model.class))).thenReturn(fileObj); work.addDataFile(contentUri, FILENAME, MIMETYPE, SHA1, MD5); ArgumentCaptor.forClass(PID.class); ArgumentCaptor<Model> modelCaptor = ArgumentCaptor.forClass(Model.class); verify(repoObjFactory).createFileObject(modelCaptor.capture()); Model fileObjModel = modelCaptor.getValue(); assertTrue(fileObjModel.contains(null, DC.title, FILENAME)); verify(fileObj).addOriginalFile(contentUri, FILENAME, MIMETYPE, SHA1, MD5); verify(repoObjFactory).addMember(eq(work), eq(fileObj)); }
@Test(expected = IllegalArgumentException.class) public void addDataFileNoContentTest() { work.addDataFile(null, FILENAME, MIMETYPE, SHA1, MD5); }