### Question:
SyncDecoder extends ActiveSyncDecoder { @VisibleForTesting Integer getWindowSize(Element root) { return uniqueIntegerFieldValue(root, SyncRequestFields.WINDOW_SIZE); } @Inject protected  SyncDecoder(DecoderFactory decoderFactory); SyncRequest decodeSync(Document doc); SyncResponse decodeSyncResponse(Document responseDocument);  }### Answer:
@Test public void testWindowSizeByDefault() throws Exception { Document request = DOMUtils.parse( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<Sync>" + "<Collections>" + "<Collection>" + "<SyncKey>ddcf2e35-9834-49de-96ff-09979c7e2aa0</SyncKey>" + "<CollectionId>2</CollectionId>" + "</Collection>" + "</Collections>" + "</Sync>"); Integer windowSize = new SyncDecoder(null).getWindowSize(request.getDocumentElement()); assertThat(windowSize).isNull(); }
@Test(expected=ASRequestIntegerFieldException.class) public void testWindowSizeWhenNotANumber() throws Exception { Document request = DOMUtils.parse( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<Sync>" + "<WindowSize>a1</WindowSize>" + "<Collections>" + "<Collection>" + "<SyncKey>ddcf2e35-9834-49de-96ff-09979c7e2aa0</SyncKey>" + "<CollectionId>2</CollectionId>" + "</Collection>" + "</Collections>" + "</Sync>"); Integer windowSize = new SyncDecoder(null).getWindowSize(request.getDocumentElement()); assertThat(windowSize).isNull(); }
@Test public void testWindowSize() throws Exception { Document request = DOMUtils.parse( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<Sync>" + "<WindowSize>150</WindowSize>" + "<Collections>" + "<Collection>" + "<SyncKey>ddcf2e35-9834-49de-96ff-09979c7e2aa0</SyncKey>" + "<CollectionId>2</CollectionId>" + "</Collection>" + "</Collections>" + "</Sync>"); Integer windowSize = new SyncDecoder(null).getWindowSize(request.getDocumentElement()); assertThat(windowSize).isEqualTo(150); }