SEBSERV-345 Merge branch 'dev-1.4' into development
Conflicts: src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java
This commit is contained in:
commit
5aeb14ea8e
4 changed files with 55 additions and 3 deletions
|
@ -779,4 +779,18 @@ public final class Utils {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isEqualsWithEmptyCheck(final String s1, final String s2) {
|
||||||
|
// checks equal strings and both null
|
||||||
|
if (Objects.equals(s1, s2)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check null and empty string
|
||||||
|
if (StringUtils.isBlank(s1) && StringUtils.isBlank(s2)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,15 +341,26 @@ class ExamUpdateHandler {
|
||||||
if (!Objects.equals(exam.name, quizData.name) ||
|
if (!Objects.equals(exam.name, quizData.name) ||
|
||||||
!Objects.equals(exam.startTime, quizData.startTime) ||
|
!Objects.equals(exam.startTime, quizData.startTime) ||
|
||||||
!Objects.equals(exam.endTime, quizData.endTime) ||
|
!Objects.equals(exam.endTime, quizData.endTime) ||
|
||||||
!Objects.equals(exam.getDescription(), quizData.description) ||
|
!Utils.isEqualsWithEmptyCheck(exam.getDescription(), quizData.description) ||
|
||||||
!Objects.equals(exam.getStartURL(), quizData.startURL)) {
|
!Utils.isEqualsWithEmptyCheck(exam.getStartURL(), quizData.startURL)) {
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Update difference from LMS. Exam:{}, QuizData: {}", exam, quizData);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quizData.additionalAttributes != null && !quizData.additionalAttributes.isEmpty()) {
|
if (quizData.additionalAttributes != null && !quizData.additionalAttributes.isEmpty()) {
|
||||||
for (final Map.Entry<String, String> attr : quizData.additionalAttributes.entrySet()) {
|
for (final Map.Entry<String, String> attr : quizData.additionalAttributes.entrySet()) {
|
||||||
if (!Objects.equals(exam.getAdditionalAttribute(attr.getKey()), attr.getValue())) {
|
final String currentAttrValue = exam.getAdditionalAttribute(attr.getKey());
|
||||||
|
if (!Utils.isEqualsWithEmptyCheck(currentAttrValue, attr.getValue())) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Update difference from LMS: attribute{}, currentValue: {}, lmsValue: {}",
|
||||||
|
attr.getKey(),
|
||||||
|
currentAttrValue,
|
||||||
|
attr.getValue());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,13 @@
|
||||||
|
|
||||||
package ch.ethz.seb.sebserver.gbl.util;
|
package ch.ethz.seb.sebserver.gbl.util;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ReplTest {
|
public class ReplTest {
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
|
@ -48,4 +55,11 @@ public class ReplTest {
|
||||||
// assertTrue(new Boolean(false) == new Boolean(false));
|
// assertTrue(new Boolean(false) == new Boolean(false));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testObjectEquals() {
|
||||||
|
assertTrue(Objects.equals("", ""));
|
||||||
|
assertTrue(Objects.equals(null, null));
|
||||||
|
assertFalse(Objects.equals("", null));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,4 +243,17 @@ public class UtilsTest {
|
||||||
.contains("ch.ethz.seb.sebserver.gbl.util.UtilsTest.testFormatStackTracePrint"));
|
.contains("ch.ethz.seb.sebserver.gbl.util.UtilsTest.testFormatStackTracePrint"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsEqualsWithEmptyCheck() {
|
||||||
|
assertTrue(Utils.isEqualsWithEmptyCheck("aa", "aa"));
|
||||||
|
assertTrue(Utils.isEqualsWithEmptyCheck("", ""));
|
||||||
|
assertTrue(Utils.isEqualsWithEmptyCheck(null, null));
|
||||||
|
assertTrue(Utils.isEqualsWithEmptyCheck("", null));
|
||||||
|
assertTrue(Utils.isEqualsWithEmptyCheck(null, ""));
|
||||||
|
assertTrue(Utils.isEqualsWithEmptyCheck(" ", null));
|
||||||
|
assertTrue(Utils.isEqualsWithEmptyCheck(" ", " "));
|
||||||
|
|
||||||
|
assertFalse(Utils.isEqualsWithEmptyCheck(" ", "a"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue