KafkaModelReader implements ModelReader<KafkaRoad> { @Override public KafkaRoad read(JsonNode json) { return mapper.convertValue(json, KafkaRoad.class); }  @Override KafkaRoad read(JsonNode json);  }
@Test public void correct_decode_of_full_model() throws Exception { JsonNode json = mapper .readTree( "{\n" + " \"name\": \"test_topic6\",\n" + " \"topicName\": \"road.test_topic6\",\n" + " \"description\": \"test road\",\n" + " \"type\":\"COMPACT\",\n" + " \"status\": {\n" + " \"topicCreated\": true,\n" + " \"partitions\": 6,\n" + " \"replicationFactor\": 3,\n" + " \"message\": \"\"\n" + " },\n" + " \"messageStatus\": {\n" + " \"lastUpdated\": 124947,\n" + " \"numberOfMessages\": 30\n" + " },\n" + " \"deleted\": false\n" + "}"); KafkaRoad road = reader.read(json); assertThat( road, is( new KafkaRoad( "test_topic6", "road.test_topic6", RoadType.COMPACT, new TrafficControlStatus(true, 6, 3, ""), new MessageStatus(124947, 30), false))); }
@Test public void correct_decode_with_null_status() throws Exception { JsonNode json = mapper .readTree( "{\n" + " \"name\": \"test_topic6\",\n" + " \"topicName\": \"road.test_topic6\",\n" + " \"type\":\"COMPACT\",\n" + " \"status\": null,\n" + " \"messageStatus\": null,\n" + " \"deleted\": true\n" + "}"); KafkaRoad road = reader.read(json); assertThat(road, is(new KafkaRoad("test_topic6", "road.test_topic6", RoadType.COMPACT, null, null, true))); }