@Test public void shouldReceiveMessages() { String body = "A message"; when(sqsClient.receiveMessage(any(ReceiveMessageRequest.class)).getMessages()) .thenReturn(Arrays.asList(new Message().withBody(body))); List<String> messages = provider.receive(); assertThat(messages.size(), is(1)); assertThat(messages, hasItem(body)); }
@Test public void shouldSendMessage() { String message = "A message"; provider.send(message); ArgumentCaptor<SendMessageRequest> argument = ArgumentCaptor.forClass(SendMessageRequest.class); verify(sqsClient, times(1)).sendMessage(argument.capture()); SendMessageRequest request = argument.getValue(); assertThat(request.getMessageBody(), equalTo(message)); }