QTIResultServiceImpl extends BasicManager implements UserDataDeletable, QTIResultService { @Override public void deleteUserData(final Identity identity, final String newDeletedUserName) { final List qtiResults = qtiResultDao.findQtiResultSets(identity); for (final Iterator iter = qtiResults.iterator(); iter.hasNext();) { qtiResultDao.deleteResultSet((QTIResultSet) iter.next()); } log.debug("Delete all QTI result data in db for identity=" + identity); } private  QTIResultServiceImpl(); protected  QTIResultServiceImpl(QTIResultDao qtiResultDaoMock); @Override boolean hasResultSets(final Long olatResource, final String olatResourceDetail, final Long repositoryRef); @Override List getResultSets(final Long olatResource, final String olatResourceDetail, final Long repositoryRef, final Identity identity); @Override List selectResults(final Long olatResource, final String olatResourceDetail, final Long repositoryRef, final int type); @Override int deleteAllResults(final Long olatRes, final String olatResDet, final Long repRef); @Override void deleteResults(final QTIResultSet qtiResultSet); static Map parseResponseStrAnswers(final String answerCode); static List parseResponseLidAnswers(final String answerCode); @Override void deleteUserData(final Identity identity, final String newDeletedUserName);  }
@Test public void testDeleteUserData() { Identity identityMock = mock(Identity.class); String newDeletedUserName = "deletedUserName"; List qtiResultSets = new ArrayList(); QTIResultSet qtiResultSet1 = mock(QTIResultSet.class); qtiResultSets.add(qtiResultSet1); QTIResultSet qtiResultSet2 = mock(QTIResultSet.class); qtiResultSets.add(qtiResultSet2); when(qtiResultDaoMock.findQtiResultSets(identityMock)).thenReturn(qtiResultSets); qtiResultServiceImpl.deleteUserData(identityMock, newDeletedUserName); verify(qtiResultDaoMock).deleteResultSet(qtiResultSet1); verify(qtiResultDaoMock).deleteResultSet(qtiResultSet2); }