@Test
  public void shouldNotSendAnyEventThroughGatewayIfPayloadParsingFails() throws Exception {
    event.setPayload(invalidEventPayload);

    subject.send(event, destinationUri, null, tenant);

    verify(httpGateway, never()).request(any(), any(), any(), any(), any(), any());
    verify(eventRepository, never()).saveIncoming(tenant, event);
  }
  @Test
  public void shouldSendAnEventThroughGatewayIfDestinationIsEnabled() throws Exception {
    subject.send(event, destinationUri, null, tenant);

    InOrder inOrder = Mockito.inOrder(eventRepository, httpGateway);

    inOrder
        .verify(httpGateway)
        .request(
            eq(HttpMethod.POST),
            eq(URI.create(destination.getServiceURI().replaceAll("\\@\\{.*}", "value"))),
            eq(MediaType.APPLICATION_JSON),
            argLambda(objectSupplier -> objectSupplier.get().equals(event.getPayload())),
            eq(destination.getServiceUsername()),
            eq(destination.getServicePassword()));
    //        inOrder.verify(eventRepository).saveIncoming(eq(tenant),eq(event));
  }
  @Before
  public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    EventPublisherRest.class.cast(subject).setEventRepository(eventRepository);

    tenant = tenantRepository.findByDomainName("konker");
    destination =
        destinationService.getByGUID(tenant, REGISTERED_AND_ACTIVE_DESTINATION_GUID).getResult();

    destinationUri =
        new RESTDestinationURIDealer() {}.toRestDestinationURI(
            tenant.getDomainName(), destination.getGuid());

    event =
        Event.builder()
            //                .channel(DEVICE_MQTT_CHANNEL)
            .payload(validEventPayload)
            .timestamp(Instant.now())
            .build();
  }