SyncVlerMessageHandler extends SecondarySiteSyncMessageHandler { @Override protected List<VistaDataChunk> fetchData(PatientIds patientIds, PatientDemographics pt) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("VistaPatientDataService.fetchVlerData: VLER is enabled - checking VLER for data now."); LOGGER.debug("VistaPatientDataService.fetchVlerData: pid: " + patientIds.getPid()); LOGGER.debug("VistaPatientDataService.fetchVlerData: patient.icn: " + patientIds.getIcn()); LOGGER.debug("VistaPatientDataService.fetchVlerData: patient.uid: " + patientIds.getUid()); } List<VistaDataChunk> vistaDataChunkList = vlerService.fetchVlerData(patientIds); if (vistaDataChunkList != null) { LOGGER.debug("VistaPatientDataService.fetchVlerData: Received " + vistaDataChunkList.size() + " chunks(items) from VLER."); } else { LOGGER.debug("VistaPatientDataService.fetchVlerData: Received NO chunks(items) from VLER."); } LOGGER.debug("VistaPatientDataService.fetchVlerData: VLER is enabled - done checking VLER for data."); return vistaDataChunkList; }  @Autowired void setVlerService(IVlerService vlerService); @Override void onMessage(Message message, Session session); final static String SITE_ID; static final String TIMER_NAME; }
@Test public void testFetchVlerData() { PatientIds patientIds = getPatientIds(); VistaDataChunk dataChunk = new VistaDataChunk(); dataChunk.setContent("test.content"); List<VistaDataChunk> vistaDataChunkList = Arrays.asList(dataChunk); when(mockVlerService.fetchVlerData((PatientIds) anyObject())).thenReturn(vistaDataChunkList); PatientDemographics pt = new PatientDemographics(); List<VistaDataChunk> resp = handler.fetchData(patientIds, pt); assertNotNull(resp); assertEquals(resp.size(), 1); assertEquals(resp.get(0).getContent(), dataChunk.getContent()); when(mockVlerService.fetchVlerData((PatientIds) anyObject())).thenReturn(null); List<VistaDataChunk> resp2 = handler.fetchData(patientIds, pt); assertNull(resp2); }