package io.xn.dx.server;

import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.ImmutableMap;
import io.airlift.units.Duration;
import io.xn.dx.reps.Service;
import io.xn.dx.reps.Status;
import io.xn.dx.reps.Version;
import io.xn.dx.vendor.DxServerRule;
import org.junit.Rule;
import org.junit.Test;

import java.net.URI;
import java.util.Optional;

import static io.xn.dx.assertions.JsonNodeAssert.assertThat;

public class HeartbeatResourceTest
{
    @Rule
    public DxServerRule app = new DxServerRule();

    @Test
    public void testUpdateTtl() throws Exception
    {
        Service one = app.createService(URI.create("http://foo"),
                                        "foo",
                                        Version.valueOf("1.2.3"),
                                        "blue",
                                        Duration.valueOf("100ms"));

        URI status_uri = one.getLinks().get("heartbeat").getHref();
        JsonNode node = app.POST(status_uri, ImmutableMap.of("ttl", "200ms"));
        assertThat(node.at("/ttl")).isTextual();
    }

}

@@ -595,16 +595,18 @@
 n%0A    %7B%0A
+//
         
@@ -659,24 +659,26 @@
 tp://foo%22),%0A
+//
             
@@ -712,16 +712,18 @@
  %22foo%22,%0A
+//
         
@@ -780,16 +780,18 @@
 .2.3%22),%0A
+//
         
@@ -830,16 +830,18 @@
 %22blue%22,%0A
+//
         
@@ -900,17 +900,21 @@
 0ms%22));%0A
-%0A
+//%0A//
         
@@ -969,24 +969,26 @@
 .getHref();%0A
+//
         Json
@@ -1054,16 +1054,18 @@
 0ms%22));%0A
+//
         

make tests pass