Search in sources :

Example 1 with Statistics

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

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

the class UpdateStatisticsQueryBuilder method fromItemStatusAware.

public static Update fromItemStatusAware(final TestItem item, boolean isReset) {
    Statistics current = item.getStatistics();
    int iTotal = current.getExecutionCounter().getPassed() + current.getExecutionCounter().getFailed() + current.getExecutionCounter().getSkipped();
    int iPassed = current.getExecutionCounter().getPassed();
    int iFailed = current.getExecutionCounter().getFailed();
    int iSkipped = current.getExecutionCounter().getSkipped();
    Update updateStatusAware = new Update().inc(EXECUTION_COUNTER + ".total", isReset ? iTotal * -1 : iTotal);
    if (item.getStatus().awareStatisticsField() != null && !item.getStatus().awareStatisticsField().isEmpty()) {
        updateStatusAware = updateStatusAware.inc(EXECUTION_COUNTER + "." + Status.PASSED.awareStatisticsField(), isReset ? iPassed * -1 : iPassed);
        updateStatusAware = updateStatusAware.inc(EXECUTION_COUNTER + "." + Status.FAILED.awareStatisticsField(), isReset ? iFailed * -1 : iFailed);
        updateStatusAware = updateStatusAware.inc(EXECUTION_COUNTER + "." + Status.SKIPPED.awareStatisticsField(), isReset ? iSkipped * -1 : iSkipped);
    }
    return updateStatusAware;
}
Also used : Update(org.springframework.data.mongodb.core.query.Update) Statistics(com.epam.ta.reportportal.database.entity.statistics.Statistics)

Aggregations

Statistics (com.epam.ta.reportportal.database.entity.statistics.Statistics)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 IssueCounter (com.epam.ta.reportportal.database.entity.statistics.IssueCounter)1 Test (org.junit.Test)1 Update (org.springframework.data.mongodb.core.query.Update)1