Skip to content
Snippets Groups Projects
Commit bc1ed9f2 authored by aboeckle's avatar aboeckle
Browse files

OO-4455 Fixed wrong messages

parent ecd439a4
No related branches found
No related tags found
No related merge requests found
......@@ -94,7 +94,7 @@ public interface CourseDisclaimerManager {
* @param repositoryEntryRef
* @return boolean
*/
public boolean isAnyConsent(RepositoryEntryRef repositoryEntryRef);
public boolean hasAnyConsent(RepositoryEntryRef repositoryEntryRef);
/**
* Returns the amount of consents to a repository entry
......@@ -103,4 +103,11 @@ public interface CourseDisclaimerManager {
* @return Long
*/
public Long countConsents(RepositoryEntryRef repositoryEntryRef);
/**
* Returns whether any entry in the database for this repository entry is existing
* @param repositoryEntryRef
* @return boolean
*/
public boolean hasAnyEntry(RepositoryEntryRef repositoryEntryRef);
}
......@@ -118,12 +118,29 @@ public class CourseDisclaimerManagerImpl implements CourseDisclaimerManager {
}
@Override
public boolean isAnyConsent(RepositoryEntryRef repositoryEntryRef) {
return !getConsents(repositoryEntryRef).isEmpty();
public boolean hasAnyConsent(RepositoryEntryRef repositoryEntryRef) {
List<CourseDisclaimerConsent> consents = getConsents(repositoryEntryRef);
if (consents.isEmpty()) {
return false;
} else {
for (CourseDisclaimerConsent courseDisclaimerConsent : consents) {
if (courseDisclaimerConsent.getConsentDate() != null) {
return true;
}
}
}
return false;
}
@Override
public Long countConsents(RepositoryEntryRef repositoryEntryRef) {
return courseDisclaimerDAO.countConsents(repositoryEntryRef);
}
@Override
public boolean hasAnyEntry(RepositoryEntryRef repositoryEntryRef) {
return !getConsents(repositoryEntryRef).isEmpty();
}
}
......@@ -153,7 +153,7 @@ public class CourseDisclaimerController extends FormBasicController {
@Override
protected void formOK(UserRequest ureq) {
if (disclaimerManager.isAnyConsent(repositoryEntry)) {
if (disclaimerManager.hasAnyEntry(repositoryEntry)) {
if (!disclaimer1Enabled && !disclaimer2Enabled) {
// Ask whether existing entries should be deleted
askForRemoval(ureq);
......@@ -361,7 +361,7 @@ public class CourseDisclaimerController extends FormBasicController {
!StringHelper.containsNonWhitespace(courseConfig.getDisclaimerTerms(2))))
&&
// Check if there any consents yet
disclaimerManager.isAnyConsent(repositoryEntry)) {
disclaimerManager.hasAnyConsent(repositoryEntry)) {
askForRevoke(ureq);
}
......
......@@ -96,7 +96,7 @@ public class CourseDisclaimerUpdateConfirmController extends FormBasicController
}
}
confirmMessage += translate("dialog.confirm" + (deleteConfirm ? ".remove" : ".revoke"), String.valueOf(numOfConsents) + (numOfConsents != 1 ? ".plural" : ""));
confirmMessage += translate("dialog.confirm" + (deleteConfirm ? ".remove" : ".revoke") + (numOfConsents != 1 ? ".plural" : ""), String.valueOf(numOfConsents));
layout.contextPut("confirmMessage", confirmMessage);
FormLayoutContainer layoutCont = FormLayoutContainer.createDefaultFormLayout("confirm", getTranslator());
......
......@@ -153,7 +153,7 @@ public class CourseDisclaimerManagerTest extends OlatTestCase {
public void acceptDisclaimer() {
initDisclaimer();
Assert.assertFalse(courseDisclaimerManager.isAnyConsent(repositoryEntry));
Assert.assertFalse(courseDisclaimerManager.hasAnyConsent(repositoryEntry));
courseDisclaimerManager.acceptDisclaimer(repositoryEntry, id1, true, true);
courseDisclaimerManager.acceptDisclaimer(repositoryEntry, id2, true, false);
......@@ -228,4 +228,39 @@ public class CourseDisclaimerManagerTest extends OlatTestCase {
Assert.assertTrue(courseDisclaimerManager.isAccessGranted(repositoryEntry, id2));
assertThat(courseDisclaimerManager.getConsents(repositoryEntry)).hasSize(2);
}
@Test
public void hasAnyEntry() {
initDisclaimer();
Assert.assertFalse(courseDisclaimerManager.hasAnyEntry(repositoryEntry));
courseDisclaimerManager.acceptDisclaimer(repositoryEntry, id1, true, true);
courseDisclaimerManager.acceptDisclaimer(repositoryEntry, id2, true, true);
dbInstance.commitAndCloseSession();
Assert.assertTrue(courseDisclaimerManager.hasAnyEntry(repositoryEntry));
}
@Test
public void hasAnyConsent() {
initDisclaimer();
Assert.assertFalse(courseDisclaimerManager.hasAnyConsent(repositoryEntry));
courseDisclaimerManager.acceptDisclaimer(repositoryEntry, id1, true, true);
courseDisclaimerManager.acceptDisclaimer(repositoryEntry, id2, true, true);
dbInstance.commitAndCloseSession();
Assert.assertTrue(courseDisclaimerManager.hasAnyConsent(repositoryEntry));
courseDisclaimerManager.revokeAllConsents(repositoryEntry);
dbInstance.commitAndCloseSession();
Assert.assertFalse(courseDisclaimerManager.hasAnyConsent(repositoryEntry));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment