  @Test
  public void testHostFromConfig() {

    factory.setServicePort(8888);
    factory.setServiceAddress("127.0.0.1");

    when(agent.isRegistered(anyString())).thenReturn(false);
    final ConsulAdvertiser advertiser =
        new ConsulAdvertiser(environment, factory, consul, serviceId);
    advertiser.register("http", 8080, 8081);

    final ImmutableRegistration registration =
        ImmutableRegistration.builder()
            .id(serviceId)
            .port(8888)
            .address("127.0.0.1")
            .check(
                ImmutableRegCheck.builder()
                    .http("http://127.0.0.1:8081/admin/healthcheck")
                    .interval("1s")
                    .deregisterCriticalServiceAfter("1m")
                    .build())
            .name("test")
            .meta(ImmutableMap.of("scheme", "http"))
            .build();

    verify(agent).register(registration);
  }