@Test public void testSetTeamContext() throws Exception { String teamUid = "urn:va:foo:bar:baz"; ModelAndView mav = controller.set("team", teamUid, mockRequest); verify(mockTeamContext).setCurrentTeamUid(teamUid); assertThat(mav.getViewName(), is(ContentNegotiatingViewResolver.DEFAULT_VIEW_NAME)); }
@Test public void testSetMultipleContexts() throws Exception { String rosterUid = "urn:va:roster:foo"; String boardUid = "urn:va:board:foo"; String teamUid = "urn:va:team:foo"; String encounterUid = "urn:va:encounter:foo"; ModelAndView mav = controller.set(rosterUid, boardUid, teamUid, encounterUid, mockRequest); verify(mockRosterContext).setCurrentRosterUid(rosterUid); verify(mockBoardContext).setCurrentBoardUid(boardUid); verify(mockTeamContext).setCurrentTeamUid(teamUid); verify(mockEncounterContext).setCurrentEncounterUid(encounterUid); assertThat(mav.getViewName(), is(ContentNegotiatingViewResolver.DEFAULT_VIEW_NAME)); }
@Test public void testSetPatientContext() throws Exception { String pid = "ABCD;1234"; PatientSelect mockPatientSelect = new PatientSelect(Collections.<String, Object>singletonMap("pid", pid)); when(mockPatientSelectDAO.findOneByPid(pid)).thenReturn(mockPatientSelect); PatientDemographics mockPatientDemographics = new PatientDemographics(Collections.<String, Object>singletonMap("pid", pid)); when(mockPatientContext.getCurrentPatient()).thenReturn(mockPatientDemographics); ModelAndView mav = controller.set(pid, mockRequest); verify(mockPatientContext).setCurrentPatientPid(pid); assertThat(mav.getViewName(), is(ContentNegotiatingViewResolver.DEFAULT_VIEW_NAME)); // TODO: test all extra patient context stuff included in model? }
@Before public void setUp() throws Exception { mockRequest = new MockHttpServletRequest(); mockPatientSelectDAO = mock(IPatientSelectDAO.class); mockPatientContext = mock(PatientContext.class); mockBoardContext = mock(BoardContext.class); mockRosterContext = mock(RosterContext.class); mockTeamContext = mock(TeamContext.class); mockEncounterContext = mock(EncounterContext.class); controller = new ContextManagementController(); controller.setPatientContext(mockPatientContext); controller.setPatientSelectDAO(mockPatientSelectDAO); controller.setBoardContext(mockBoardContext); controller.setRosterContext(mockRosterContext); controller.setTeamContext(mockTeamContext); controller.setEncounterContext(mockEncounterContext); }