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.messaging.Message;
16 import org.springframework.messaging.support.GenericMessage;
17 import org.springframework.test.annotation.DirtiesContext;
18 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
20 @RunWith(SpringJUnit4ClassRunner.class)
21 @SpringBootTest(classes = { Receiver.class })
23 public class ReceiverShould {
29 DummyService dummyService;
32 public void callSomeDummy() {
33 String productName = "product";
34 String productDescription = "productDescription";
35 Product product = new Product(productName, productDescription);
36 ArgumentCaptor<String> dummyArgCaptor = ArgumentCaptor.forClass(String.class);
37 doNothing().when(dummyService).iAmVeryDummy(dummyArgCaptor.capture());
39 Message<Product> message = new GenericMessage<>(product);
40 source.input().send(message);
42 assertThat(dummyArgCaptor.getValue(), is(product.getName()));