public Collection<String> getSitesForTestSession(TestSession testSession) throws Exception { Set<String> sites = new HashSet<>(); List<LogMapDTO> logMapDTOs = getLogsForTestSession(testSession); for (LogMapDTO logMapDTO : logMapDTOs) { Map<String, LogFileContentDTO> map = logMapDTO.getLogFileContentMap(); for (LogFileContentDTO logFileContentDTO : map.values()) { String site = logFileContentDTO.getSiteName(); if (site != null && !site.equals("")) sites.add(site); } } return sites; }
/** * Validate testSession and site exist and that either the testSession is empty or it contains * only test results for that site. * @param testSession * @param siteName * @return status */ public ConformanceSessionValidationStatus validateConformanceSession(TestSession testSession, String siteName) throws Exception { List<LogMapDTO> logMapDTOs = getLogsForTestSession(testSession); if (siteName == null || siteName.equals("")) return new ConformanceSessionValidationStatus(); Set<String> badSites = new HashSet<>(); for (LogMapDTO logMapDTO : logMapDTOs) { Map<String, LogFileContentDTO> map = logMapDTO.getLogFileContentMap(); for (LogFileContentDTO logFileContentDTO : map.values()) { String site = logFileContentDTO.getSiteName(); if (site == null || site.equals("")) continue; if (!site.equals(siteName)) { badSites.add(site); } } } if (badSites.size() == 0) return new ConformanceSessionValidationStatus(); StringBuilder buf = new StringBuilder(); buf.append("Test Session ").append(testSession).append(" already has results for these sites: ").append(badSites.toString() + " you cannot use it to test " + siteName); return new ConformanceSessionValidationStatus(false, buf.toString()); }
private SectionOverviewDTO addSection(String sectionName, LogFileContentDTO logFileContentDTO) { SectionOverviewDTO sectionOverview = new SectionOverviewDTO(); sectionOverview.setName(sectionName); if (logFileContentDTO == null) { sectionOverview.setRun(false); testOverview.addSection(sectionOverview); return sectionOverview; } sectionOverview.setTls(logFileContentDTO.isTls()); sectionOverview.setPass(logFileContentDTO.isSuccess()); sectionOverview.setHl7Time(logFileContentDTO.getHl7Time()); sectionOverview.setSite(logFileContentDTO.getSiteName()); for (String stepName : logFileContentDTO.getStepMap().keySet()) { TestStepLogContentDTO stepContent = logFileContentDTO.getStepLog(stepName); addStep(stepName, stepContent, sectionOverview); } testOverview.addSection(sectionOverview); return sectionOverview; }