@Test public void should_not_process_any_order_when_shop_state_is_CLOSED() { Map<String, Object> buyOrderMsg = createBuyOrderMsg(ProductType.margaux, 1L); when(shopService.isShopOpen()).thenReturn(ofNullable(FALSE)); barAppListener.receiveOrder(buyOrderMsg); Mockito.verify(shopService, times(0)).processBuyOrder(any(Map.class)); }
@RabbitListener(queues = {BarApp.XEBICON_BARAPP_LISTENER}) public void receiveOrder(Map<String, Object> msg) { logger.debug("Receiving message [{}]", msg); if (shopService.isShopOpen().orElse(false) && ofNullable(msg.get("type")).orElse("").equals("BUY")) { shopService.processBuyOrder((Map) msg.get("payload")); } if (ofNullable(msg.get("type")).orElse("").equals("KEYNOTE_STATE")) { Optional<String> payloadValue = ofNullable((Map<String, String>) msg.get("payload")).map(payload -> payload.get("value")); if (payloadValue.orElse("").equals("AVAILABILITY_START")) { shopService.openShop(); } else if (payloadValue.orElse("").equals("AVAILABILITY_END")) { shopService.closeShop(); } } }
BarAppListener { @RabbitListener(queues = {BarApp.XEBICON_BARAPP_LISTENER}) public void receiveOrder(Map<String, Object> msg) { logger.debug("Receiving message [{}]", msg); if (shopService.isShopOpen().orElse(false) && ofNullable(msg.get("type")).orElse("").equals("BUY")) { shopService.processBuyOrder((Map) msg.get("payload")); } if (ofNullable(msg.get("type")).orElse("").equals("KEYNOTE_STATE")) { Optional<String> payloadValue = ofNullable((Map<String, String>) msg.get("payload")).map(payload -> payload.get("value")); if (payloadValue.orElse("").equals("AVAILABILITY_START")) { shopService.openShop(); } else if (payloadValue.orElse("").equals("AVAILABILITY_END")) { shopService.closeShop(); } } } }
BarAppListener { @RabbitListener(queues = {BarApp.XEBICON_BARAPP_LISTENER}) public void receiveOrder(Map<String, Object> msg) { logger.debug("Receiving message [{}]", msg); if (shopService.isShopOpen().orElse(false) && ofNullable(msg.get("type")).orElse("").equals("BUY")) { shopService.processBuyOrder((Map) msg.get("payload")); } if (ofNullable(msg.get("type")).orElse("").equals("KEYNOTE_STATE")) { Optional<String> payloadValue = ofNullable((Map<String, String>) msg.get("payload")).map(payload -> payload.get("value")); if (payloadValue.orElse("").equals("AVAILABILITY_START")) { shopService.openShop(); } else if (payloadValue.orElse("").equals("AVAILABILITY_END")) { shopService.closeShop(); } } }  }
BarAppListener { @RabbitListener(queues = {BarApp.XEBICON_BARAPP_LISTENER}) public void receiveOrder(Map<String, Object> msg) { logger.debug("Receiving message [{}]", msg); if (shopService.isShopOpen().orElse(false) && ofNullable(msg.get("type")).orElse("").equals("BUY")) { shopService.processBuyOrder((Map) msg.get("payload")); } if (ofNullable(msg.get("type")).orElse("").equals("KEYNOTE_STATE")) { Optional<String> payloadValue = ofNullable((Map<String, String>) msg.get("payload")).map(payload -> payload.get("value")); if (payloadValue.orElse("").equals("AVAILABILITY_START")) { shopService.openShop(); } else if (payloadValue.orElse("").equals("AVAILABILITY_END")) { shopService.closeShop(); } } }  @RabbitListener(queues = {BarApp.XEBICON_BARAPP_LISTENER}) void receiveOrder(Map<String, Object> msg); }
BarAppListener { @RabbitListener(queues = {BarApp.XEBICON_BARAPP_LISTENER}) public void receiveOrder(Map<String, Object> msg) { logger.debug("Receiving message [{}]", msg); if (shopService.isShopOpen().orElse(false) && ofNullable(msg.get("type")).orElse("").equals("BUY")) { shopService.processBuyOrder((Map) msg.get("payload")); } if (ofNullable(msg.get("type")).orElse("").equals("KEYNOTE_STATE")) { Optional<String> payloadValue = ofNullable((Map<String, String>) msg.get("payload")).map(payload -> payload.get("value")); if (payloadValue.orElse("").equals("AVAILABILITY_START")) { shopService.openShop(); } else if (payloadValue.orElse("").equals("AVAILABILITY_END")) { shopService.closeShop(); } } }  @RabbitListener(queues = {BarApp.XEBICON_BARAPP_LISTENER}) void receiveOrder(Map<String, Object> msg);  }