fix(education): clear optional collection metadata
This commit is contained in:
@@ -53,10 +53,19 @@ public interface QuestionCollectionMapper extends BaseMapperX<QuestionCollection
|
||||
.eq(QuestionCollectionDO::getDeleted, false));
|
||||
}
|
||||
default int updateDraftCas(Long tenantId, Long id, QuestionCollectionDO values, int expectedVersion) {
|
||||
return update(values, new LambdaUpdateWrapper<QuestionCollectionDO>().eq(QuestionCollectionDO::getId, id)
|
||||
return update(null, new LambdaUpdateWrapper<QuestionCollectionDO>().eq(QuestionCollectionDO::getId, id)
|
||||
.eq(QuestionCollectionDO::getTenantId, tenantId).eq(QuestionCollectionDO::getScope, "TENANT_OWNED")
|
||||
.eq(QuestionCollectionDO::getDeleted, false).eq(QuestionCollectionDO::getPublicationStatus, "DRAFT")
|
||||
.eq(QuestionCollectionDO::getAuthoringVersion, expectedVersion)
|
||||
.set(QuestionCollectionDO::getEntryId, values.getEntryId())
|
||||
.set(QuestionCollectionDO::getNodeId, values.getNodeId())
|
||||
.set(QuestionCollectionDO::getName, values.getName())
|
||||
.set(QuestionCollectionDO::getTitle, values.getTitle())
|
||||
.set(QuestionCollectionDO::getCollectionType, values.getCollectionType())
|
||||
.set(QuestionCollectionDO::getDurationMinutes, values.getDurationMinutes())
|
||||
.set(QuestionCollectionDO::getAccessRules, values.getAccessRules())
|
||||
.set(QuestionCollectionDO::getSortOrder, values.getSortOrder())
|
||||
.set(QuestionCollectionDO::getMetadata, values.getMetadata())
|
||||
.set(QuestionCollectionDO::getAuthoringVersion, expectedVersion + 1));
|
||||
}
|
||||
default int advanceMembershipCas(Long tenantId, Long id, int expectedVersion, int count) {
|
||||
|
||||
@@ -63,6 +63,20 @@ class QuestionCollectionAuthoringPostgreSqlIntegrationTest extends PostgreSqlDbI
|
||||
assertEquals(2L, auditMapper.selectCount());
|
||||
}
|
||||
|
||||
@Test void draftRevisionClearsNullableMetadata() {
|
||||
Long id = service.createDraft(command(null));
|
||||
QuestionCollectionAuthoringCommand cleared = new QuestionCollectionAuthoringCommand(
|
||||
activeNodeId, "manual-revised", null, null, null, 1, null, 0);
|
||||
assertEquals(1, service.reviseDraft(id, cleared));
|
||||
QuestionCollectionDO stored = collectionMapper.selectTenantOwnedById(10L, id);
|
||||
assertEquals("manual-revised", stored.getName());
|
||||
assertNull(stored.getTitle());
|
||||
assertNull(stored.getDurationMinutes());
|
||||
assertNull(stored.getAccessRules());
|
||||
assertNull(stored.getMetadata());
|
||||
assertEquals(1, stored.getAuthoringVersion());
|
||||
}
|
||||
|
||||
@Test void sameSizeAndEmptyMembershipReplacementAdvanceSharedVersion() {
|
||||
Long id = service.createDraft(command(null));
|
||||
assertEquals(1, service.replaceMembership(id, List.of(publishedQuestionIds.get(0)), 0));
|
||||
|
||||
Reference in New Issue
Block a user