List of usage examples for java.io CharArrayReader read
public int read(java.nio.CharBuffer target) throws IOException
From source file:org.openmrs.module.radiology.web.controller.RadiologyObsFormControllerTest.java
/** * @see RadiologyObsFormController#populateModelAndView(RadiologyOrder,Obs) * @verifies populate the model and view for given obs with complex concept */// w ww . ja v a 2 s . c o m @Test public void populateModelAndView_shouldPopulateTheModelAndViewForGivenObsWithComplexConcept() throws Exception { //given ConceptComplex concept = new ConceptComplex(); ConceptDatatype cdt = new ConceptDatatype(); cdt.setHl7Abbreviation("ED"); concept.setDatatype(cdt); mockObs.setConcept(concept); mockObs.setComplexData(RadiologyTestData.getMockComplexDataForMockObsWithComplexConcept()); Field obsServiceField = RadiologyObsFormController.class.getDeclaredField("obsService"); obsServiceField.setAccessible(true); obsServiceField.set(radiologyObsFormController, obsService); when(obsService.getComplexObs(mockObs.getId(), WebConstants.HTML_VIEW)) .thenReturn(RadiologyTestData.getMockComplexObsAsHtmlViewForMockObs()); when(obsService.getComplexObs(mockObs.getId(), WebConstants.HYPERLINK_VIEW)) .thenReturn(RadiologyTestData.getMockComplexObsAsHyperlinkViewForMockObs()); Method populateModelAndViewMethod = radiologyObsFormController.getClass().getDeclaredMethod( "populateModelAndView", new Class[] { org.openmrs.module.radiology.RadiologyOrder.class, org.openmrs.Obs.class }); populateModelAndViewMethod.setAccessible(true); ModelAndView modelAndView = (ModelAndView) populateModelAndViewMethod.invoke(radiologyObsFormController, new Object[] { mockRadiologyOrder, mockObs }); assertThat(modelAndView.getModelMap(), hasKey("obs")); Obs obs = (Obs) modelAndView.getModelMap().get("obs"); assertThat(obs, is(mockObs)); assertThat(modelAndView.getModelMap(), hasKey("htmlView")); CharArrayReader htmlComplexData = (CharArrayReader) modelAndView.getModelMap().get("htmlView"); assertThat(htmlComplexData, is(notNullValue())); char[] htmlComplexDataCharArray = new char[47]; htmlComplexData.read(htmlComplexDataCharArray); assertThat(String.copyValueOf(htmlComplexDataCharArray), is("<img src='/openmrs/complexObsServlet?obsId=1'/>")); assertThat(modelAndView.getModelMap(), hasKey("hyperlinkView")); CharArrayReader hyperlinkViewComplexData = (CharArrayReader) modelAndView.getModelMap() .get("hyperlinkView"); assertThat(hyperlinkViewComplexData, is(notNullValue())); char[] hyperlinkViewComplexDataCharArray = new char[33]; hyperlinkViewComplexData.read(hyperlinkViewComplexDataCharArray); assertThat(String.copyValueOf(hyperlinkViewComplexDataCharArray), is("openmrs/complexObsServlet?obsId=1")); }