forked from wangziqi/ruoyi-vue-pro
test(education): align question fixtures with node lifecycle
This commit is contained in:
@@ -10,8 +10,10 @@ import cn.iocoder.yudao.module.education.dal.dataobject.catalog.QuestionDO;
|
|||||||
import cn.iocoder.yudao.module.education.dal.dataobject.catalog.QuestionVersionDO;
|
import cn.iocoder.yudao.module.education.dal.dataobject.catalog.QuestionVersionDO;
|
||||||
import cn.iocoder.yudao.module.education.dal.dataobject.catalog.ContentEntryDO;
|
import cn.iocoder.yudao.module.education.dal.dataobject.catalog.ContentEntryDO;
|
||||||
import cn.iocoder.yudao.module.education.dal.dataobject.catalog.ContentNodeDO;
|
import cn.iocoder.yudao.module.education.dal.dataobject.catalog.ContentNodeDO;
|
||||||
|
import cn.iocoder.yudao.module.education.dal.dataobject.catalog.ContentNodeLifecycleAuditDO;
|
||||||
import cn.iocoder.yudao.module.education.dal.mysql.catalog.ContentEntryMapper;
|
import cn.iocoder.yudao.module.education.dal.mysql.catalog.ContentEntryMapper;
|
||||||
import cn.iocoder.yudao.module.education.dal.mysql.catalog.ContentNodeMapper;
|
import cn.iocoder.yudao.module.education.dal.mysql.catalog.ContentNodeMapper;
|
||||||
|
import cn.iocoder.yudao.module.education.dal.mysql.catalog.ContentNodeLifecycleAuditMapper;
|
||||||
import cn.iocoder.yudao.module.education.dal.mysql.catalog.QuestionLifecycleAuditMapper;
|
import cn.iocoder.yudao.module.education.dal.mysql.catalog.QuestionLifecycleAuditMapper;
|
||||||
import cn.iocoder.yudao.module.education.dal.mysql.catalog.QuestionMapper;
|
import cn.iocoder.yudao.module.education.dal.mysql.catalog.QuestionMapper;
|
||||||
import cn.iocoder.yudao.module.education.dal.mysql.catalog.QuestionVersionMapper;
|
import cn.iocoder.yudao.module.education.dal.mysql.catalog.QuestionVersionMapper;
|
||||||
@@ -53,6 +55,7 @@ class TenantQuestionLifecyclePostgreSqlIntegrationTest extends PostgreSqlDbInteg
|
|||||||
@Resource private PlatformTransactionManager transactionManager;
|
@Resource private PlatformTransactionManager transactionManager;
|
||||||
@Resource private ContentEntryMapper contentEntryMapper;
|
@Resource private ContentEntryMapper contentEntryMapper;
|
||||||
@Resource private ContentNodeMapper contentNodeMapper;
|
@Resource private ContentNodeMapper contentNodeMapper;
|
||||||
|
@Resource private ContentNodeLifecycleAuditMapper contentNodeAuditMapper;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUpTenant() {
|
void setUpTenant() {
|
||||||
@@ -215,10 +218,7 @@ class TenantQuestionLifecyclePostgreSqlIntegrationTest extends PostgreSqlDbInteg
|
|||||||
lifecycleService.publish(id, 7L);
|
lifecycleService.publish(id, 7L);
|
||||||
assertNodeQuestionCount(200L, 1L);
|
assertNodeQuestionCount(200L, 1L);
|
||||||
|
|
||||||
ContentNodeDO update = new ContentNodeDO();
|
archiveNode(200L, 10L);
|
||||||
update.setId(200L);
|
|
||||||
update.setIsActive(false);
|
|
||||||
contentNodeMapper.updateById(update);
|
|
||||||
|
|
||||||
assertNodeQuestionCount(200L, 0L);
|
assertNodeQuestionCount(200L, 0L);
|
||||||
assertNotNull(questionCatalogService.getQuestion(String.valueOf(id)));
|
assertNotNull(questionCatalogService.getQuestion(String.valueOf(id)));
|
||||||
@@ -343,6 +343,46 @@ class TenantQuestionLifecyclePostgreSqlIntegrationTest extends PostgreSqlDbInteg
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void insertNode(Long id, Long tenantId, String scope, Long entryId, String name) {
|
private void insertNode(Long id, Long tenantId, String scope, Long entryId, String name) {
|
||||||
|
if ("TENANT_OWNED".equals(scope)) {
|
||||||
|
new TransactionTemplate(transactionManager).executeWithoutResult(status -> {
|
||||||
|
ContentNodeDO node = newNode(id, tenantId, scope, entryId, name);
|
||||||
|
node.setPublicationStatus("DRAFT");
|
||||||
|
node.setIsActive(false);
|
||||||
|
node.setIsHidden(true);
|
||||||
|
node.setAuthoringVersion(0);
|
||||||
|
contentNodeMapper.insert(node);
|
||||||
|
assertEquals(1, contentNodeMapper.updateLifecycleCas(tenantId, id, "DRAFT", "ACTIVE", true, 0));
|
||||||
|
ContentNodeLifecycleAuditDO audit = new ContentNodeLifecycleAuditDO();
|
||||||
|
audit.setTenantId(tenantId);
|
||||||
|
audit.setNodeId(id);
|
||||||
|
audit.setAuthoringVersion(1);
|
||||||
|
audit.setActorId(7L);
|
||||||
|
audit.setFromStatus("DRAFT");
|
||||||
|
audit.setToStatus("ACTIVE");
|
||||||
|
audit.setOccurredAt(java.time.LocalDateTime.now());
|
||||||
|
contentNodeAuditMapper.insert(audit);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
contentNodeMapper.insert(newNode(id, tenantId, scope, entryId, name));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void archiveNode(Long id, Long tenantId) {
|
||||||
|
new TransactionTemplate(transactionManager).executeWithoutResult(status -> {
|
||||||
|
assertEquals(1, contentNodeMapper.updateLifecycleCas(tenantId, id, "ACTIVE", "ARCHIVED", false, 1));
|
||||||
|
ContentNodeLifecycleAuditDO audit = new ContentNodeLifecycleAuditDO();
|
||||||
|
audit.setTenantId(tenantId);
|
||||||
|
audit.setNodeId(id);
|
||||||
|
audit.setAuthoringVersion(2);
|
||||||
|
audit.setActorId(7L);
|
||||||
|
audit.setFromStatus("ACTIVE");
|
||||||
|
audit.setToStatus("ARCHIVED");
|
||||||
|
audit.setOccurredAt(java.time.LocalDateTime.now());
|
||||||
|
contentNodeAuditMapper.insert(audit);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private ContentNodeDO newNode(Long id, Long tenantId, String scope, Long entryId, String name) {
|
||||||
ContentNodeDO node = new ContentNodeDO();
|
ContentNodeDO node = new ContentNodeDO();
|
||||||
node.setId(id);
|
node.setId(id);
|
||||||
node.setTenantId(tenantId);
|
node.setTenantId(tenantId);
|
||||||
@@ -350,6 +390,6 @@ class TenantQuestionLifecyclePostgreSqlIntegrationTest extends PostgreSqlDbInteg
|
|||||||
node.setEntryId(entryId);
|
node.setEntryId(entryId);
|
||||||
node.setName(name);
|
node.setName(name);
|
||||||
node.setNodeType("category");
|
node.setNodeType("category");
|
||||||
contentNodeMapper.insert(node);
|
return node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user