### Question:
RemoteOperations implements SessionOperations { public SessionInfo refresh(Session session, boolean reset) throws SessionException { SessionID sessionID = session.getID(); if (debug.messageEnabled()) { debug.message(MessageFormat.format( "Remote fetch SessionInfo for {0}\n" + "Reset: {1}", sessionID, reset)); } SessionRequest sreq = new SessionRequest(SessionRequest.GetSession, sessionID.toString(), reset); SessionResponse sres = requests.sendRequestWithRetry(session.getSessionServiceURL(), sreq, session); if (sres.getException() != null) { throw new SessionException(SessionBundle.rbName, INVALID_SESSION_STATE, null); } List<SessionInfo> infos = sres.getSessionInfo(); if (infos.size() != 1) { throw new SessionException(SessionBundle.rbName, UNEXPECTED_SESSION, null); } return infos.get(0); } @Inject  RemoteOperations(@Named(SessionConstants.SESSION_DEBUG) Debug debug, Requests requests); SessionInfo refresh(Session session, boolean reset); void logout(Session session); void destroy(Session requester, Session session); void setProperty(Session session, String name, String value);  }### Answer:
@Test public void shouldUseSessionIDInRefreshRequest() throws SessionException { SessionInfo mockSessionInfo = mock(SessionInfo.class); given(mockResponse.getSessionInfo()).willReturn(Arrays.asList(mockSessionInfo)); SessionInfo result = remoteOperations.refresh(mockSession, true); assertThat(result).isEqualTo(mockSessionInfo); }
@Test public void shouldThrowExceptionIfRequestContainedOne() throws SessionException { given(mockResponse.getException()).willReturn("Error"); try { remoteOperations.refresh(mockSession, true); } catch (SessionException e) { assertThat(e.getErrorCode()).isEqualTo(RemoteOperations.INVALID_SESSION_STATE); } }
@Test public void shouldFailIfRequestDoesNotContainOneInfo() throws SessionException { given(mockResponse.getSessionInfo()).willReturn(Arrays.asList( mock(SessionInfo.class), mock(SessionInfo.class))); try { remoteOperations.refresh(mockSession, true); } catch (SessionException e) { assertThat(e.getErrorCode()).isEqualTo(RemoteOperations.UNEXPECTED_SESSION); } }