### Question:
ContinuationServiceImpl implements ContinuationService { @Override public void suspend(UserDataRequest userDataRequest, IContinuation continuation, long secondsTimeout, String cancellingStatus) { logger.debug("suspend {} {} {} {}", userDataRequest.getUser(), userDataRequest.getDevice(), secondsTimeout, cancellingStatus); continuation.error(cancellingStatus); boolean hasPreviousElement = continuationTransactionMap.putContinuationForDevice(userDataRequest.getUser(), userDataRequest.getDevice(), continuation); if (hasPreviousElement) { logger.error("Continuation was already cached for device {} and user ", userDataRequest.getDevice(), userDataRequest.getUser()); } continuation.suspend(userDataRequest, secondsTimeout); } @SuppressWarnings({ "unchecked", "rawtypes" }) @Inject @VisibleForTesting  ContinuationServiceImpl(ContinuationTransactionMap continuationTransactionMap); @Override void suspend(UserDataRequest userDataRequest, IContinuation continuation, long secondsTimeout, String cancellingStatus); @Override void resume(User user, Device device); @Override void cancel(User user, Device device); @Override void running(User user, Device device);  }### Answer:
@Test public void testSuspend() { String error = "ERROR"; UserDataRequest userDataRequest = getFakeUserDataRequest(); IContinuation continuation = mockContinuation(); continuation.suspend(userDataRequest, 0); expectLastCall(); continuation.error(error); expectLastCall(); ContinuationTransactionMap<IContinuation> continuationTransactionMap = mockContinuationTransactionMap(); expect(continuationTransactionMap.putContinuationForDevice(user, device, continuation)).andReturn(false); control.replay(); continuationService(continuationTransactionMap).suspend(userDataRequest, continuation, 0, error); control.verify(); }
@Test public void testSuspendOnAlreadyCachedContinuation() { String error = "ERROR"; UserDataRequest userDataRequest = getFakeUserDataRequest(); IContinuation continuation = mockContinuation(); continuation.suspend(userDataRequest, 0); expectLastCall(); continuation.error(error); expectLastCall(); ContinuationTransactionMap<IContinuation> continuationTransactionMap = mockContinuationTransactionMap(); expect(continuationTransactionMap.putContinuationForDevice(user, device, continuation)).andReturn(true); control.replay(); continuationService(continuationTransactionMap).suspend(userDataRequest, continuation, 0, error); control.verify(); }