@Override
    public ServerNodeDto toDto() {
        return ServerNodeDto.Builder.builder()
                .setObjectId(this.getObjectId().toHexString())
                .setId(this.getNodeId())
                .setTransportAddress(this.getTransportAddress())
                .setLastSeen(this.getLastSeen())
                .setHostname(this.getHostname())
                .setLeader(this.isLeader())
                .build();
    }
@Test
    void serialize() throws Exception {
        final ZonedDateTime lastSeen = Instant.ofEpochSecond(1).atZone(ZoneOffset.UTC);
        final String nodeId = "2d4cff7a-b9c4-440c-9c62-89ba1fb06211";
        final String transportAddress = "http://127.0.0.1:9000/api/";
        final String hostname = "graylog.local";
        final Map<String, Object> fields = Maps.newHashMap();
        fields.put("last_seen", (int) lastSeen.toEpochSecond());
        fields.put("node_id", nodeId);
        fields.put("is_leader", true);
        fields.put("transport_address", transportAddress);
        fields.put("hostname", hostname);

        final String id = "61b9c2861448530c3e061283";
        final ServerNodeEntity node = new ServerNodeEntity(new ObjectId(id), fields);

        final JsonNode jsonNode = mapper.readTree(mapper.writeValueAsString(node));

        assertThat(jsonNode.size()).isEqualTo(8);

        assertThat(ZonedDateTime.parse(jsonNode.path("last_seen").asText())).isEqualTo(lastSeen);
        assertThat(jsonNode.path("node_id").asText()).isEqualTo(nodeId);
        assertThat(jsonNode.path("is_leader").asBoolean()).isEqualTo(true);
        assertThat(jsonNode.path("transport_address").asText()).isEqualTo(transportAddress);
        assertThat(jsonNode.path("hostname").asText()).isEqualTo(hostname);

        assertThat(jsonNode.path("id").asText()).isEqualTo(id);
        assertThat(jsonNode.path("is_master").asBoolean()).isEqualTo(true);
        assertThat(jsonNode.path("short_node_id").asText()).isEqualTo("2d4cff7a");

        assertThat(node.toDto()).isEqualTo(ServerNodeDto.Builder.builder()
                .setLastSeen(new DateTime(lastSeen.toEpochSecond() * 1000, DateTimeZone.UTC))
                .setId(nodeId)
                .setLeader(true)
                .setTransportAddress(transportAddress)
                .setHostname(hostname)
                .setObjectId(id)
                .build());
    }