### Question:
UriSpec implements Iterable<UriSpec.Part> { public String build() { return build(null, Maps.<String, Object>newHashMap()); } UriSpec();  UriSpec(String rawSpec); String build(); String build(ServiceInstance<?> serviceInstance); String build(Map<String, Object> variables); String build(ServiceInstance<?> serviceInstance, Map<String, Object> variables); @Override Iterator<Part> iterator(); List<Part> getParts(); void add(Part part); void remove(Part part); @SuppressWarnings("RedundantIfStatement") @Override boolean equals(Object o); @Override int hashCode(); static final String FIELD_SCHEME; static final String FIELD_NAME; static final String FIELD_ID; static final String FIELD_ADDRESS; static final String FIELD_PORT; static final String FIELD_SSL_PORT; static final String FIELD_REGISTRATION_TIME_UTC; static final String FIELD_SERVICE_TYPE; static final String FIELD_OPEN_BRACE; static final String FIELD_CLOSE_BRACE; }### Answer:
@Test public void testScheme() { UriSpec spec = new UriSpec("{scheme}: ServiceInstanceBuilder<Void> builder = new ServiceInstanceBuilder<Void>(); builder.id("x"); builder.name("foo"); builder.port(5); ServiceInstance<Void> instance = builder.build(); Assert.assertEquals(spec.build(instance), "http: builder.sslPort(5); instance = builder.build(); Assert.assertEquals(spec.build(instance), "https: }
@Test public void testFromInstance() { ServiceInstanceBuilder<Void> builder = new ServiceInstanceBuilder<Void>(); builder.address("1.2.3.4"); builder.name("foo"); builder.id("bar"); builder.port(5); builder.sslPort(6); builder.registrationTimeUTC(789); builder.serviceType(ServiceType.PERMANENT); ServiceInstance<Void> instance = builder.build(); UriSpec spec = new UriSpec("{scheme}: Map<String, Object> m = Maps.newHashMap(); m.put("scheme", "test"); Assert.assertEquals(spec.build(instance, m), "test: }