Search in sources :

Example 1 with IssueCounter

use of com.epam.ta.reportportal.database.entity.statistics.IssueCounter 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 2 with IssueCounter

use of com.epam.ta.reportportal.database.entity.statistics.IssueCounter in project commons-dao by reportportal.

the class UpdateStatisticsQueryBuilder method fromIssueTypeAware.

/**
 * Complex update operator for MongoDB with positive or negative increment
 * for all defined issue sub-types of specified test item.
 *
 * upd: since there are different methods for incrementing, this is used
 * only for deleting item's statistics.
 *
 * @param item
 * @return Update
 */
/* DELETE methods in old statistics */
public static Update fromIssueTypeAware(final TestItem item) {
    IssueCounter issueCounter = item.getStatistics().getIssueCounter();
    /* MongoDB Update object instance initialization */
    Update issueStatusAware = new Update();
    issueCounter.getAutomationBug().forEach((k, v) -> decreaseIssueCounter(issueStatusAware, AUTOMATION_BUG.awareStatisticsField(), k, v));
    issueCounter.getProductBug().forEach((k, v) -> decreaseIssueCounter(issueStatusAware, PRODUCT_BUG.awareStatisticsField(), k, v));
    issueCounter.getSystemIssue().forEach((k, v) -> decreaseIssueCounter(issueStatusAware, SYSTEM_ISSUE.awareStatisticsField(), k, v));
    issueCounter.getNoDefect().forEach((k, v) -> decreaseIssueCounter(issueStatusAware, NO_DEFECT.awareStatisticsField(), k, v));
    issueCounter.getToInvestigate().forEach((k, v) -> decreaseIssueCounter(issueStatusAware, TO_INVESTIGATE.awareStatisticsField(), k, v));
    return issueStatusAware;
}
Also used : IssueCounter(com.epam.ta.reportportal.database.entity.statistics.IssueCounter) Update(org.springframework.data.mongodb.core.query.Update)

Aggregations

IssueCounter (com.epam.ta.reportportal.database.entity.statistics.IssueCounter)2 BaseDaoTest (com.epam.ta.reportportal.BaseDaoTest)1 TestItem (com.epam.ta.reportportal.database.entity.item.TestItem)1 ExecutionCounter (com.epam.ta.reportportal.database.entity.statistics.ExecutionCounter)1 Statistics (com.epam.ta.reportportal.database.entity.statistics.Statistics)1 Test (org.junit.Test)1 Update (org.springframework.data.mongodb.core.query.Update)1