CommandSubscription { public static CommandSubscription fromTopic(final String topic, final Device authenticatedDevice) { try { return new CommandSubscription(topic, authenticatedDevice); } catch (final IllegalArgumentException e) { LOG.debug(e.getMessage()); return null; } } private  CommandSubscription(final String topic, final Device authenticatedDevice); private  CommandSubscription(final String topic, final Device authenticatedDevice, final MqttQoS qos, final String clientId); String getTenant(); String getDeviceId(); String getAuthenticatedDeviceId(); String getEndpoint(); MqttQoS getQos(); String getClientId(); String getTopic(); String getRequestPart(); boolean isAuthenticated(); boolean isGatewaySubscriptionForSpecificDevice(); static CommandSubscription fromTopic(final String topic, final Device authenticatedDevice); static CommandSubscription fromTopic(final MqttTopicSubscription mqttTopicSub, final Device authenticatedDevice, final String clientId);  }
@Test public void testSubscriptionAuthShort() { final CommandSubscription subscription = CommandSubscription.fromTopic("c/tenant/device/q/#", device); assertThat(subscription).isNotNull(); }
@Test public void testSubscriptionAuthDeviceDifferent() { final CommandSubscription subscription = CommandSubscription.fromTopic(getCommandEndpoint() + "/tenantA/deviceB/req/#", device); assertThat(subscription).isNull(); }
@Test public void testSubscriptionUnauthWithPattern() { final CommandSubscription subscription = CommandSubscription.fromTopic(getCommandEndpoint() + "/+/+/req/#", null); assertThat(subscription).isNull(); }
@Test public void testSubscriptionEndpoint() { final CommandSubscription subscription = CommandSubscription.fromTopic("cx/tenant/device/q/#", null); assertThat(subscription).isNull(); }
@Test public void testSubscriptionReq() { final CommandSubscription subscription = CommandSubscription.fromTopic("c/tenant/device/qx/#", null); assertThat(subscription).isNull(); }
@Test public void testSubscriptionEnd() { final CommandSubscription subscription = CommandSubscription.fromTopic("c/tenant/device/q/a", null); assertThat(subscription).isNull(); }
@Test public void testSubscriptionParts() { final CommandSubscription subscription = CommandSubscription.fromTopic("c/tenant/device/q/#/x", null); assertThat(subscription).isNull(); final CommandSubscription subscription2 = CommandSubscription.fromTopic("c/tenant/device/q", null); assertThat(subscription2).isNull(); }