### Question:
Weighted { static Weighted<String> fromString(String candidate) { return fromString(candidate,new StringParser()); } private  Weighted(final Double weight, final T content); @Override String toString();  }### Answer:
@Test public void qualityParameterCannotHaveWhitespacesBeforeEqual() { try { Weighted.fromString("value;q \t=1.000"); fail("Should fail when whitespaces before equal"); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(),startsWith("Quality definition failure found: whitespace before equal")); } }
@Test public void qualityParameterCannotHaveWhitespacesAfterEqual() { try { Weighted.fromString("value;q=\t 1.000"); fail("Should fail when whitespaces after equal"); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(),startsWith("Quality definition failure found: whitespace after equal")); } }
@Test public void qualityParameterValuesCannotHaveMoreThanThreeDigits() { try { Weighted.fromString("value;q=1.0000"); fail("Should fail when quality parameter value has more than three digits"); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(),startsWith("Quality definition failure found: invalid weight value '1.0000'")); } }
@Test public void qualityParameterValuesRequireDotSeparator() { try { Weighted.fromString("value;q=1"); fail("Should fail when no dot separator is present"); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(),startsWith("Quality definition failure found: invalid weight value '1'")); } }
@Test public void qualityParameterValuesCannotBeGreaterThanOne() { try { Weighted.fromString("value;q=2.0"); fail("Should fail when quality value is greater than 1"); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(),startsWith("Quality definition failure found: invalid weight value '2.0'")); } }
@Test public void qualityParameterValuesCannotBeEmpty() { try { Weighted.fromString("value;q="); fail("Should fail when quality parameter value is empty"); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(),startsWith("Quality definition failure found: weight cannot be empty")); } }
@Test public void multipleQualityParametersAreNotAllowed() { try { Weighted.fromString("value;q=1.000;q=0.000"); fail("Should fail when multiple quality parameters are defined"); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(),startsWith("Only one quality value can be specified (found 2: ")); } }