Search in sources :

Example 56 with BuildDetails

use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.

the class TestUtils method createRandomBuildHistory.

public static List<BuildDetails> createRandomBuildHistory(final String hostName, final String projectName, final int numOfBuilds, final boolean withParams) {
    final List<BuildDetails> retval = new ArrayList<BuildDetails>(numOfBuilds);
    for (int buildCtr = 1; buildCtr <= numOfBuilds; buildCtr++) {
        final BuildDetails buildDetails = createRandomBuildDetails(withParams);
        buildDetails.setId(buildDetails.getId() + buildCtr);
        buildDetails.setName(projectName);
        buildDetails.getNode().setMasterHostName(hostName);
        retval.add(buildDetails);
    }
    return retval;
}
Also used : BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) ArrayList(java.util.ArrayList)

Example 57 with BuildDetails

use of org.jenkins.plugins.audit2db.model.BuildDetails 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 58 with BuildDetails

use of org.jenkins.plugins.audit2db.model.BuildDetails 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)

Example 59 with BuildDetails

use of org.jenkins.plugins.audit2db.model.BuildDetails 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 60 with BuildDetails

use of org.jenkins.plugins.audit2db.model.BuildDetails 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

BuildDetails (org.jenkins.plugins.audit2db.model.BuildDetails)62 Test (org.junit.Test)50 List (java.util.List)25 Calendar (java.util.Calendar)11 BuildParameter (org.jenkins.plugins.audit2db.model.BuildParameter)11 Date (java.util.Date)9 ArrayList (java.util.ArrayList)8 TransactionStatus (org.springframework.transaction.TransactionStatus)8 BuildDetailsHibernateRepository (org.jenkins.plugins.audit2db.internal.data.BuildDetailsHibernateRepository)5 BuildDetailsImpl (org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl)5 JobsByParamReportImpl (org.jenkins.plugins.audit2db.internal.reports.JobsByParamReportImpl)5 JobHistoryReport (org.jenkins.plugins.audit2db.reports.JobHistoryReport)5 JobsByParamReport (org.jenkins.plugins.audit2db.reports.JobsByParamReport)5 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)4 BuildNode (org.jenkins.plugins.audit2db.model.BuildNode)4 JobsByDateReport (org.jenkins.plugins.audit2db.reports.JobsByDateReport)4 HashMap (java.util.HashMap)3 Jenkins (jenkins.model.Jenkins)3 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)3 BuildDetailsRepository (org.jenkins.plugins.audit2db.data.BuildDetailsRepository)3