优化
This commit is contained in:
@@ -27,6 +27,7 @@ class DirectEventClientTest {
|
||||
|
||||
@Test void feeIsSentOnlyToFinance() {
|
||||
var event = event(EventTypes.BUSINESS_FEE_SOURCE_CHANGED);
|
||||
when(finance.fee("token", event)).thenReturn(ApiResponse.success(DeliveryAck.of(event, DeliveryAck.Outcome.APPLIED)));
|
||||
client.receive("token", event);
|
||||
verify(finance).fee("token", event);
|
||||
verifyNoMoreInteractions(finance);
|
||||
@@ -45,7 +46,7 @@ class DirectEventClientTest {
|
||||
|
||||
@Test void unsupportedEventsHaveNoDefaultDestination() {
|
||||
assertThatThrownBy(() -> client.receive("token", event(EventTypes.WALLET_COMMAND_COMPLETED)))
|
||||
.isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Unsupported outbound");
|
||||
.isInstanceOf(com.baiyue.common.web.EventDeliveryFailure.class).hasMessageContaining("Unsupported outbound");
|
||||
verifyNoInteractions(firstleg, finance);
|
||||
}
|
||||
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.baiyue.lastleg.controller;
|
||||
|
||||
import com.baiyue.common.event.EventProtocolException;
|
||||
import com.baiyue.common.event.EventDependencyNotReadyException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
class EventConsumptionExceptionHandlerTest {
|
||||
@RestController static class Probe {
|
||||
@GetMapping("/protocol") void protocol() { throw new EventProtocolException("invalid hash"); }
|
||||
@GetMapping("/dependency") void dependency() { throw new EventDependencyNotReadyException("source not ready"); }
|
||||
}
|
||||
@Test void protocolAndDependencyHaveDistinctWireCodes() throws Exception {
|
||||
var mvc = MockMvcBuilders.standaloneSetup(new Probe()).setControllerAdvice(new EventConsumptionExceptionHandler()).build();
|
||||
mvc.perform(get("/protocol")).andExpect(status().isOk()).andExpect(jsonPath("$.code").value("EVT_PROTOCOL"));
|
||||
mvc.perform(get("/dependency")).andExpect(status().isOk()).andExpect(jsonPath("$.code").value("EVT_DEPENDENCY"));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -155,7 +155,7 @@ class LastlegOrderControllerTest {
|
||||
when(event.eventType()).thenReturn(EventTypes.IAM_USER_STATUS_CHANGED);
|
||||
LoadingCompletedConsumer loading = (LoadingCompletedConsumer) ReflectionTestUtils.getField(controller, "consumer");
|
||||
|
||||
assertThrows(ResponseStatusException.class, () -> controller.receive("internal-token", event));
|
||||
assertThrows(com.baiyue.common.event.EventProtocolException.class, () -> controller.receive("internal-token", event));
|
||||
|
||||
verify(loading, never()).consume(event);
|
||||
}
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ class InboundUnloadCompletedOutboxRelayTest {
|
||||
|
||||
relay.relay();
|
||||
|
||||
verify(repository).retry(eq(9001L), anyString(), any(LocalDateTime.class), eq("consumer unavailable"));
|
||||
verify(repository).retry(eq(9001L), anyString(), any(LocalDateTime.class), contains("consumer unavailable"));
|
||||
verify(repository, never()).published(anyLong(), anyString(), any());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user