RepositoryImpl extends AbstractC32DaoAware implements Repository { @Override public C32Document getDocument(Date docDate, String patientId) { List<C32DocumentEntity> docList = getAllStoredDocuments(patientId); docList = getCompletedDocuments(docList); C32DocumentEntity doc = getDocumentByDate(docDate, docList); if (doc==null) { throw new RuntimeException("document for date:" + docDate + " & id:" + patientId + " does not exist"); } return getC32Doc(doc); }  MessageSendable getMessageSender(); void setMessageSender(MessageSendable messageSender); @Override List<DocStatus> getStatus(String patientId, String patientName); @Override C32Document getDocument(Date docDate, String patientId);  }
@Test public void getDocument_errors() { try { repo.getDocument(new Date(), "12321"); Assert.fail("exception not thrown"); } catch (RuntimeException ex) { Assert.assertTrue(ex.getMessage().startsWith("document for date:")); } }
@Test public void getDocument_oneOfOne() { String xml = "<hiThere></hiThere>"; docsRetrieved = new ArrayList<C32DocumentEntity>(); docsRetrieved.add(new C32DocumentEntity("12321", "12321", getNowTimestamp(), xml)); C32Document doc = repo.getDocument(new Date(), "12321"); Assert.assertNotNull(doc); Assert.assertEquals("12321", doc.getPatientId()); Assert.assertEquals(xml, new String(Base64.decodeBase64(doc.getDocument()))); }
@Test public void getDocument_oneOfSeveralErrors() { String ptId = "333"; Date aDate = new Date(); String docString = "<hi></hi>"; java.sql.Timestamp time = getTimestamp(aDate); setupMultipleEntriesOneDate(ptId, time, docString); C32Document doc = repo.getDocument(aDate, ptId); Assert.assertNotNull(doc); Assert.assertEquals(ptId, doc.getPatientId()); Assert.assertEquals(docString, new String(Base64.decodeBase64(doc.getDocument()))); }