@Before public void runBeforeAllTests() { mockPatient1 = RadiologyTestData.getMockPatient1(); mockOrders = new ArrayList<RadiologyOrder>(); mockOrders.add(RadiologyTestData.getMockRadiologyOrder1()); when((radiologyService.getRadiologyOrdersByPatient(mockPatient1))).thenReturn(mockOrders); invalidPatient = new Patient(); ArrayList<RadiologyOrder> emptyOrdersList = new ArrayList<RadiologyOrder>(); when((radiologyService.getRadiologyOrdersByPatient(invalidPatient))) .thenReturn(emptyOrdersList); }
/** @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)); }
@Before public void runBeforeAllTests() { mockPatient = RadiologyTestData.getMockPatient1(); mockStudy = RadiologyTestData.getMockStudy1PostSave(); mockRadiologyOrder = RadiologyTestData.getMockRadiologyOrder1(); mockRadiologyOrder.setStudy(mockStudy); mockRadiologyOrder.setPatient(mockPatient); mockRequest = new MockHttpServletRequest(); mockObs = RadiologyTestData.getMockObs(); mockObs.setPatient(mockPatient); mockObs.setOrder(mockRadiologyOrder); mockReadingPhysician = RadiologyTestData.getMockRadiologyReadingPhysician(); mockRadiologyScheduler = RadiologyTestData.getMockRadiologyScheduler(); obsErrors = mock(BindingResult.class); }