### Question:
PermutationsIO { public static String serialize( final List<SelectionDescriptor> descriptors ) throws Exception { final Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); final Element permutationsNode = document.createElement( PERMUTATIONS ); document.appendChild( permutationsNode ); for ( final SelectionDescriptor descriptor : descriptors ) { final Element node = document.createElement( PERMUTATION_NODE ); node.setAttribute( PERMUTATION_NAME, descriptor.getPermutationName() ); permutationsNode.appendChild( node ); for ( final BindingProperty b : descriptor.getBindingProperties() ) { final Element variable = document.createElement( b.getName() ); variable.appendChild( document.createTextNode( b.getValue() ) ); node.appendChild( variable ); } } return transformDocumentToString( document ); } private  PermutationsIO(); static List<SelectionDescriptor> deserialize( final InputStream stream ); static String serialize( final List<SelectionDescriptor> descriptors ); static final String PERMUTATIONS_DESCRIPTOR_FILE_NAME; }### Answer:
@Test public void serialize() throws Exception { final String permutation1 = "C7D408F8EFA266A7F9A31209F8AA7446"; final String permutation2 = "C7D408F8EFA2AAAAAAAAAAAAAAAAAAAA"; final String permutation3 = "C7D408F8EFA2AAAAAABBBBBBBBBBBBBB"; final String key1 = "user.agent"; final String key2 = "screen.size"; final String key3 = "color.depth"; final String value11 = "ie8,ie9,safari,ie10,gecko1_8"; final String value12 = "biggo"; final String value13 = "much"; final String value21 = "ie8,ie9,safari,ie10"; final String value22 = "smallish"; final String value31 = "ie8,ie9,ie10,gecko1_8"; final ArrayList<SelectionDescriptor> input = new ArrayList<>(); final ArrayList<BindingProperty> input1 = new ArrayList<>(); input1.add( new BindingProperty( key1, value11 ) ); input1.add( new BindingProperty( key2, value12 ) ); input1.add( new BindingProperty( key3, value13 ) ); input.add( new SelectionDescriptor( permutation1, input1 ) ); final ArrayList<BindingProperty> input2 = new ArrayList<>(); input2.add( new BindingProperty( key1, value21 ) ); input2.add( new BindingProperty( key2, value22 ) ); input.add( new SelectionDescriptor( permutation2, input2 ) ); final ArrayList<BindingProperty> input3 = new ArrayList<>(); input3.add( new BindingProperty( key1, value31 ) ); input.add( new SelectionDescriptor( permutation3, input3 ) ); final String output = PermutationsIO.serialize( input ); final List<SelectionDescriptor> descriptors = PermutationsIO.deserialize( new ByteArrayInputStream( output.getBytes( "US-ASCII" ) ) ); assertEquals( descriptors.size(), 3 ); final List<BindingProperty> binding1 = ensureBinding( descriptors, permutation1 ); assertEquals( binding1.size(), 3 ); assertBinding( binding1, key1, value11 ); assertBinding( binding1, key2, value12 ); assertBinding( binding1, key3, value13 ); final List<BindingProperty> binding2 = ensureBinding( descriptors, permutation2 ); assertEquals( binding2.size(), 2 ); assertBinding( binding2, key1, value21 ); assertBinding( binding2, key2, value22 ); final List<BindingProperty> binding3 = ensureBinding( descriptors, permutation3 ); assertEquals( binding3.size(), 1 ); assertBinding( binding3, key1, value31 ); }