Search in sources :

Example 6 with QuestionItemAuditLog

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);
}
Also used : QuestionItemAuditLog(org.olat.modules.qpool.QuestionItemAuditLog) Test(org.junit.Test)

Example 7 with QuestionItemAuditLog

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);
}
Also used : Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItemAuditLog(org.olat.modules.qpool.QuestionItemAuditLog) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 8 with QuestionItemAuditLog

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();
}
Also used : Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItemAuditLog(org.olat.modules.qpool.QuestionItemAuditLog) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 9 with QuestionItemAuditLog

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();
}
Also used : Identity(org.olat.core.id.Identity) QuestionItem(org.olat.modules.qpool.QuestionItem) QuestionItemAuditLog(org.olat.modules.qpool.QuestionItemAuditLog) QItemType(org.olat.modules.qpool.model.QItemType) Test(org.junit.Test)

Example 10 with QuestionItemAuditLog

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);
}
Also used : QuestionItemAuditLog(org.olat.modules.qpool.QuestionItemAuditLog) Test(org.junit.Test)

Aggregations

QuestionItemAuditLog (org.olat.modules.qpool.QuestionItemAuditLog)10 Test (org.junit.Test)8 QuestionItem (org.olat.modules.qpool.QuestionItem)6 Identity (org.olat.core.id.Identity)4 QItemType (org.olat.modules.qpool.model.QItemType)4 Date (java.util.Date)2 License (org.olat.core.commons.services.license.License)2 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)2