### Question:
TelemetryEvent { public String getTopicSubpath() { return mTopicSubpath; } TelemetryEvent(@NonNull byte[] data, @Nullable String topicSubpath, @Qos int qos); byte[] getData(); String getTopicSubpath(); @Qos int getQos(); static final int QOS_AT_MOST_ONCE; static final int QOS_AT_LEAST_ONCE; }### Answer:
@Test public void testNullTopicSubpath() { TelemetryEvent event = new TelemetryEvent(new byte[1], null, TelemetryEvent.QOS_AT_MOST_ONCE); assertThat(event.getTopicSubpath()).isEmpty(); }
@Test public void testNonNullTopicSubpathWithLeadingSlash() { String subpath = "/a/b/c"; TelemetryEvent event = new TelemetryEvent(new byte[1], subpath, TelemetryEvent.QOS_AT_MOST_ONCE); assertThat(event.getTopicSubpath()).isEqualTo(subpath); }
@Test public void testNonNullTopicSubpathWithNoLeadingSlash() { String subpath = "a/b/c"; TelemetryEvent event = new TelemetryEvent(new byte[1], subpath, TelemetryEvent.QOS_AT_MOST_ONCE); assertThat(event.getTopicSubpath()).isEqualTo("/" + subpath); }