Search in sources :

Example 1 with TestItem

use of com.epam.ta.reportportal.database.entity.item.TestItem in project commons-dao by reportportal.

the class MoreCollectorsTest method getTestData.

private List<TestItem> getTestData(final int count) {
    List<TestItem> list = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        TestItem testItem = new TestItem();
        testItem.setId(String.valueOf(i));
        testItem.setUniqueId("unique" + i);
        list.add(testItem);
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) TestItem(com.epam.ta.reportportal.database.entity.item.TestItem)

Example 2 with TestItem

use of com.epam.ta.reportportal.database.entity.item.TestItem in project commons-dao by reportportal.

the class TestItemRepositoryTest method setUp.

@Before
public void setUp() {
    String launch = "launch";
    TestItem testItem = new TestItem();
    testItem.setLaunchRef(launch);
    testItem.setId(testItemId1);
    testItem.setName("test");
    testItem.setIssue(new TestItemIssue(TestItemIssueType.SYSTEM_ISSUE.getLocator(), null));
    TestItem testItem1 = new TestItem();
    testItem1.setId(testItemId2);
    testItem1.setName("testName");
    testItem1.setLaunchRef(launch);
    testItem1.setType(TestItemType.SUITE);
    testItem1.setIssue(new TestItemIssue(TestItemIssueType.NO_DEFECT.getLocator(), null));
    TestItem testItem2 = new TestItem();
    testItem2.setId(testItemId3);
    testItem2.setName("test2");
    testItem2.setIssue(new TestItemIssue("nd_custom", null));
    testItem2.setType(TestItemType.SUITE);
    testItem2.setLaunchRef(launch);
    testItemRepository.save(testItem2);
    testItemRepository.save(testItem1);
    testItemRepository.save(testItem);
    TestItem child = new TestItem();
    child.setId(testItemId4);
    child.setName("child");
    child.setStatus(Status.FAILED);
    child.setParent(testItem.getId());
    testItemRepository.save(child);
}
Also used : TestItemIssue(com.epam.ta.reportportal.database.entity.item.issue.TestItemIssue) TestItem(com.epam.ta.reportportal.database.entity.item.TestItem) Before(org.junit.Before)

Example 3 with TestItem

use of com.epam.ta.reportportal.database.entity.item.TestItem in project commons-dao by reportportal.

the class TestItemRepositoryTest method updateExecutionStatisticsTest.

@Test
public void updateExecutionStatisticsTest() {
    final TestItem testItem = new TestItem();
    testItem.setStatistics(new Statistics(new ExecutionCounter(2, 2, 0, 0), new IssueCounter()));
    testItem.setStatus(Status.PASSED);
    testItemRepository.save(testItem);
    testItemRepository.updateExecutionStatistics(testItem);
    final TestItem item = testItemRepository.findOne(testItem.getId());
    final ExecutionCounter executionCounter = item.getStatistics().getExecutionCounter();
    assertThat(executionCounter.getTotal()).isEqualTo(3);
    assertThat(executionCounter.getFailed()).isEqualTo(0);
    assertThat(executionCounter.getPassed()).isEqualTo(3);
    assertThat(executionCounter.getSkipped()).isEqualTo(0);
}
Also used : ExecutionCounter(com.epam.ta.reportportal.database.entity.statistics.ExecutionCounter) IssueCounter(com.epam.ta.reportportal.database.entity.statistics.IssueCounter) Statistics(com.epam.ta.reportportal.database.entity.statistics.Statistics) TestItem(com.epam.ta.reportportal.database.entity.item.TestItem) BaseDaoTest(com.epam.ta.reportportal.BaseDaoTest) Test(org.junit.Test)

Example 4 with TestItem

use of com.epam.ta.reportportal.database.entity.item.TestItem in project commons-dao by reportportal.

the class CriteriaMapTest method dynamicCriteriaTest.

@Test
public void dynamicCriteriaTest() {
    CriteriaMap<TestItem> testItemCriteriaMap = new CriteriaMap<>(TestItem.class);
    assertThat(testItemCriteriaMap.getCriteriaHolderUnchecked(IssueCounter.PRODUCT_BUG_CRITERIA)).isPresent();
    Filter filter = Filter.builder().withCondition(FilterCondition.builder().withCondition(Condition.EQUALS).withSearchCriteria("statistics$defects$product_bug$total").withValue("10").build()).withTarget(TestItem.class).build();
    Query q = QueryBuilder.newBuilder().with(filter).build();
    assertThat(q.getQueryObject().get("statistics.issueCounter.productBug.total")).isEqualTo(10L);
}
Also used : Query(org.springframework.data.mongodb.core.query.Query) TestItem(com.epam.ta.reportportal.database.entity.item.TestItem) Test(org.junit.Test)

Example 5 with TestItem

use of com.epam.ta.reportportal.database.entity.item.TestItem in project commons-dao by reportportal.

the class TestItemRepositoryCustomImpl method findIdsWithNameByLaunchesRef.

@Override
public Set<String> findIdsWithNameByLaunchesRef(String name, Set<String> launchRef) {
    Query query = query(where(LAUNCH_REFERENCE).in(launchRef)).addCriteria(where(NAME).is(name));
    query.fields().include("_id");
    return mongoTemplate.find(query, TestItem.class).stream().map(TestItem::getId).collect(toSet());
}
Also used : Query(org.springframework.data.mongodb.core.query.Query) TestItem(com.epam.ta.reportportal.database.entity.item.TestItem)

Aggregations

TestItem (com.epam.ta.reportportal.database.entity.item.TestItem)10 Query (org.springframework.data.mongodb.core.query.Query)6 ArrayList (java.util.ArrayList)3 TestItemIssue (com.epam.ta.reportportal.database.entity.item.issue.TestItemIssue)2 BasicDBObject (com.mongodb.BasicDBObject)2 Collectors.toList (java.util.stream.Collectors.toList)2 ObjectId (org.bson.types.ObjectId)2 Test (org.junit.Test)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 MongoTemplate (org.springframework.data.mongodb.core.MongoTemplate)2 Criteria (org.springframework.data.mongodb.core.query.Criteria)2 BaseDaoTest (com.epam.ta.reportportal.BaseDaoTest)1 DbUtils (com.epam.ta.reportportal.commons.DbUtils)1 MoreCollectors (com.epam.ta.reportportal.commons.MoreCollectors)1 LogRepository (com.epam.ta.reportportal.database.dao.LogRepository)1 AddFieldsOperation.addFields (com.epam.ta.reportportal.database.dao.aggregation.AddFieldsOperation.addFields)1 com.epam.ta.reportportal.database.entity (com.epam.ta.reportportal.database.entity)1 FlakyHistory (com.epam.ta.reportportal.database.entity.history.status.FlakyHistory)1 MostFailedHistory (com.epam.ta.reportportal.database.entity.history.status.MostFailedHistory)1 RetryObject (com.epam.ta.reportportal.database.entity.history.status.RetryObject)1