1 package de.example.spring.kafka;
3 import static org.hamcrest.CoreMatchers.is;
4 import static org.junit.Assert.assertThat;
5 import static org.mockito.Mockito.doNothing;
7 import javax.inject.Inject;
10 import org.junit.runner.RunWith;
11 import org.mockito.ArgumentCaptor;
12 import org.springframework.boot.test.context.SpringBootTest;
13 import org.springframework.boot.test.mock.mockito.MockBean;
14 import org.springframework.cloud.stream.messaging.Sink;
15 import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration;
16 import org.springframework.messaging.Message;
17 import org.springframework.messaging.support.GenericMessage;
18 import org.springframework.test.annotation.DirtiesContext;
19 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
21 @RunWith(SpringJUnit4ClassRunner.class)
22 @SpringBootTest(classes = { Receiver.class, TestSupportBinderAutoConfiguration.class })
24 public class ReceiverIntegrationTest {
30 DummyService dummyService;
33 public void callSomeDummy() {
34 String productName = "product";
35 String productDescription = "productDescription";
36 Product product = new Product(productName, productDescription);
37 ArgumentCaptor<String> dummyArgCaptor = ArgumentCaptor.forClass(String.class);
38 doNothing().when(dummyService).iAmVeryDummy(dummyArgCaptor.capture());
40 Message<Product> message = new GenericMessage<>(product);
41 source.input().send(message);
43 assertThat(dummyArgCaptor.getValue(), is(product.getName()));