CDAHelper { public static Obs getLatestObs(List<Obs> observationList) { Map<String,Obs> latestObsdate=new HashMap<String,Obs>(); if(observationList!=null) { if(observationList.isEmpty()) { return null; } else { for (Obs obs : observationList) { if(latestObsdate.isEmpty()) { latestObsdate.put("Latest date", obs); } else { Date date=latestObsdate.get("Latest date").getObsDatetime(); if(date.before(obs.getObsDatetime())) { latestObsdate.put("Latest date", obs); } } } return latestObsdate.get("Latest date"); } } else return null; }  static SimpleDateFormat getDateFormat(); static IVL_TS buildEffectiveTimeinIVL(Date d , Date d1); static IVL_TS buildEffectiveTimeinIVL(Date d); static II buildTemplateID(String root , String extension ,String assigningAuthorityName); static ST buildTitle(String title); static II buildID(String root , String extension); static CE buildCodeCE(String code , String codeSystem, String displayString, String codeSystemName); static CD buildCodeCD(String code , String codeSystem, String displayString, String codeSystemName); static TS buildEffectiveTime(Date d); static ED buildEDText(String value); static String getDatatypesValue(Integer datatypeId,Obs obs); static Obs getLatestObs(List<Obs> observationList); static CS getStatusCode(String statusCode); static IVL_TS buildDateTime(Date date); static String getCodeSystemByName(String codeSystemName); static String removeDirtyValue(String input); static String getUnitsaccordingto_Tf_PCC(String unit); static String getConceptIdasString(int conceptId);  }
@Test public void shouldreturnNullIfgetLatestObsIsCalledWithNull() { Obs latestobs=CDAHelper.getLatestObs(null); Assert.assertEquals(latestobs, null); }