### Question:
SyncDecoder extends ActiveSyncDecoder { public SyncResponse decodeSyncResponse(Document responseDocument) { Element root = responseDocument.getDocumentElement(); SyncResponse.Builder builder = SyncResponse.builder() .status(getCollectionStatus(root)); NodeList collectionNodes = root.getElementsByTagName(SyncRequestFields.COLLECTION.getName()); for (int i = 0; i < collectionNodes.getLength(); i++) { builder.addResponse(buildCollectionResponse((Element)collectionNodes.item(i))); } return builder.build(); } @Inject protected  SyncDecoder(DecoderFactory decoderFactory); SyncRequest decodeSync(Document doc); SyncResponse decodeSyncResponse(Document responseDocument);  }### Answer:
@Test public void testResponseCollectionWhenNoClass() throws Exception { Document request = DOMUtils.parse( "<Sync>" + "<Collections>" + "<Collection>" + "<SyncKey>ddcf2e35-9834-49de-96ff-09979c7e2aa0</SyncKey>" + "<CollectionId>2</CollectionId>" + "<WindowSize>150</WindowSize>" + "</Collection>" + "</Collections>" + "</Sync>"); SyncResponse response = new SyncDecoder(null).decodeSyncResponse(request); SyncCollectionResponse collectionResponse = Iterables.getOnlyElement(response.getCollectionResponses()); assertThat(collectionResponse.getDataType()).isNull(); }
@Test public void testResponseCollectionWhenUnkonwClass() throws Exception { Document request = DOMUtils.parse( "<Sync>" + "<Collections>" + "<Collection>" + "<Class>Music</Class>" + "<SyncKey>ddcf2e35-9834-49de-96ff-09979c7e2aa0</SyncKey>" + "<CollectionId>2</CollectionId>" + "<WindowSize>150</WindowSize>" + "</Collection>" + "</Collections>" + "</Sync>"); SyncResponse response = new SyncDecoder(null).decodeSyncResponse(request); SyncCollectionResponse collectionResponse = Iterables.getOnlyElement(response.getCollectionResponses()); assertThat(collectionResponse.getDataType()).isEqualTo(PIMDataType.UNKNOWN); }
@Test public void testResponseCollectionWhenEmailClass() throws Exception { Document request = DOMUtils.parse( "<Sync>" + "<Collections>" + "<Collection>" + "<Class>Email</Class>" + "<SyncKey>ddcf2e35-9834-49de-96ff-09979c7e2aa0</SyncKey>" + "<CollectionId>2</CollectionId>" + "<WindowSize>150</WindowSize>" + "</Collection>" + "</Collections>" + "</Sync>"); SyncResponse response = new SyncDecoder(null).decodeSyncResponse(request); SyncCollectionResponse collectionResponse = Iterables.getOnlyElement(response.getCollectionResponses()); assertThat(collectionResponse.getDataType()).isEqualTo(PIMDataType.EMAIL); }