/** @see RadiologyObsFormController#updateReadingPhysician(Study) */ @Test @Verifies( value = "should not update reading physician for given study with reading physician", method = "updateReadingPhysician(Study)") public void updateReadingPhysician_shouldNotUpdateReadingPhysicianForGivenStudyWithReadingPhysician() throws Exception { User otherMockReadingPhysician = RadiologyTestData.getMockRadiologyReadingPhysician(); assertThat(mockReadingPhysician, is(not(otherMockReadingPhysician))); mockStudy.setReadingPhysician(mockReadingPhysician); when(Context.getAuthenticatedUser()).thenReturn(otherMockReadingPhysician); Method updateReadingPhysicianMethod = radiologyObsFormController .getClass() .getDeclaredMethod( "updateReadingPhysician", new Class[] {org.openmrs.module.radiology.Study.class}); updateReadingPhysicianMethod.setAccessible(true); assertThat(mockStudy.getReadingPhysician(), is(mockReadingPhysician)); updateReadingPhysicianMethod.invoke(radiologyObsFormController, new Object[] {mockStudy}); assertThat(mockStudy.getReadingPhysician(), is(mockReadingPhysician)); }
/** * Updates reading physician for given study * * @param study for which the reading physician should be updated * @should update reading physician for given study and user authenticated as reading physician * @should not update reading physician if user is not authenticated as reading physician * @should not update reading physician for given study with reading physician */ private void updateReadingPhysician(Study study) { User user = Context.getAuthenticatedUser(); if (user.hasRole(READING_PHYSICIAN, true) && study.getReadingPhysician() == null) study.setReadingPhysician(user); radiologyService.saveStudy(study); }