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()); }
for (String section : lm.getLogFileContentMap().keySet()) { LogFileContentDTO ll = lm.getLogFileContentMap().get(section); testLogDetails.addTestPlanLog(section, ll);