Search in sources :

Example 1 with JobsByDateReport

use of org.jenkins.plugins.audit2db.reports.JobsByDateReport in project selenium_java by sergueik.

the class JobsByDateReportTests method invalidDateRangeShouldReturnEmptyResults.

@Test
public void invalidDateRangeShouldReturnEmptyResults() {
    final JobsByDateReport report = new JobsByDateReportImpl();
    report.setRepository(TestUtils.getTestRepository());
    final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(DbAuditUtil.getHostName());
    // after each test run
    for (final List<BuildDetails> detailsList : dataset.values()) {
        TestUtils.getTestRepository().saveBuildDetailsList(detailsList);
    }
    Map<String, List<BuildDetails>> results = report.getProjectExecutions(TestUtils.YESTERDAY, TestUtils.YESTERDAY);
    Assert.assertTrue("Unexpected results collection", results.isEmpty());
    results = report.getProjectExecutions(TestUtils.TOMORROW, TestUtils.TOMORROW);
    Assert.assertTrue("Unexpected results collection", results.isEmpty());
}
Also used : BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) List(java.util.List) JobsByDateReport(org.jenkins.plugins.audit2db.reports.JobsByDateReport) JobsByDateReportImpl(org.jenkins.plugins.audit2db.internal.reports.JobsByDateReportImpl) Test(org.junit.Test)

Example 2 with JobsByDateReport

use of org.jenkins.plugins.audit2db.reports.JobsByDateReport in project selenium_java by sergueik.

the class JobsByDateReportTests method matchingParametersShouldReturnNonEmptyResults.

@Test
public void matchingParametersShouldReturnNonEmptyResults() {
    final JobsByDateReport report = new JobsByDateReportImpl();
    report.setRepository(TestUtils.getTestRepository());
    final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(DbAuditUtil.getHostName());
    // after each test run
    for (final List<BuildDetails> detailsList : dataset.values()) {
        TestUtils.getTestRepository().saveBuildDetailsList(detailsList);
    }
    final Map<String, List<BuildDetails>> results = report.getProjectExecutions(TestUtils.NOW, TestUtils.NOW);
    Assert.assertFalse("Unexpected empty results", results.isEmpty());
}
Also used : BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) List(java.util.List) JobsByDateReport(org.jenkins.plugins.audit2db.reports.JobsByDateReport) JobsByDateReportImpl(org.jenkins.plugins.audit2db.internal.reports.JobsByDateReportImpl) Test(org.junit.Test)

Example 3 with JobsByDateReport

use of org.jenkins.plugins.audit2db.reports.JobsByDateReport in project selenium_java by sergueik.

the class WhenRunningJobsByDateReport method testShouldDisplaySomeRecordsForMatchingSelection.

@Test
public void testShouldDisplaySomeRecordsForMatchingSelection() {
    final JobsByDateReport report = TestUtils.getReportExtension(JobsByDateReport.class);
    final BuildDetailsHibernateRepository repository = (BuildDetailsHibernateRepository) report.getRepository();
    final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(DbAuditUtil.getHostName());
    // after each test run
    for (final List<BuildDetails> detailsList : dataset.values()) {
        repository.saveBuildDetailsList(detailsList);
    }
    // used for debugging
    String pageText = null;
    try {
        page.load();
        page.setStartDate(now);
        page.setEndDate(tomorrow);
        final HtmlPage resultPage = page.submit();
        pageText = resultPage.asText();
        WebAssert.assertElementPresent(resultPage, "reportResults");
    } catch (final Exception e) {
        // expecting successful run
        LOGGER.log(Level.SEVERE, pageText, e);
        fail("Unexpected error.");
    }
}
Also used : BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) List(java.util.List) JobsByDateReport(org.jenkins.plugins.audit2db.reports.JobsByDateReport) BuildDetailsHibernateRepository(org.jenkins.plugins.audit2db.internal.data.BuildDetailsHibernateRepository) Test(org.junit.Test)

Example 4 with JobsByDateReport

use of org.jenkins.plugins.audit2db.reports.JobsByDateReport in project selenium_java by sergueik.

the class WhenRunningJobsByDateReport method testShouldDisplayNoRecordsForNonMatchingSelection.

@Test
public void testShouldDisplayNoRecordsForNonMatchingSelection() {
    final JobsByDateReport report = TestUtils.getReportExtension(JobsByDateReport.class);
    final BuildDetailsHibernateRepository repository = (BuildDetailsHibernateRepository) report.getRepository();
    final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(DbAuditUtil.getHostName());
    // after each test run
    for (final List<BuildDetails> detailsList : dataset.values()) {
        repository.saveBuildDetailsList(detailsList);
    }
    // used for debugging
    String pageText = null;
    try {
        page.load();
        page.setStartDate(yesterday);
        page.setEndDate(yesterday);
        final HtmlPage resultPage = page.submit();
        pageText = resultPage.asText();
        WebAssert.assertElementPresent(resultPage, "noDataWarning");
    } catch (final Exception e) {
        // expecting successful run
        LOGGER.log(Level.SEVERE, pageText, e);
        fail("Unexpected error.");
    }
}
Also used : BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) List(java.util.List) JobsByDateReport(org.jenkins.plugins.audit2db.reports.JobsByDateReport) BuildDetailsHibernateRepository(org.jenkins.plugins.audit2db.internal.data.BuildDetailsHibernateRepository) Test(org.junit.Test)

Aggregations

List (java.util.List)4 BuildDetails (org.jenkins.plugins.audit2db.model.BuildDetails)4 JobsByDateReport (org.jenkins.plugins.audit2db.reports.JobsByDateReport)4 Test (org.junit.Test)4 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)2 BuildDetailsHibernateRepository (org.jenkins.plugins.audit2db.internal.data.BuildDetailsHibernateRepository)2 JobsByDateReportImpl (org.jenkins.plugins.audit2db.internal.reports.JobsByDateReportImpl)2