### Question:
RatesConsumer { @RabbitListener( bindings = @QueueBinding(value = @Queue, exchange = @Exchange( value = ICONATOR_ENTRY_EXCHANGE, type = ExchangeTypes.TOPIC, ignoreDeclarationExceptions = "true", durable = "true" ), key = RATES_EXCHANGE_REQUEST_ROUTING_KEY) ) public FetchRatesResponseMessage receiveMessage(FetchRatesRequestMessage messageObject) { CurrencyType from = ofNullable(messageObject) .map((m) -> m.getFrom()) .orElseThrow(() -> new AmqpRejectAndDontRequeueException("'from' attribute on FetchRatesRequestMessage message is null.")); List<CurrencyType> to = ofNullable(messageObject).map((m) -> m.getTo()).orElse(Arrays.asList()); Instant timestamp = ofNullable(messageObject) .map((m) -> m.getDesiredRateTimestamp()) .map((date) -> date.toInstant()) .orElseThrow(() -> new AmqpRejectAndDontRequeueException("'desiredRateTimestamp' attribute on " + "FetchRatesRequestMessage message is null or has a wrong format.")); List<ExchangeAggregateCurrencyRateDTO> listDTOs = to.stream().map((currency) -> { try { BigDecimal rate = ratesProviderService.getRate(currency, timestamp); return new ExchangeAggregateCurrencyRateDTO(Date.from(timestamp), currency, rate); } catch (RateNotFoundException e) { LOG.error("Rate could not be fetched for {}. Exception: {}", currency, e); } return null; }).filter((element) -> element != null).collect(Collectors.toList()); return new FetchRatesResponseMessage(from, listDTOs); }  @RabbitListener( bindings = @QueueBinding(value = @Queue, exchange = @Exchange( value = ICONATOR_ENTRY_EXCHANGE, type = ExchangeTypes.TOPIC, ignoreDeclarationExceptions = "true", durable = "true" ), key = RATES_EXCHANGE_REQUEST_ROUTING_KEY) ) FetchRatesResponseMessage receiveMessage(FetchRatesRequestMessage messageObject);  }### Answer:
@Test public void testReceiveMessage() throws RateNotFoundException, JsonProcessingException { Instant now = Instant.now(); FetchRatesRequestMessage requestMessage = new FetchRatesRequestMessage( Date.from(now), CurrencyType.USD, Arrays.asList(CurrencyType.ETH)); when(ratesProviderService.getRate(eq(CurrencyType.ETH), any())).thenReturn(new BigDecimal("1.1234567")); FetchRatesResponseMessage responseMessage = ratesConsumer.receiveMessage(requestMessage); assertNotNull(responseMessage); assertTrue(responseMessage.getFrom() == CurrencyType.USD); assertTrue(responseMessage.getExchangeAggregateRates() .stream().allMatch((element) -> element.getCurrencyType().equals(CurrencyType.ETH))); assertTrue(responseMessage.getExchangeAggregateRates() .stream().allMatch((element) -> element.getAggregateRateDate().equals(Date.from(now)))); assertTrue(responseMessage.getExchangeAggregateRates() .stream().allMatch((element) -> element.getAggregateExchangeRate().equals(new BigDecimal("1.1234567")))); }