fix(firstleg): wire finance outbox relay constructor

This commit is contained in:
2026-08-11 19:47:20 +08:00
parent 3809d2a028
commit 7c24c96f88
2 changed files with 21 additions and 0 deletions
@@ -8,6 +8,7 @@ import com.baiyue.firstleg.repository.FinanceFeeSourceOutboxRepository;
import com.fasterxml.jackson.databind.ObjectMapper;
import feign.FeignException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -39,6 +40,7 @@ public class FinanceFeeSourceOutboxRelay {
@Value("${baiyue.security.internal-service-token}")
private String internalToken;
@Autowired
public FinanceFeeSourceOutboxRelay(FinanceFeeSourceOutboxRepository repository,
FinanceFeeSourceEventClient client,
ObjectMapper objectMapper) {
@@ -10,6 +10,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.MapPropertySource;
import org.springframework.test.util.ReflectionTestUtils;
import java.time.Clock;
@@ -17,6 +19,7 @@ import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -33,6 +36,22 @@ class FinanceFeeSourceOutboxRelayTest {
private final FinanceFeeSourceEventClient client = mock(FinanceFeeSourceEventClient.class);
private final FinanceFeeSourceOutboxRelay relay = relay();
@Test
void springCreatesRelayWithItsAutowiredProductionConstructor() {
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
context.getEnvironment().getPropertySources().addFirst(new MapPropertySource(
"test", Map.of("baiyue.security.internal-service-token", "finance-token")));
context.registerBean(FinanceFeeSourceOutboxRepository.class, () -> repository);
context.registerBean(FinanceFeeSourceEventClient.class, () -> client);
context.registerBean(ObjectMapper.class, () -> json);
context.register(FinanceFeeSourceOutboxRelay.class);
context.refresh();
assertThat(context.getBean(FinanceFeeSourceOutboxRelay.class)).isNotNull();
}
}
@Test
void claimsThenPublishesOnlyAfterFinanceAcknowledgesSameEvent() throws Exception {
InboundOutboxEntity row = event();