Search in sources :

Example 46 with BuildDetails

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

the class BuildDetailsHibernateRepositoryTests method retrievingOldProjectNamesShouldReturnEmptyList.

@Test
public void retrievingOldProjectNamesShouldReturnEmptyList() {
    final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(hostName);
    // ideally we should persist dataset in a transaction and roll it back
    // at the end of the test
    final TransactionStatus tx = txmgr.getTransaction(null);
    tx.setRollbackOnly();
    for (final List<BuildDetails> detailsList : dataset.values()) {
        repository.saveBuildDetailsList(detailsList);
    }
    final Calendar fromDate = Calendar.getInstance();
    fromDate.add(Calendar.YEAR, -10);
    final Calendar toDate = Calendar.getInstance();
    toDate.add(Calendar.YEAR, -1);
    final List<String> projectNames = repository.getProjectNames(hostName, fromDate.getTime(), toDate.getTime());
    txmgr.rollback(tx);
    Assert.assertNotNull("Unexpected null list of project names", projectNames);
    Assert.assertTrue("Unexpected non-empty list of project names", projectNames.isEmpty());
}
Also used : BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) Calendar(java.util.Calendar) TransactionStatus(org.springframework.transaction.TransactionStatus) List(java.util.List) Test(org.junit.Test)

Example 47 with BuildDetails

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

the class BuildDetailsHibernateRepositoryTests method retrievingAllProjectNamesShouldMatchDataset.

@Test
public void retrievingAllProjectNamesShouldMatchDataset() {
    final Map<String, List<BuildDetails>> dataset = TestUtils.createRandomDataset(hostName);
    // ideally we should persist dataset in a transaction and roll it back
    // at the end of the test
    final TransactionStatus tx = txmgr.getTransaction(null);
    tx.setRollbackOnly();
    for (final List<BuildDetails> detailsList : dataset.values()) {
        repository.saveBuildDetailsList(detailsList);
    }
    final Calendar fromDate = Calendar.getInstance();
    fromDate.add(Calendar.YEAR, -1);
    final Calendar toDate = Calendar.getInstance();
    final List<String> projectNames = repository.getProjectNames(hostName, fromDate.getTime(), toDate.getTime());
    txmgr.rollback(tx);
    Assert.assertNotNull("Unexpected null list of project names", projectNames);
    Assert.assertFalse("Unexpected empty list of project names", projectNames.isEmpty());
    Assert.assertEquals("Unexpected number of project names", dataset.size(), projectNames.size());
}
Also used : BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) Calendar(java.util.Calendar) TransactionStatus(org.springframework.transaction.TransactionStatus) List(java.util.List) Test(org.junit.Test)

Example 48 with BuildDetails

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

the class BuildDetailsImplTests method getBuildDetails.

private BuildDetails getBuildDetails() {
    final BuildDetails build = new BuildDetailsImpl();
    build.setDuration(Long.valueOf(60));
    build.setEndDate(new Date(build.getStartDate().getTime() + (build.getDuration() * 1000)));
    build.setFullName("BUILD FULL NAME");
    build.setId("BUILD ID");
    build.setName("BUILD NAME");
    build.setUserId("BUILD USER ID");
    build.setUserName("BUILD USER NAME");
    final List<BuildParameter> params = new ArrayList<BuildParameter>();
    params.add(new BuildParameterImpl("PARAM_ID", "PARAM NAME", "PARAM VALUE", build));
    build.setParameters(params);
    return build;
}
Also used : BuildDetailsImpl(org.jenkins.plugins.audit2db.internal.model.BuildDetailsImpl) BuildParameter(org.jenkins.plugins.audit2db.model.BuildParameter) BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) ArrayList(java.util.ArrayList) BuildParameterImpl(org.jenkins.plugins.audit2db.internal.model.BuildParameterImpl) Date(java.util.Date)

Example 49 with BuildDetails

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

the class BuildDetailsImplTests method equalsNullShouldBeFalse.

@Test
public void equalsNullShouldBeFalse() {
    final BuildDetails actual = getBuildDetails();
    Assert.assertFalse("Broken inequality logic", actual.equals(null));
}
Also used : BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) Test(org.junit.Test)

Example 50 with BuildDetails

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

the class BuildDetailsImplTests method equalsSomethingElseShouldBeFalse.

@Test
public void equalsSomethingElseShouldBeFalse() {
    final BuildDetails actual = getBuildDetails();
    Assert.assertFalse("Broken inequality logic", actual.equals("SOMESTRING"));
}
Also used : BuildDetails(org.jenkins.plugins.audit2db.model.BuildDetails) 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