mirror of
https://github.com/iflytek/skillhub.git
synced 2026-10-15 04:18:20 +00:00
test(review): tighten persistence assertions
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
This commit is contained in:
parent
e7771cf208
commit
22b3a719c9
2 changed files with 9 additions and 1 deletions
|
|
@ -77,6 +77,11 @@ class SkillReviewModerationFlowIntegrationTest {
|
|||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.status").value("HIDDEN"));
|
||||
|
||||
SkillRating hidden = ratingRepository.findById(review.getId()).orElseThrow();
|
||||
assertThat(hidden.getReviewStatus()).isEqualTo(SkillReviewStatus.HIDDEN);
|
||||
assertThat(hidden.getModeratedBy()).isEqualTo(ADMIN_ID);
|
||||
assertThat(hidden.getModerationReason()).isEqualTo("off topic");
|
||||
|
||||
mockMvc.perform(post("/api/v1/admin/skill-reviews/" + review.getId() + "/restore")
|
||||
.with(authentication(adminAuth()))
|
||||
.with(csrf()))
|
||||
|
|
@ -89,6 +94,8 @@ class SkillReviewModerationFlowIntegrationTest {
|
|||
|
||||
List<String> actions = auditLogRepository.findAll().stream()
|
||||
.filter(log -> ADMIN_ID.equals(log.getActorUserId()))
|
||||
.filter(log -> review.getId().equals(log.getTargetId()))
|
||||
.filter(log -> "SKILL_REVIEW".equals(log.getTargetType()))
|
||||
.map(AuditLog::getAction)
|
||||
.toList();
|
||||
assertThat(actions).contains("SKILL_REVIEW_HIDE", "SKILL_REVIEW_RESTORE");
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.iflytek.skillhub.domain.social.SkillReviewStatus;
|
|||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import jakarta.persistence.OptimisticLockException;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
|
|
@ -78,7 +79,7 @@ class SkillRatingOptimisticLockingTest {
|
|||
secondManager.persist(duplicate);
|
||||
secondManager.flush();
|
||||
secondManager.getTransaction().commit();
|
||||
}).isInstanceOf(RuntimeException.class);
|
||||
}).satisfies(error -> assertThat(hasCause(error, ConstraintViolationException.class)).isTrue());
|
||||
|
||||
EntityManager verifier = entityManagerFactory.createEntityManager();
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue