### Question:
FolderSyncProtocol implements ActiveSyncProtocol<FolderSyncRequest, FolderSyncResponse> { @Override public Document encodeResponse(Device device, FolderSyncResponse folderSyncResponse) throws FactoryConfigurationError { Document ret = DOMUtils.createDoc(null, "FolderSync"); Element root = ret.getDocumentElement(); DOMUtils.createElementAndText(root, "Status", folderSyncResponse.getStatus().asXmlValue()); Element sk = DOMUtils.createElement(root, "SyncKey"); sk.setTextContent(folderSyncResponse.getNewSyncKey().asString()); Element changes = DOMUtils.createElement(root, "Changes"); DOMUtils.createElementAndText(changes, "Count", String.valueOf(folderSyncResponse.getCount())); for (CollectionChange collectionChange: folderSyncResponse.getCollectionsAddedAndUpdated()) { Element addedOrUpdated; if (collectionChange.isNew()) { addedOrUpdated = DOMUtils.createElement(changes, "Add"); } else { addedOrUpdated = DOMUtils.createElement(changes, "Update"); } addCollectionChange(addedOrUpdated, collectionChange); } for (CollectionDeletion collectionDeleted: folderSyncResponse.getCollectionsDeleted()) { Element deleted = DOMUtils.createElement(changes, "Delete"); DOMUtils.createElementAndText(deleted, "ServerId", collectionDeleted.getCollectionId().asString()); } return ret; }  @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 testEncodeStatusOK() throws Exception { Document encodedDocument = folderSyncProtocol.encodeResponse(device, FolderSyncResponse.builder() .newSyncKey(new FolderSyncKey("1234")) .status(FolderSyncStatus.OK) .hierarchyItemsChanges(HierarchyCollectionChanges.builder().build()) .build()); assertThat(DOMUtils.serialize(encodedDocument)).isEqualTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<FolderSync>" + "<Status>1</Status>" + "<SyncKey>1234</SyncKey>" + "<Changes>" + "<Count>0</Count>" + "</Changes>" + "</FolderSync>"); }
@Test public void testEncodeStatusInvalidSyncKey() throws Exception { Document encodedDocument = folderSyncProtocol.encodeResponse(device, FolderSyncResponse.builder() .newSyncKey(new FolderSyncKey("1234")) .status(FolderSyncStatus.INVALID_SYNC_KEY) .hierarchyItemsChanges(HierarchyCollectionChanges.builder().build()) .build()); assertThat(DOMUtils.serialize(encodedDocument)).isEqualTo( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<FolderSync>" + "<Status>9</Status>" + "<SyncKey>1234</SyncKey>" + "<Changes>" + "<Count>0</Count>" + "</Changes>" + "</FolderSync>"); }