Source:
<code>private Map<String, Set<TestEntity>> getTestsWithName(Collection<String> sessionIds, String testName){ if (sessionIds.isEmpty()){ return Collections.emptyMap(); } SessionMatchingSetup sessionMatchingSetup = new SessionMatchingSetup(false,Collections.<SessionMatchingSetup.MatchBy>emptySet()); List<TaskDataDto> taskDataDtoList = databaseService.getTaskDataForSessions(new HashSet<String>(sessionIds),sessionMatchingSetup); Map<TaskDataDto,Map<String,TestInfoDto>> testInfoMap = databaseService.getTestInfoByTaskDataDto(taskDataDtoList); Map<String, Set<TestEntity>> result = new HashMap<String, Set<TestEntity>>(); for (TaskDataDto taskDataDto : taskDataDtoList) { if (taskDataDto.getSessionIds().size() > 1) { log.error("TaskDataDto contains data for more that one session. This is unexpected result. {}", taskDataDto); } else { if (((testName != null) && (testName.equals(taskDataDto.getTaskName()))) || (testName == null)) { TestEntity testEntity = new TestEntity(); testEntity.setId(taskDataDto.getId()); testEntity.setDescription(taskDataDto.getDescription()); testEntity.setName(taskDataDto.getTaskName()); <START> testEntity.setLoad(testInfoMap.get(taskDataDto).entrySet().iterator().next().getValue().getClock()); <END> testEntity.setTerminationStrategy(testInfoMap.get(taskDataDto).entrySet().iterator().next().getValue().getTermination()); if (result.containsKey(taskDataDto.getSessionId())){ result.get(taskDataDto.getSessionId()).add(testEntity); }else{ Set<TestEntity> list = new HashSet<TestEntity>(); list.add(testEntity); result.put(taskDataDto.getSessionId(), list); } } } } return result; }</code><technical_language>if testInfoMap do contains information taskDataDto</technical_language>

Target:
private Map<String, Set<TestEntity>> getTestsWithName(Collection<String> sessionIds, String testName){ if (sessionIds.isEmpty()){ return Collections.emptyMap(); } SessionMatchingSetup sessionMatchingSetup = new SessionMatchingSetup(false,Collections.<SessionMatchingSetup.MatchBy>emptySet()); List<TaskDataDto> taskDataDtoList = databaseService.getTaskDataForSessions(new HashSet<String>(sessionIds),sessionMatchingSetup); Map<TaskDataDto,Map<String,TestInfoDto>> testInfoMap = databaseService.getTestInfoByTaskDataDto(taskDataDtoList); Map<String, Set<TestEntity>> result = new HashMap<String, Set<TestEntity>>(); for (TaskDataDto taskDataDto : taskDataDtoList) { if (taskDataDto.getSessionIds().size() > 1) { log.error("TaskDataDto contains data for more that one session. This is unexpected result. {}", taskDataDto); } else { if (((testName != null) && (testName.equals(taskDataDto.getTaskName()))) || (testName == null)) { TestEntity testEntity = new TestEntity(); testEntity.setId(taskDataDto.getId()); testEntity.setDescription(taskDataDto.getDescription()); testEntity.setName(taskDataDto.getTaskName()); if (testInfoMap.containsKey(taskDataDto)) { testEntity.setLoad(testInfoMap.get(taskDataDto).entrySet().iterator().next().getValue().getClock()); testEntity.setTerminationStrategy(testInfoMap.get(taskDataDto).entrySet().iterator().next().getValue().getTermination()); } else { testEntity.setLoad(""); testEntity.setTerminationStrategy(""); } if (result.containsKey(taskDataDto.getSessionId())){ result.get(taskDataDto.getSessionId()).add(testEntity); }else{ Set<TestEntity> list = new HashSet<TestEntity>(); list.add(testEntity); result.put(taskDataDto.getSessionId(), list); } } } } return result; }