use of com.epam.ta.reportportal.database.entity.item.TestItem in project commons-dao by reportportal.
the class TestItemRepositoryCustomImpl method findIdsNotInIssueType.
@Override
public List<String> findIdsNotInIssueType(String issueType, String launchId) {
Query query = query(where(LAUNCH_REFERENCE).is(launchId)).addCriteria(where(ISSUE).exists(true)).addCriteria(where(ISSUE_TYPE).ne(issueType));
query.fields().include(ID);
return mongoTemplate.find(query, TestItem.class).stream().map(TestItem::getId).collect(toList());
}
use of com.epam.ta.reportportal.database.entity.item.TestItem in project commons-dao by reportportal.
the class TestItemRepositoryCustomImpl method findRetry.
@Override
public Optional<TestItem> findRetry(String retryId) {
Query q = query(where("retries._id").is(retryId));
q.fields().include("retries");
return Optional.ofNullable(mongoTemplate.findOne(q, TestItem.class)).flatMap(it -> Optional.ofNullable(it.getRetries())).flatMap(it -> it.stream().filter(r -> retryId.equals(r.getId())).findAny());
}
use of com.epam.ta.reportportal.database.entity.item.TestItem in project commons-dao by reportportal.
the class TestItemRepositoryCustomImpl method findPathNames.
@Override
public Map<String, String> findPathNames(Iterable<String> path) {
Query q = query(where("_id").in(toObjId(path)));
q.fields().include("name");
List<TestItem> testItems = mongoTemplate.find(q, TestItem.class);
return testItems.stream().collect(MoreCollectors.toLinkedMap(TestItem::getId, TestItem::getName));
}
use of com.epam.ta.reportportal.database.entity.item.TestItem in project commons-dao by reportportal.
the class DeleteItemsListener method onBeforeDelete.
@Override
public void onBeforeDelete(BeforeDeleteEvent<TestItem> event) {
DBObject dbqo = queryMapper.getMappedObject(event.getDBObject(), mappingContext.getPersistentEntity(TestItem.class));
for (DBObject dbObject : mongoTemplate.getCollection(event.getCollectionName()).find(dbqo)) {
Boolean isRetryProcessed = (Boolean) dbObject.get("retryProcessed");
if (isRetryProcessed == null || isRetryProcessed) {
String objectId = dbObject.get("_id").toString();
List<TestItem> itemsForDelete = mongoTemplate.find(queryItems(objectId), TestItem.class);
List<ObjectId> objectIds = itemsForDelete.stream().map(it -> new ObjectId(it.getId())).collect(toList());
BasicDBObject query = new BasicDBObject("_id", new BasicDBObject("$in", objectIds));
mongoTemplate.getCollection(event.getCollectionName()).remove(query);
List<String> itemRefs = getLogItemReferences(itemsForDelete);
logRepository.deleteByItemRef(itemRefs);
}
}
}
use of com.epam.ta.reportportal.database.entity.item.TestItem in project commons-dao by reportportal.
the class DeleteProjectListenerTest method testData.
private TestData testData() {
final Project project = new Project();
project.setName(PROJECT_ID);
projectRepository.save(project);
final Launch launch = new Launch();
launch.setProjectRef(project.getId());
launchRepository.save(launch);
final TestItem suite = new TestItem();
suite.setLaunchRef(launch.getId());
testItemRepository.save(suite);
final TestItem test = new TestItem();
test.setLaunchRef(launch.getId());
test.setParent(suite.getId());
test.setPath(singletonList(suite.getId()));
testItemRepository.save(test);
final TestItem step = new TestItem();
step.setLaunchRef(launch.getId());
step.setParent(test.getId());
final List<String> stepPath = new ArrayList<>(test.getPath());
stepPath.add(test.getId());
step.setPath(stepPath);
testItemRepository.save(step);
final Log log = log(step.getId());
final TestData testData = new TestData();
testData.projectId = project.getId();
testData.launchId = launch.getId();
testData.suiteId = suite.getId();
testData.testId = test.getId();
testData.stepId = step.getId();
testData.logId = log.getId();
testData.fileName = log.getBinaryContent().getBinaryDataId();
testData.thumbnail = log.getBinaryContent().getThumbnailId();
return testData;
}
Aggregations