Jagger
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
Map<String, Set<TestEntity> > com.griddynamics.jagger.engine.e1.services.DefaultDataService.getTestsWithName ( Collection< String >  sessionIds,
String  testName,
SessionMatchingSetup  sessionMatchingSetup 
)

Definition at line 135 of file DefaultDataService.java.

References com.griddynamics.jagger.engine.e1.services.data.service.TestEntity.setClockValue(), com.griddynamics.jagger.engine.e1.services.data.service.TestEntity.setDecision(), com.griddynamics.jagger.engine.e1.services.data.service.TestEntity.setDescription(), com.griddynamics.jagger.engine.e1.services.data.service.TestEntity.setId(), com.griddynamics.jagger.engine.e1.services.data.service.TestEntity.setLoad(), com.griddynamics.jagger.engine.e1.services.data.service.TestEntity.setName(), com.griddynamics.jagger.engine.e1.services.data.service.TestEntity.setStartDate(), com.griddynamics.jagger.engine.e1.services.data.service.TestEntity.setTaskDataDto(), com.griddynamics.jagger.engine.e1.services.data.service.TestEntity.setTerminationStrategy(), com.griddynamics.jagger.engine.e1.services.data.service.TestEntity.setTestExecutionStatus(), and com.griddynamics.jagger.engine.e1.services.data.service.TestEntity.setTestGroupIndex().

Referenced by com.griddynamics.jagger.engine.e1.services.DefaultDataService.getTests(), and com.griddynamics.jagger.engine.e1.services.DefaultDataService.getTestsByName().

135  {
136  if (sessionIds.isEmpty()) {
137  return Collections.emptyMap();
138  }
139 
140  // basic
141  List<TaskDataDto> taskDataDtoList = databaseService.getTaskDataForSessions(new HashSet<String>(sessionIds), sessionMatchingSetup);
142  // info
143  Map<TaskDataDto, Map<String, TestInfoDto>> testInfoMap = databaseService.getTestInfoByTaskDataDto(taskDataDtoList);
144  // decision
145  Set<Long> ids = new HashSet<Long>();
146  for (TaskDataDto taskDataDto : taskDataDtoList) {
147  ids.addAll(taskDataDto.getIds());
148  }
149  Map<Long, TaskDecisionDto> idToDecisionPerTest = new HashMap<Long, TaskDecisionDto>();
150  for (TaskDecisionDto taskDecisionDto : databaseService.getDecisionsPerTask(ids)) {
151  idToDecisionPerTest.put(taskDecisionDto.getId(), taskDecisionDto);
152  }
153 
154  Map<String, Set<TestEntity>> result = new HashMap<String, Set<TestEntity>>();
155 
156  for (TaskDataDto taskDataDto : taskDataDtoList) {
157  for (Map.Entry<Long, String> entry : taskDataDto.getIdToSessionId().entrySet()) {
158  if (((testName != null) && (testName.equals(taskDataDto.getTaskName()))) ||
159  (testName == null)) {
160  Long testId = entry.getKey();
161  String sessionId = entry.getValue();
162 
163  TestEntity testEntity = new TestEntity();
164  testEntity.setId(testId);
165  testEntity.setDescription(taskDataDto.getDescription());
166  testEntity.setName(taskDataDto.getTaskName());
167  testEntity.setTaskDataDto(taskDataDto);
168 
169  if (testInfoMap.containsKey(taskDataDto)) {
170  TestInfoDto testInfoDto = testInfoMap.get(taskDataDto).entrySet().iterator().next().getValue();
171  testEntity.setLoad(testInfoDto.getClock());
172  testEntity.setClockValue(testInfoDto.getClockValue());
173  testEntity.setTerminationStrategy(testInfoDto.getTermination());
174  testEntity.setStartDate(testInfoDto.getStartTime());
175  testEntity.setTestGroupIndex(testInfoDto.getNumber());
176  testEntity.setTestExecutionStatus(testInfoDto.getStatus());
177  }
178 
179  if (idToDecisionPerTest.containsKey(testId)) {
180  testEntity.setDecision(idToDecisionPerTest.get(testId).getDecision());
181  }
182 
183  if (result.containsKey(sessionId)) {
184  result.get(sessionId).add(testEntity);
185  } else {
186  Set<TestEntity> testEntitySet = new HashSet<TestEntity>();
187  testEntitySet.add(testEntity);
188  result.put(sessionId, testEntitySet);
189  }
190  }
191  }
192  }
193 
194  // add empty results when not found
195  for (String sessionId : sessionIds) {
196  if (!result.containsKey(sessionId)) {
197  result.put(sessionId, Collections.<TestEntity>emptySet());
198  }
199  }
200 
201  return result;
202  }

Here is the call graph for this function:

Here is the caller graph for this function: