### Question:
FolderSyncProtocol implements ActiveSyncProtocol<FolderSyncRequest, FolderSyncResponse> { @Override public FolderSyncResponse decodeResponse(Document doc) throws NoDocumentException { if (doc == null) { throw new NoDocumentException("Document of FolderSync response is null."); } Element fsr = doc.getDocumentElement(); String statusAsString = DOMUtils.getUniqueElement(fsr, "Status").getTextContent(); FolderSyncStatus status = FolderSyncStatus.fromSpecificationValue(statusAsString); if (!status.equals(FolderSyncStatus.OK)) { return FolderSyncResponse.builder() .hierarchyItemsChanges(HierarchyCollectionChanges.empty()) .status(status) .build(); } Element sk = DOMUtils.getUniqueElement(fsr, "SyncKey"); String newSyncKey = sk.getTextContent(); Element changes = DOMUtils.getUniqueElement(fsr, "Changes"); List<CollectionChange> collectionChanges = new LinkedList<CollectionChange>(); NodeList adds = changes.getElementsByTagName("Add"); for (int i = 0; i < adds.getLength(); i++) { Element add = (Element) adds.item(i); collectionChanges.add(createCollectionChange(add, true)); } NodeList updates = changes.getElementsByTagName("Update"); for (int i = 0; i < updates.getLength(); i++) { Element update = (Element) updates.item(i); collectionChanges.add(createCollectionChange(update, false)); } List<CollectionDeletion> collectionDeletions = new LinkedList<CollectionDeletion>(); NodeList deletes = changes.getElementsByTagName("Delete"); for (int i = 0; i < deletes.getLength(); i++) { Element delete = (Element) deletes.item(i); Element se = DOMUtils.getUniqueElement(delete, "ServerId"); String serverId = se.getTextContent(); collectionDeletions.add(CollectionDeletion.builder().collectionId(CollectionId.of(serverId)).build()); } HierarchyCollectionChanges hierarchyItemsChanges = HierarchyCollectionChanges.builder() .changes(collectionChanges) .deletions(collectionDeletions) .build(); return FolderSyncResponse.builder() .status(status) .newSyncKey(new FolderSyncKey(newSyncKey)) .hierarchyItemsChanges(hierarchyItemsChanges) .build(); }  @Override FolderSyncRequest decodeRequest(Document doc); Document encodeErrorResponse(FolderSyncStatus status); @Override FolderSyncResponse decodeResponse(Document doc); @Override Document encodeResponse(Device device, FolderSyncResponse folderSyncResponse); @Override Document encodeRequest(FolderSyncRequest folderSyncRequest);  }### Answer:
@Test public void testDecodeStatusOK() throws Exception { String initialDocument = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<FolderSync>" + "<Status>1</Status>" + "<SyncKey>2056e98e-be0e-4d1a-8f39-328614a32f3a</SyncKey>" + "<Changes>" + "<Count>0</Count>" + "</Changes>" + "</FolderSync>"; FolderSyncResponse folderSyncResponse = folderSyncProtocol.decodeResponse(DOMUtils.parse(initialDocument)); assertThat(folderSyncResponse.getStatus()).isEqualTo(FolderSyncStatus.OK); }
@Test public void testDecodeStatusInvalidSyncKey() throws Exception { String initialDocument = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<FolderSync>" + "<Status>9</Status>" + "<SyncKey>2056e98e-be0e-4d1a-8f39-328614a32f3a</SyncKey>" + "<Changes>" + "<Count>0</Count>" + "</Changes>" + "</FolderSync>"; FolderSyncResponse folderSyncResponse = folderSyncProtocol.decodeResponse(DOMUtils.parse(initialDocument)); assertThat(folderSyncResponse.getStatus()).isEqualTo(FolderSyncStatus.INVALID_SYNC_KEY); }