|
| 1 | +package org.springframework.integration.aws.support.config.xml.parsers; |
| 2 | + |
| 3 | +import org.bool.junit.mockito.inline.ConstructionMock; |
| 4 | + |
| 5 | +import org.assertj.core.api.InstanceOfAssertFactories; |
| 6 | +import org.junit.jupiter.api.Test; |
| 7 | +import org.mockito.Mock; |
| 8 | +import org.mockito.MockedConstruction.Context; |
| 9 | +import org.springframework.integration.aws.inbound.SnsInboundChannelAdapter; |
| 10 | +import software.amazon.awssdk.services.sns.SnsClient; |
| 11 | + |
| 12 | +import static org.assertj.core.api.Assertions.assertThat; |
| 13 | + |
| 14 | +@ConstructionMock(SnsInboundChannelAdapter.class) |
| 15 | +class SnsInboundChannelAdapterParserTest extends ParserTestBase { |
| 16 | + |
| 17 | + @Mock |
| 18 | + private SnsClient sns; |
| 19 | + |
| 20 | + @Test |
| 21 | + void testAdapter() { |
| 22 | + registerBean("sns", sns); |
| 23 | + |
| 24 | + parse(""" |
| 25 | + <int-aws:sns-inbound-channel-adapter |
| 26 | + id="sica" |
| 27 | + channel="c" |
| 28 | + sns="sns" |
| 29 | + path="/path/{uri},/path/*.do" |
| 30 | + error-channel="ec" |
| 31 | + handle-notification-status="#{true}" |
| 32 | + payload-expression="payload.exp" |
| 33 | + send-timeout="#{50}" |
| 34 | + /> |
| 35 | + """); |
| 36 | + |
| 37 | + var adapter = beanFactory.getBean(SnsInboundChannelAdapter.class); |
| 38 | + |
| 39 | + verify(adapter).setBeanName("sica"); |
| 40 | + verify(adapter).setErrorChannelName("ec"); |
| 41 | + verify(adapter).setHandleNotificationStatus(true); |
| 42 | + verify(adapter).setPayloadExpression(assertArg(e -> assertThat(e.getExpressionString()).isEqualTo("payload.exp"))); |
| 43 | + verify(adapter).setRequestTimeout(50L); |
| 44 | + } |
| 45 | + |
| 46 | + void testAdapter(SnsInboundChannelAdapter mock, Context context) { |
| 47 | + assertThat(context.arguments()).asInstanceOf(InstanceOfAssertFactories.LIST) |
| 48 | + .contains(sns, new String[] {"/path/{uri}", "/path/*.do"}); |
| 49 | + } |
| 50 | +} |
0 commit comments