RepositoryImpl extends AbstractC32DaoAware implements Repository { @Override public List<DocStatus> getStatus(String patientId, String patientName) { List<C32DocumentEntity> docList = getAllStoredDocuments(patientId); Date today = new Date(); if (getDocumentByDate(today, docList)==null) { saveIncompleteDocument(today, patientId); sendMessageToRetrieve(today, patientId, patientName); docList = getAllStoredDocuments(patientId); } docList = getLimitedStatuses(today, docList); return getDocStatuses(docList); }  MessageSendable getMessageSender(); void setMessageSender(MessageSendable messageSender); @Override List<DocStatus> getStatus(String patientId, String patientName); @Override C32Document getDocument(Date docDate, String patientId);  }
@Test public void getStatus_oneDocStored() { docsRetrieved = new ArrayList<C32DocumentEntity>(1); docsRetrieved.add(new C32DocumentEntity("112233", "<doc>hi there</doc>", getDate(2012, 10, 10, 9, 8, 7), "112233v10")); List<DocStatus> list = repo.getStatus("112233", "jones"); Assert.assertEquals(1, list.size()); assertDateEquals(list.get(0).getDateGenerated(), 2012, 10, 10, 9, 8, 7); Assert.assertEquals(BlueButtonConstants.COMPLETE_STATUS_STRING, list.get(0).getStatus()); Assert.assertEquals("112233", list.get(0).getPatientId()); assertMessageSent("112233", "jones"); assertOnePersisted("112233"); }
@Test public void getStatus_oneOfSeveralErrors() { String ptId = "12345"; String docString = "<fred></fred>"; java.sql.Timestamp time = getDate(2012, 10, 11, 13, 14, 15); setupEntriesOneErrorOneGood1(ptId, time, docString); List<DocStatus> list = repo.getStatus(ptId, "whatever"); Assert.assertEquals(2, list.size()); assertDateEquals(list.get(0).getDateGenerated(), 2012, 10, 11, 13, 14, 15); Assert.assertEquals(BlueButtonConstants.ERROR_STRING, list.get(0).getStatus()); Assert.assertEquals(ptId, list.get(0).getPatientId()); assertDateEquals(list.get(1).getDateGenerated(), 2012, 10, 11, 13, 14, 15); Assert.assertEquals(BlueButtonConstants.COMPLETE_STATUS_STRING, list.get(1).getStatus()); Assert.assertEquals(ptId, list.get(1).getPatientId()); assertMessageSent(ptId, "whatever"); assertOnePersisted(ptId); }
@Test public void getStatus_todayAlreadyRequested() { docsRetrieved = new ArrayList<C32DocumentEntity>(1); docsRetrieved.add(new C32DocumentEntity("223344", "223344v10", new java.sql.Timestamp(new Date().getTime()), "incomplete")); List<DocStatus> list = repo.getStatus("223344", "jill"); Assert.assertEquals(1, list.size()); Assert.assertEquals(0, asyncMessageList.size()); Assert.assertEquals(0, docsUpdatedList.size()); Assert.assertEquals(0, docsInsertedList.size()); }