### Question:
ContentPreferencesUtils { public static ContentPreferences fromPreferenceHeader(String header) { checkNotNull("Preference header cannot be null"); String[] preferenceParts = header.split(";"); validatePrefix(header, preferenceParts[0]); ContentPreferencesBuilder builder = ContentPreferences.builder(); if(preferenceParts.length==1) { throw new InvalidPreferenceHeaderException("Could not parse preference ("+header+"): invalid return representation preference configuration"); } populatePreferences(builder,Arrays.copyOfRange(preferenceParts,1,preferenceParts.length,String[].class)); return builder.build(); } private  ContentPreferencesUtils(); static ContentPreferences fromPreferenceHeader(String header); static String asPreferenceHeader(ContentPreferences contentPreferences); static String asPreferenceAppliedHeader(ContentPreferences contentPreferences); static final String PREFERENCE_APPLIED_HEADER; static final String PREFER_HEADER; }### Answer:
@Test public void testFromPreferenceHeader$validValues() throws Exception { assertThat(ContentPreferencesUtils.fromPreferenceHeader(MIXED_PREFERENCES_INCLUDE_OMIT),equalTo(COMPOSITE_PREFERENCES)); assertThat(ContentPreferencesUtils.fromPreferenceHeader(MIXED_PREFERENCES_OMIT_INCLUDE),equalTo(COMPOSITE_PREFERENCES)); assertThat(ContentPreferencesUtils.fromPreferenceHeader(SINGLE_INCLUDE_PREFERENCE),equalTo(SINGLE_INCLUDE)); assertThat(ContentPreferencesUtils.fromPreferenceHeader(MULTIPLE_INCLUDE_PREFERENCE),equalTo(MULTIPLE_INCLUDES)); assertThat(ContentPreferencesUtils.fromPreferenceHeader(MULTIPLE_OMIT_PREFERENCES),equalTo(MULTIPLE_OMITS)); }
@Test(expected=InvalidPreferenceHeaderException.class) public void testFromPreferenceHeader$invalidValues$no_parameter() throws Exception { ContentPreferencesUtils.fromPreferenceHeader("return=representation"); }
@Test(expected=InvalidPreferenceHeaderException.class) public void testFromPreferenceHeader$invalidValues$wrong_parameter() throws Exception { ContentPreferencesUtils.fromPreferenceHeader("return=representation; invalidParameter"); }
@Test(expected=InvalidPreferenceHeaderException.class) public void testFromPreferenceHeader$invalidValues$more_than_two_parameters() throws Exception { ContentPreferencesUtils.fromPreferenceHeader("return=representation; invalidParameter; another; third"); }
@Test(expected=InvalidPreferenceHeaderException.class) public void testFromPreferenceHeader$invalidValues$repeated_include_hints() throws Exception { ContentPreferencesUtils.fromPreferenceHeader("return=representation; include=\"http: }
@Test(expected=InvalidPreferenceHeaderException.class) public void testFromPreferenceHeader$invalidValues$repeated_omit_hints() throws Exception { ContentPreferencesUtils.fromPreferenceHeader("return=representation; omit=\"http: }
@Test(expected=InvalidPreferenceHeaderException.class) public void testFromPreferenceHeader$invalidValues$repeated_unknown_hint_preference$1() throws Exception { ContentPreferencesUtils.fromPreferenceHeader("return=representation; omit=\"http: }
@Test(expected=InvalidPreferenceHeaderException.class) public void testFromPreferenceHeader$invalidValues$repeated_unknown_hint_preference$2() throws Exception { ContentPreferencesUtils.fromPreferenceHeader("return=representation; omit=\"http: }