Search in sources :

Example 51 with BuildDetails

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

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

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

the class JobsByParamReportTests method invalidParamValueShouldReturnEmptyResults.

@Test
public void invalidParamValueShouldReturnEmptyResults() {
    final JobsByParamReport report = new JobsByParamReportImpl();
    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 BuildParameter param = dataset.values().iterator().next().get(0).getParameters().get(0);
    final Map<String, List<BuildDetails>> results = report.getProjectExecutions(param.getName(), param.getValue() + " INVALID", TestUtils.NOW, TestUtils.NOW);
    Assert.assertTrue("Unexpected results collection", results.isEmpty());
}
Also used : BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) JobsByParamReportImpl(org.jenkins.plugins.audit2db.internal.reports.JobsByParamReportImpl) List(java.util.List) JobsByParamReport(org.jenkins.plugins.audit2db.reports.JobsByParamReport) Test(org.junit.Test)

Example 54 with BuildDetails

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

the class JobsByParamReportTests method paramNameWithWildcardShouldReturnNonEmptyResults.

@Test
public void paramNameWithWildcardShouldReturnNonEmptyResults() {
    final JobsByParamReport report = new JobsByParamReportImpl();
    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 BuildParameter param = dataset.values().iterator().next().get(0).getParameters().get(0);
    final Map<String, List<BuildDetails>> results = report.getProjectExecutions(param.getName().substring(0) + "%", param.getValue(), TestUtils.NOW, TestUtils.NOW);
    Assert.assertFalse("Unexpected empty results", results.isEmpty());
}
Also used : BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) JobsByParamReportImpl(org.jenkins.plugins.audit2db.internal.reports.JobsByParamReportImpl) List(java.util.List) JobsByParamReport(org.jenkins.plugins.audit2db.reports.JobsByParamReport) Test(org.junit.Test)

Example 55 with BuildDetails

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

the class TestUtils method createRandomBuildDetails.

public static BuildDetails createRandomBuildDetails(final boolean withParams) {
    final long salt = System.nanoTime();
    final BuildDetails build = new BuildDetailsImpl();
    build.setDuration(Long.valueOf(60 + (long) (Math.random() * 60)));
    build.setEndDate(new Date(build.getStartDate().getTime() + (build.getDuration() * 1000)));
    build.setFullName("BUILD FULL NAME " + salt);
    build.setId("BUILD ID " + salt);
    build.setName("BUILD NAME " + salt);
    build.setUserId("BUILD USER ID " + salt);
    build.setUserName("BUILD USER NAME " + salt);
    if (withParams) {
        final List<BuildParameter> params = new ArrayList<BuildParameter>();
        params.add(new BuildParameterImpl("PARAM_ID 1 " + salt, "PARAM NAME 1 " + salt, "PARAM VALUE 1 " + salt, build));
        params.add(new BuildParameterImpl("PARAM_ID 2 " + salt, "PARAM NAME 2 " + salt, "PARAM VALUE 2 " + salt, build));
        build.setParameters(params);
    }
    final BuildNode node = new BuildNodeImpl("NODE ADDRESS", "NODE HOSTNAME", "NODE DISPLAYNAME", "NODE URL", "NODE NAME", "NODE DESCRIPTION", "NODE LABEL");
    build.setNode(node);
    return build;
}
Also used : BuildDetailsImpl(org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl) BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildNodeImpl(org.jenkins.plugins.audit2db.internal.model.BuildNodeImpl) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) ArrayList(java.util.ArrayList) BuildParameterImpl(org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl) Date(java.util.Date) BuildNode(org.jenkins.plugins.audit2db.model.BuildNode)

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