### Question:
UpdateDescriptionService { public BinaryObject updateDescription(AgentPrincipals agent, PID pid, InputStream modsStream) throws MetadataValidationException, IOException { ContentObject obj = (ContentObject) repoObjLoader.getRepositoryObject(pid); return updateDescription(null, agent, obj, modsStream); } UpdateDescriptionService(); BinaryObject updateDescription(AgentPrincipals agent, PID pid, InputStream modsStream); BinaryObject updateDescription(BinaryTransferSession transferSession, AgentPrincipals agent,
            PID pid, InputStream modsStream); BinaryObject updateDescription(BinaryTransferSession transferSession, AgentPrincipals agent,
            ContentObject obj, InputStream modsStream); void setAclService(AccessControlService aclService); void setRepositoryObjectLoader(RepositoryObjectLoader repoObjLoader); void setRepositoryObjectFactory(RepositoryObjectFactory repoObjFactory); void setOperationsMessageSender(OperationsMessageSender operationsMessageSender); void setModsValidator(MODSValidator modsValidator); void setVersionedDatastreamService(VersionedDatastreamService versioningService); void setValidate(boolean validate); void setSendsMessages(boolean sendsMessages); void setChecksAccess(boolean checksAccess);  }### Answer:
@Test public void updateDescriptionTest() throws Exception { service.updateDescription(agent, objPid, modsStream); verify(versioningService).addVersion(versionCaptor.capture()); DatastreamVersion version = versionCaptor.getValue(); assertEquals(modsPid, version.getDsPid()); assertEquals("text/xml", version.getContentType()); assertEquals(FILE_CONTENT, IOUtils.toString(version.getContentStream())); assertMessageSent(); }
@Test public void updateDescriptionAlreadyExistsTest() throws Exception { when(repoObjFactory.objectExists(modsPid.getRepositoryUri())).thenReturn(true); service.updateDescription(agent, objPid, modsStream); verify(versioningService).addVersion(versionCaptor.capture()); DatastreamVersion version = versionCaptor.getValue(); assertEquals(modsPid, version.getDsPid()); assertEquals("text/xml", version.getContentType()); assertEquals(FILE_CONTENT, IOUtils.toString(version.getContentStream())); assertMessageSent(); }
@Test(expected = AccessRestrictionException.class) public void insufficientAccessTest() throws Exception { doThrow(new AccessRestrictionException()).when(aclService) .assertHasAccess(anyString(), eq(objPid), any(AccessGroupSet.class), any(Permission.class)); service.updateDescription(agent, objPid, modsStream); }
@Test(expected = MetadataValidationException.class) public void invalidModsTest() throws Exception { doThrow(new MetadataValidationException()).when(modsValidator).validate(any(InputStream.class)); service.updateDescription(agent, objPid, modsStream); }
@Test public void updateDescriptionProvidedSession() throws Exception { service.updateDescription(transferSession, agent, objPid, modsStream); verify(versioningService).addVersion(versionCaptor.capture()); DatastreamVersion version = versionCaptor.getValue(); assertEquals(FILE_CONTENT, IOUtils.toString(version.getContentStream())); assertEquals(transferSession, version.getTransferSession()); assertMessageSent(); }