### Question:
CitationManager implements ICitationManager { @Override public ICitation createCitation(IUser user, String groupId, List<String> collectionIds, ICitation citation) throws ZoteroConnectionException, ZoteroItemCreationFailedException, GroupDoesNotExistException, ZoteroHttpStatusException { Optional<ICitationGroup> groupOptional = groupRepository.findByGroupId(new Long(groupId)); if (!groupOptional.isPresent()) { throw new GroupDoesNotExistException("Group with id " + groupId + " does not exist."); } ICitation newCitation = zoteroManager.createCitation(user, groupId, collectionIds, citation); citationRepository.save((Citation) newCitation); ICitationGroup group = groupOptional.get(); group.setLastLocallyModifiedOn(OffsetDateTime.now().toString()); groupRepository.save((CitationGroup) group); return newCitation; }  @PostConstruct void init(); @Override ICitation getCitation(IUser user, String groupId, String key); @Override ICitation getCitationFromZotero(IUser user, String groupId, String key); @Override void updateCitation(IUser user, String groupId, ICitation citation); @Override ICitation createCitation(IUser user, String groupId, List<String> collectionIds, ICitation citation); @Override ICitation updateCitationFromZotero(IUser user, String groupId, String itemKey); @Override List<ICitationGroup> getGroups(IUser user); @Override @SuppressWarnings("unchecked") CloseableIterator<ICitation> getAllGroupItems(IUser user, String groupId, String collectionId); @Override CitationResults getGroupItems(IUser user, String groupId, String collectionId, int page, String sortBy); @Override void forceGroupItemsRefresh(IUser user, String groupId, String collectionId, int page, String sortBy); @Override List<BibField> getItemTypeFields(IUser user, ItemType itemType); @Override List<String> getValidCreatorTypes(IUser user, ItemType itemType); @Override CitationPage getPrevAndNextCitation(IUser user, String groupId, String collectionId, int page, String sortBy,
            int index);  }### Answer:
@Test public void test_createCitation_success() throws ZoteroConnectionException, ZoteroItemCreationFailedException, GroupDoesNotExistException, ZoteroHttpStatusException { ICitation newCitation = new Citation(); ICitation createdCitation = new Citation(); createdCitation.setKey("KEY"); Mockito.when(zoteroManager.createCitation(user, GROUP_ID, new ArrayList<>(), newCitation)).thenReturn(createdCitation); ICitation actual = managerToTest.createCitation(user, GROUP_ID, new ArrayList<>(), newCitation); Mockito.verify(citationRepository).save((Citation)createdCitation); Assert.assertEquals(createdCitation, actual); }
@Test(expected=ZoteroItemCreationFailedException.class) public void test_createCitation_failure() throws ZoteroConnectionException, ZoteroItemCreationFailedException, GroupDoesNotExistException, ZoteroHttpStatusException { ICitation newCitation = new Citation(); Mockito.when(zoteroManager.createCitation(user, GROUP_ID, new ArrayList<>(), newCitation)).thenThrow(new ZoteroItemCreationFailedException()); managerToTest.createCitation(user, GROUP_ID, new ArrayList<>(), newCitation); }