use of org.olat.modules.qpool.QuestionItemAuditLog in project OpenOLAT by OpenOLAT.
the class QuestionItemAuditLogBuilderImplTest method shouldBuildAuditLogWithAllAttributes.
@Test
public void shouldBuildAuditLogWithAllAttributes() {
QuestionItemAuditLog auditLog = new QuestionItemAuditLogBuilderImpl(qpoolServiceMock, licenseServiceMock, authorMock, ACTION).withBefore(qitemMock).withAfter(qitemMock).withMessage(MESSAGE).create();
assertThat(auditLog.getAuthorKey()).isEqualTo(AUTHOR_KEY);
assertThat(auditLog.getAction()).isEqualTo(ACTION.name());
assertThat(auditLog.getQuestionItemKey()).isEqualTo(QITEM_KEY);
assertThat(auditLog.getBefore()).isNotNull();
assertThat(auditLog.getAfter()).isNotNull();
assertThat(auditLog.getLicenseBefore()).isNotNull();
assertThat(auditLog.getLicenseAfter()).isNotNull();
assertThat(auditLog.getMessage()).isEqualTo(MESSAGE);
}
use of org.olat.modules.qpool.QuestionItemAuditLog in project OpenOLAT by OpenOLAT.
the class QuestionItemAuditLogDAOTest method shouldFindAuditLogByQuestionItem.
@Test
public void shouldFindAuditLogByQuestionItem() {
QItemType qItemType = qItemTypeDao.loadByType(QuestionType.MC.name());
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("qitem-audit-log");
QuestionItem item = questionDao.createAndPersist(id, "NGC 55", QTI21Constants.QTI_21_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
QuestionItemAuditLog auditLog = qpoolService.createAuditLogBuilder(id, QuestionItemAuditLog.Action.CREATE_QUESTION_ITEM_NEW).withBefore(item).create();
sut.persist(auditLog);
auditLog = qpoolService.createAuditLogBuilder(id, QuestionItemAuditLog.Action.UPDATE_QUESTION).withBefore(item).create();
sut.persist(auditLog);
auditLog = qpoolService.createAuditLogBuilder(id, QuestionItemAuditLog.Action.UPDATE_QUESTION_ITEM_METADATA).withBefore(item).create();
sut.persist(auditLog);
QuestionItem otherItem = questionDao.createAndPersist(id, "NGC 55", QTI21Constants.QTI_21_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
auditLog = qpoolService.createAuditLogBuilder(id, QuestionItemAuditLog.Action.UPDATE_QUESTION_ITEM_METADATA).withBefore(otherItem).create();
sut.persist(auditLog);
dbInstance.commitAndCloseSession();
List<QuestionItemAuditLog> auditLogs = sut.getAuditLogByQuestionItem(item);
assertThat(auditLogs).hasSize(3);
}
use of org.olat.modules.qpool.QuestionItemAuditLog in project OpenOLAT by OpenOLAT.
the class QuestionItemAuditLogDAOTest method shouldPersistAuditLog.
@Test
public void shouldPersistAuditLog() {
QItemType qItemType = qItemTypeDao.loadByType(QuestionType.MC.name());
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("qitem-audit-log");
QuestionItem item = questionDao.createAndPersist(id, "NGC 55", QTI21Constants.QTI_21_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
licenseService.loadOrCreateLicense(item);
QuestionItemAuditLog auditLog = qpoolService.createAuditLogBuilder(id, QuestionItemAuditLog.Action.CREATE_QUESTION_ITEM_NEW).withBefore(item).withAfter(item).withMessage("item was created").create();
dbInstance.commitAndCloseSession();
sut.persist(auditLog);
dbInstance.commitAndCloseSession();
List<QuestionItemAuditLog> auditLogs = sut.getAuditLogByQuestionItem(item);
QuestionItemAuditLog loadedAuditLog = auditLogs.get(0);
assertThat(loadedAuditLog.getAuthorKey()).isNotNull();
assertThat(loadedAuditLog.getBefore()).isNotNull();
assertThat(loadedAuditLog.getAfter()).isNotNull();
assertThat(loadedAuditLog.getLicenseBefore()).isNotNull();
assertThat(loadedAuditLog.getLicenseAfter()).isNotNull();
assertThat(loadedAuditLog.getMessage()).isNotNull();
}
use of org.olat.modules.qpool.QuestionItemAuditLog in project openolat by klemens.
the class QuestionItemAuditLogDAOTest method shouldPersistAuditLog.
@Test
public void shouldPersistAuditLog() {
QItemType qItemType = qItemTypeDao.loadByType(QuestionType.MC.name());
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("qitem-audit-log");
QuestionItem item = questionDao.createAndPersist(id, "NGC 55", QTI21Constants.QTI_21_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, qItemType);
licenseService.loadOrCreateLicense(item);
QuestionItemAuditLog auditLog = qpoolService.createAuditLogBuilder(id, QuestionItemAuditLog.Action.CREATE_QUESTION_ITEM_NEW).withBefore(item).withAfter(item).withMessage("item was created").create();
dbInstance.commitAndCloseSession();
sut.persist(auditLog);
dbInstance.commitAndCloseSession();
List<QuestionItemAuditLog> auditLogs = sut.getAuditLogByQuestionItem(item);
QuestionItemAuditLog loadedAuditLog = auditLogs.get(0);
assertThat(loadedAuditLog.getAuthorKey()).isNotNull();
assertThat(loadedAuditLog.getBefore()).isNotNull();
assertThat(loadedAuditLog.getAfter()).isNotNull();
assertThat(loadedAuditLog.getLicenseBefore()).isNotNull();
assertThat(loadedAuditLog.getLicenseAfter()).isNotNull();
assertThat(loadedAuditLog.getMessage()).isNotNull();
}
use of org.olat.modules.qpool.QuestionItemAuditLog in project openolat by klemens.
the class QuestionItemAuditLogBuilderImplTest method shouldBuildAuditLogWithAllAttributes.
@Test
public void shouldBuildAuditLogWithAllAttributes() {
QuestionItemAuditLog auditLog = new QuestionItemAuditLogBuilderImpl(qpoolServiceMock, licenseServiceMock, authorMock, ACTION).withBefore(qitemMock).withAfter(qitemMock).withMessage(MESSAGE).create();
assertThat(auditLog.getAuthorKey()).isEqualTo(AUTHOR_KEY);
assertThat(auditLog.getAction()).isEqualTo(ACTION.name());
assertThat(auditLog.getQuestionItemKey()).isEqualTo(QITEM_KEY);
assertThat(auditLog.getBefore()).isNotNull();
assertThat(auditLog.getAfter()).isNotNull();
assertThat(auditLog.getLicenseBefore()).isNotNull();
assertThat(auditLog.getLicenseAfter()).isNotNull();
assertThat(auditLog.getMessage()).isEqualTo(MESSAGE);
}
Aggregations