### Question:
Topic { public void unsubscribe() { for (TopicCallback cb : this.callbacks) { this.ros.deregisterTopicCallback(this.name, cb); } this.callbacks.clear(); for (String id : this.ids) { JsonObject call = Json.createObjectBuilder() .add(JRosbridge.FIELD_OP, JRosbridge.OP_CODE_UNSUBSCRIBE) .add(JRosbridge.FIELD_ID, id) .add(JRosbridge.FIELD_TOPIC, this.name).build(); this.ros.send(call); } this.isSubscribed = false; } Topic(Ros ros, String name, String type);  Topic(Ros ros, String name, String type,
			JRosbridge.CompressionType compression);  Topic(Ros ros, String name, String type, int throttleRate);  Topic(Ros ros, String name, String type,
			JRosbridge.CompressionType compression, int throttleRate); Ros getRos(); String getName(); String getType(); boolean isAdvertised(); boolean isSubscribed(); JRosbridge.CompressionType getCompression(); int getThrottleRate(); void subscribe(TopicCallback cb); void unsubscribe(); void advertise(); void unadvertise(); void publish(Message message);  }### Answer:
@Test public void testUnsubscribe() { DummyTopicCallback cb = new DummyTopicCallback(); t1.subscribe(cb); assertFalse(t1.isAdvertised()); assertTrue(t1.isSubscribed()); assertNull(cb.latest); t1.unsubscribe(); ros.send(Json .createObjectBuilder() .add("echo", "{\"" + JRosbridge.FIELD_OP + "\":\"" + JRosbridge.OP_CODE_PUBLISH + "\",\"" + JRosbridge.FIELD_TOPIC + "\":\"myTopic1\",\"" + JRosbridge.FIELD_MESSAGE + "\":{\"test1\":\"test2\"}}").build()); Thread.yield(); assertNotNull(DummyHandler.latest); assertEquals( "{\"op\":\"subscribe\",\"id\":\"subscribe:myTopic1:0\",\"type\":\"myType1\"," + "\"topic\":\"myTopic1\",\"compression\":\"none\",\"throttle_rate\":0}", DummyHandler.latest.toString()); assertNull(cb.latest); assertFalse(t1.isAdvertised()); assertFalse(t1.isSubscribed()); }