This commit is contained in:
2026-08-24 17:15:48 +08:00
parent 132d96a99b
commit 3d8a1fac20
45 changed files with 1250 additions and 35 deletions
@@ -3,8 +3,10 @@ package com.baiyue.eventbridge.service;
import com.baiyue.eventbridge.mapper.BridgeInboxMapper;
import org.junit.jupiter.api.Test;
import org.springframework.test.util.ReflectionTestUtils;
import org.apache.ibatis.annotations.Update;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.*;
class EventReplayServiceTest {
@@ -28,6 +30,16 @@ class EventReplayServiceTest {
.isInstanceOf(IllegalStateException.class);
}
@Test
void replayOnlyRequeuesDeadStateAndDoesNotRewriteFrozenEvent() throws Exception {
String sql = String.join(" ", BridgeInboxMapper.class
.getMethod("replayDead", String.class, String.class)
.getAnnotation(Update.class).value()).replaceAll("\\s+", " ");
assertThat(sql).contains("status='RETRY'", "retry_count=0", "status='DEAD'")
.doesNotContain("payload_json=", "payload_hash=");
}
private EventReplayService service() {
EventReplayService service = new EventReplayService();
ReflectionTestUtils.setField(service, "inboxMapper", mapper);