HeaderTemplate extends Template { public static HeaderTemplate create(String name, Iterable<String> values) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException("name is required."); } if (values == null) { throw new IllegalArgumentException("values are required"); } StringBuilder template = new StringBuilder(); template.append(name) .append(" "); Iterator<String> iterator = values.iterator(); while (iterator.hasNext()) { template.append(iterator.next()); if (iterator.hasNext()) { template.append(","); } } return new HeaderTemplate(template.toString(), name, values, Util.UTF_8); } private  HeaderTemplate(String template, String name, Iterable<String> values, Charset charset); private  HeaderTemplate(String name, Charset charset, List<TemplateChunk> chunks); static HeaderTemplate from(String name, List<TemplateChunk> chunks); static HeaderTemplate create(String name, Iterable<String> values); static HeaderTemplate append(HeaderTemplate headerTemplate, Iterable<String> values); static HeaderTemplate appendFrom(HeaderTemplate headerTemplate,
                                          List<TemplateChunk> chunks); Collection<String> getValues(); String getName(); @Override String expand(Map<String, ?> variables);  }
@Test(expected = IllegalArgumentException.class) public void it_should_throw_exception_when_name_is_null() { HeaderTemplate.create(null, Collections.singletonList("test")); exception.expectMessage("name is required."); }
@Test(expected = IllegalArgumentException.class) public void it_should_throw_exception_when_name_is_empty() { HeaderTemplate.create("", Collections.singletonList("test")); exception.expectMessage("name is required."); }
@Test(expected = IllegalArgumentException.class) public void it_should_throw_exception_when_value_is_null() { HeaderTemplate.create("test", null); exception.expectMessage("values are required"); }