### Question:
ParallelScanTask { public List<ScanResult> getNextBatchOfScanResults() { startScanNextPages(); synchronized (segmentScanStates) { while (segmentScanStates.contains(SegmentScanState.Waiting) || segmentScanStates.contains(SegmentScanState.Scanning)) { try { segmentScanStates.wait(); } catch (final InterruptedException ie) { throw new AmazonClientException("Parallel scan interrupted by other thread.", ie); } } return marshalParallelScanResults(); } } @Deprecated @SuppressWarnings("checkstyle:javadocmethod")  ParallelScanTask(DynamoDBMapper mapper, AmazonDynamoDB dynamo,
            List<ScanRequest> parallelScanRequests);   ParallelScanTask(AmazonDynamoDB dynamo, List<ScanRequest> parallelScanRequests); boolean isAllSegmentScanFinished(); List<ScanResult> getNextBatchOfScanResults();  }### Answer:
@Test public void testGetNextBatchOfScanResults() { EasyMock.reset(mockClient); ScanRequest scan1 = new ScanRequest().withTableName(TABLE).withConditionalOperator("OR"); ScanRequest scan2 = new ScanRequest().withTableName(TABLE); List<ScanRequest> list = new ArrayList<ScanRequest>(); list.add(scan1); list.add(scan2); Map<String, AttributeValue> lastEvaluatedKey = new HashMap<String, AttributeValue>(); lastEvaluatedKey.put("TestPrimaryKey", new AttributeValue().withS("Test1")); ScanResult resultWithMoreData = new ScanResult().withLastEvaluatedKey(lastEvaluatedKey); ScanResult result2NoMoreData = new ScanResult().withLastEvaluatedKey(null); ParallelScanTask testTask = new ParallelScanTask(mockClient, list); EasyMock.expect(mockClient.scan(scan1)).andReturn(resultWithMoreData); EasyMock.expect(mockClient.scan(scan2)).andReturn(result2NoMoreData); EasyMock.replay(mockClient); List<ScanResult> firstBatch = testTask.getNextBatchOfScanResults(); EasyMock.verify(mockClient); assertEquals(firstBatch.size(), 2); assertTrue(firstBatch.contains(resultWithMoreData)); assertTrue(firstBatch.contains(result2NoMoreData)); EasyMock.reset(mockClient); EasyMock.expect(mockClient.scan(scan1)).andReturn(result2NoMoreData); EasyMock.replay(mockClient); List<ScanResult> secondBatch = testTask.getNextBatchOfScanResults(); EasyMock.verify(mockClient); assertEquals(secondBatch.size(), 2); assertEquals(secondBatch.get(0), result2NoMoreData); assertNull(secondBatch.get(1)); }