Directive extends NameValue { @Override public String toString() { String output = name; if (!value.isEmpty()) { output += "=" + value; } if (!parameters.isEmpty()) { output = output + "; " + parameters.stream().map(Parameter::toString).collect(Collectors.joining("; ")); } return output; } Directive(final String name, String value);  Directive(final String name, String value, List<Parameter> parameters); List<Parameter> getParameters(); int getValueAsInteger(); Parameter getParameter(String name); String getParameterValue(String name); @Override String toString();  }
@Test public void testSimpleDirective() { Directive dir = new Directive("foo", "bar"); assertEquals("foo=bar", dir.toString()); }
@Test public void testQuotedDirective() { QuotedDirective dir = new QuotedDirective("foo", "\"bar\""); assertEquals("foo=\"bar\"", dir.toString()); assertEquals("bar", dir.getValue()); }
@Test public void testDirectiveWithOneParameter() { Directive dir = new Directive("foo", "\"bar\"", Arrays.asList(new Parameter("one", "value"))); assertEquals("foo=bar; one=value", dir.toString()); }
@Test public void testDirectiveWithTwoParameters() { Directive dir = new Directive("foo", "bar", Arrays.asList(new Parameter("one", "value"), new Parameter("two", "value"))); assertEquals("foo=bar; one=value; two=value", dir.toString()); }