SubscriptionService implements MqttClientEventHandler { @Override public void onSubscribe(final MqttClientAdapter mqttClientAdapter, final Mqtt3SubAck subAck, final Throwable throwable) { final MessageMetadata messageMetadata = mqttClientAdapter.getMessageMetadata(); if (throwable == null) { LOG.info(String.format("Client subscribed for device:%s suback:%s", messageMetadata.getDeviceIdentification(), subAck.getType())); } else { LOG.info(String.format("Client subscription for device:%s failed", messageMetadata.getDeviceIdentification()), throwable); } } SubscriptionService(final MqttDeviceRepository mqttDeviceRepository,
            final MqttClientAdapterFactory mqttClientAdapterFactory,
            final OutboundOsgpCoreResponseMessageSender outboundOsgpCoreResponseMessageSender,
            @Value("#{new Integer('${mqtt.broker.defaultPort}')}") final int defaultPort,
            @Value("${mqtt.broker.defaultTopics}") final String defaultTopics,
            @Value("${mqtt.broker.defaultQos}") final String defaultQos); void subscribe(final MessageMetadata messageMetadata); @Override void onConnect(final MqttClientAdapter mqttClientAdapter, final Mqtt3ConnAck ack,
            final Throwable throwable); @Override void onSubscribe(final MqttClientAdapter mqttClientAdapter, final Mqtt3SubAck subAck,
            final Throwable throwable); @Override void onReceive(final MqttClientAdapter mqttClientAdapter, final byte[] payloadAsBytes);  }
@Test void onSubscribe() { final Mqtt3SubAck subAck = mock(Mqtt3SubAck.class); final Throwable throwable = null; this.instance.onSubscribe(this.mqttClientAdapter, subAck, throwable); verify(subAck).getType(); }
@Test void onSubscribeError() { final Mqtt3SubAck subAck = mock(Mqtt3SubAck.class); final Throwable throwable = mock(Throwable.class); this.instance.onSubscribe(this.mqttClientAdapter, subAck, throwable); verifyNoMoreInteractions(subAck); }