Search in sources :

Example 1 with JobHistoryReport

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

the class JobHistoryReportTests method invalidProjectNameShouldReturnEmptyResults.

@Test
public void invalidProjectNameShouldReturnEmptyResults() {
    final JobHistoryReport report = new JobHistoryReportImpl();
    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 String projectName = dataset.keySet().iterator().next();
    final Map<String, List<BuildDetails>> results = report.getProjectExecutions(projectName.substring(0) + " INVALID", TestUtils.NOW, TestUtils.NOW);
    Assert.assertTrue("Unexpected results collection", results.isEmpty());
}
Also used : JobHistoryReportImpl(org.jenkins.plugins.audit2db.internal.reports.JobHistoryReportImpl) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) JobHistoryReport(org.jenkins.plugins.audit2db.reports.JobHistoryReport) List(java.util.List) Test(org.junit.Test)

Example 2 with JobHistoryReport

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

the class JobHistoryReportTests method projectNameWithWildcardShouldReturnNonEmptyResults.

@Test
public void projectNameWithWildcardShouldReturnNonEmptyResults() {
    final JobHistoryReport report = new JobHistoryReportImpl();
    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 String projectName = dataset.keySet().iterator().next();
    final Map<String, List<BuildDetails>> results = report.getProjectExecutions(projectName.substring(0) + "%", TestUtils.NOW, TestUtils.NOW);
    Assert.assertFalse("Unexpected empty results", results.isEmpty());
}
Also used : JobHistoryReportImpl(org.jenkins.plugins.audit2db.internal.reports.JobHistoryReportImpl) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) JobHistoryReport(org.jenkins.plugins.audit2db.reports.JobHistoryReport) List(java.util.List) Test(org.junit.Test)

Example 3 with JobHistoryReport

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

the class JobHistoryReportTests method matchingParametersShouldReturnNonEmptyResults.

@Test
public void matchingParametersShouldReturnNonEmptyResults() {
    final JobHistoryReport report = new JobHistoryReportImpl();
    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 String projectName = dataset.keySet().iterator().next();
    final Map<String, List<BuildDetails>> results = report.getProjectExecutions(projectName, TestUtils.NOW, TestUtils.NOW);
    Assert.assertFalse("Unexpected empty results", results.isEmpty());
}
Also used : JobHistoryReportImpl(org.jenkins.plugins.audit2db.internal.reports.JobHistoryReportImpl) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) JobHistoryReport(org.jenkins.plugins.audit2db.reports.JobHistoryReport) List(java.util.List) Test(org.junit.Test)

Example 4 with JobHistoryReport

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

the class WhenRunningJobsHistoryReport method testShouldDisplayNoRecordsForNonMatchingSelection.

@Test
public void testShouldDisplayNoRecordsForNonMatchingSelection() {
    final JobHistoryReport report = TestUtils.getReportExtension(JobHistoryReport.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(tomorrow);
        page.setJobName("A JOB THAT DOES NOT EXIST");
        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) JobHistoryReport(org.jenkins.plugins.audit2db.reports.JobHistoryReport) List(java.util.List) BuildDetailsHibernateRepository(org.jenkins.plugins.audit2db.internal.data.BuildDetailsHibernateRepository) Test(org.junit.Test)

Example 5 with JobHistoryReport

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

the class WhenRunningJobsHistoryReport method testShouldDisplaySomeRecordsForMatchingSelection.

@Test
public void testShouldDisplaySomeRecordsForMatchingSelection() {
    final JobHistoryReport report = TestUtils.getReportExtension(JobHistoryReport.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);
    }
    final String projectName = dataset.keySet().iterator().next();
    // used for debugging
    String pageText = null;
    try {
        page.load();
        page.setStartDate(now);
        page.setEndDate(tomorrow);
        // test wildcard
        page.setJobName(projectName + "%");
        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) JobHistoryReport(org.jenkins.plugins.audit2db.reports.JobHistoryReport) List(java.util.List) BuildDetailsHibernateRepository(org.jenkins.plugins.audit2db.internal.data.BuildDetailsHibernateRepository) Test(org.junit.Test)

Aggregations

List (java.util.List)5 BuildDetails (org.jenkins.plugins.audit2db.model.BuildDetails)5 JobHistoryReport (org.jenkins.plugins.audit2db.reports.JobHistoryReport)5 Test (org.junit.Test)5 JobHistoryReportImpl (org.jenkins.plugins.audit2db.internal.reports.JobHistoryReportImpl)3 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)2 BuildDetailsHibernateRepository (org.jenkins.plugins.audit2db.internal.data.BuildDetailsHibernateRepository)2