### Question:
PermutationsIO { public static List<SelectionDescriptor> deserialize( final InputStream stream ) throws Exception { final List<SelectionDescriptor> descriptors = new ArrayList<>(); final Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( stream ); final Element permutationsNode = document.getDocumentElement(); final String tagName = permutationsNode.getTagName(); if ( !PERMUTATIONS.equals( tagName ) ) { throw new Exception( "unexpected xml structure: Expected node : '" + PERMUTATIONS + "' got: '" + tagName + "'" ); } final NodeList permutationsChildren = permutationsNode.getChildNodes(); final int length = permutationsChildren.getLength(); for ( int i = 0; i < length; i++ ) { final Node node = permutationsChildren.item( i ); if ( node.getNodeType() != Node.ELEMENT_NODE ) { continue; } final Element permutationNode = (Element) node; handlePermutation( descriptors, permutationNode ); } return Collections.unmodifiableList( descriptors ); } 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 deserialize() throws Exception { final String permutationContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<permutations>\n" + " <permutation name=\"C7D408F8EFA266A7F9A31209F8AA7446\">\n" + " <user.agent>ie8,ie9,safari,ie10,gecko1_8</user.agent>\n" + " <screen.size>biggo</screen.size>\n" + " <color.depth>much</color.depth>\n" + " </permutation>\n" + " <permutation name=\"Other\">\n" + " <user.agent>ie8,ie9,safari,ie10,gecko1_8</user.agent>\n" + " </permutation>\n" + " <permutation name=\"Other2\">\n" + " <user.agent>ie8,ie9,safari,ie10,gecko1_8</user.agent>\n" + " <screen.size>biggo</screen.size>\n" + " </permutation>\n" + "</permutations>\n"; final List<SelectionDescriptor> descriptors = PermutationsIO.deserialize( new ByteArrayInputStream( permutationContent.getBytes( "US-ASCII" ) ) ); assertEquals( descriptors.size(), 3 ); final List<BindingProperty> binding1 = ensureBinding( descriptors, "C7D408F8EFA266A7F9A31209F8AA7446" ); assertEquals( binding1.size(), 3 ); assertBinding( binding1, "user.agent", "ie8,ie9,safari,ie10,gecko1_8" ); assertBinding( binding1, "screen.size", "biggo" ); assertBinding( binding1, "color.depth", "much" ); final List<BindingProperty> binding2 = ensureBinding( descriptors, "Other2" ); assertEquals( binding2.size(), 2 ); assertBinding( binding2, "user.agent", "ie8,ie9,safari,ie10,gecko1_8" ); assertBinding( binding2, "screen.size", "biggo" ); final List<BindingProperty> binding3 = ensureBinding( descriptors, "Other" ); assertEquals( binding3.size(), 1 ); assertBinding( binding3, "user.agent", "ie8,ie9,safari,ie10,gecko1_8" ); }