@Test public void changeCaseFileState() throws Exception { Long caseId = 500L; String newStatus = "NEW_STATUS"; String remoteAddress = "192.168.1.1"; String currentUser = "currentUser"; expect(mockAuthentication.getDetails()).andReturn(mockAuthDetails).atLeastOnce(); expect(mockAuthDetails.getRemoteAddress()).andReturn(remoteAddress); expect(mockAuthentication.getName()).andReturn(currentUser).atLeastOnce(); expect(mockChangeCaseFileStateService.changeCaseState(mockAuthentication, caseId, newStatus, remoteAddress)) .andReturn(new CaseFile()); replayAll(); unit.changeCaseFileState(caseId, newStatus); verifyAll(); }
public void changeCaseFileState(Long caseId, String newState) { Authentication currentUser = SecurityContextHolder.getContext().getAuthentication(); String userid = currentUser.getName(); String ipAddress = null; if (currentUser.getDetails() != null && AcmAuthenticationDetails.class.isAssignableFrom(currentUser.getDetails().getClass())) { ipAddress = ((AcmAuthenticationDetails) currentUser.getDetails()).getRemoteAddress(); } log.debug("User '" + userid + "' updated case '" + caseId + "' to status '" + newState + "'"); try { getChangeCaseFileStateService().changeCaseState(currentUser, caseId, newState, ipAddress); } catch (AcmUserActionFailedException e) { log.error("Could not update case status: " + e.getMessage(), e); } }
CaseFileStateService { public void changeCaseFileState(Long caseId, String newState) { Authentication currentUser = SecurityContextHolder.getContext().getAuthentication(); String userid = currentUser.getName(); String ipAddress = null; if (currentUser.getDetails() != null && AcmAuthenticationDetails.class.isAssignableFrom(currentUser.getDetails().getClass())) { ipAddress = ((AcmAuthenticationDetails) currentUser.getDetails()).getRemoteAddress(); } log.debug("User '" + userid + "' updated case '" + caseId + "' to status '" + newState + "'"); try { getChangeCaseFileStateService().changeCaseState(currentUser, caseId, newState, ipAddress); } catch (AcmUserActionFailedException e) { log.error("Could not update case status: " + e.getMessage(), e); } } }
CaseFileStateService { public void changeCaseFileState(Long caseId, String newState) { Authentication currentUser = SecurityContextHolder.getContext().getAuthentication(); String userid = currentUser.getName(); String ipAddress = null; if (currentUser.getDetails() != null && AcmAuthenticationDetails.class.isAssignableFrom(currentUser.getDetails().getClass())) { ipAddress = ((AcmAuthenticationDetails) currentUser.getDetails()).getRemoteAddress(); } log.debug("User '" + userid + "' updated case '" + caseId + "' to status '" + newState + "'"); try { getChangeCaseFileStateService().changeCaseState(currentUser, caseId, newState, ipAddress); } catch (AcmUserActionFailedException e) { log.error("Could not update case status: " + e.getMessage(), e); } }  }
CaseFileStateService { public void changeCaseFileState(Long caseId, String newState) { Authentication currentUser = SecurityContextHolder.getContext().getAuthentication(); String userid = currentUser.getName(); String ipAddress = null; if (currentUser.getDetails() != null && AcmAuthenticationDetails.class.isAssignableFrom(currentUser.getDetails().getClass())) { ipAddress = ((AcmAuthenticationDetails) currentUser.getDetails()).getRemoteAddress(); } log.debug("User '" + userid + "' updated case '" + caseId + "' to status '" + newState + "'"); try { getChangeCaseFileStateService().changeCaseState(currentUser, caseId, newState, ipAddress); } catch (AcmUserActionFailedException e) { log.error("Could not update case status: " + e.getMessage(), e); } }  void changeCaseFileState(Long caseId, String newState); ChangeCaseFileStateService getChangeCaseFileStateService(); void setChangeCaseFileStateService(ChangeCaseFileStateService changeCaseFileStateService); }
CaseFileStateService { public void changeCaseFileState(Long caseId, String newState) { Authentication currentUser = SecurityContextHolder.getContext().getAuthentication(); String userid = currentUser.getName(); String ipAddress = null; if (currentUser.getDetails() != null && AcmAuthenticationDetails.class.isAssignableFrom(currentUser.getDetails().getClass())) { ipAddress = ((AcmAuthenticationDetails) currentUser.getDetails()).getRemoteAddress(); } log.debug("User '" + userid + "' updated case '" + caseId + "' to status '" + newState + "'"); try { getChangeCaseFileStateService().changeCaseState(currentUser, caseId, newState, ipAddress); } catch (AcmUserActionFailedException e) { log.error("Could not update case status: " + e.getMessage(), e); } }  void changeCaseFileState(Long caseId, String newState); ChangeCaseFileStateService getChangeCaseFileStateService(); void setChangeCaseFileStateService(ChangeCaseFileStateService changeCaseFileStateService);  }