use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class JobsByParamReportImpl method getProjectExecutions.
/**
* @see org.jenkins.plugins.audit2db.reports.JobsByParamReport#getProjectExecutions(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public Map<String, List<BuildDetails>> getProjectExecutions(final String paramName, final String paramValue, final String startDateString, final String endDateString) {
final Jenkins jenkins = Jenkins.getInstance();
if (jenkins != null) {
// unit tests won't have a Jenkins instance
jenkins.checkPermission(DbAuditPlugin.RUN);
}
final Map<String, List<BuildDetails>> retval = new HashMap<String, List<BuildDetails>>();
final Date startDate = DbAuditReportUtils.stringToDate(startDateString);
final Date endDate = DbAuditReportUtils.stringToDate(endDateString);
final String jenkinsHost = getJenkinsHostname();
final List<BuildDetails> buildDetails = getRepository().getBuildDetailsByParams(jenkinsHost, paramName, paramValue, startDate, endDate);
for (final BuildDetails details : buildDetails) {
final String projectName = details.getName();
if (!retval.containsKey(projectName)) {
retval.put(projectName, new ArrayList<BuildDetails>());
}
retval.get(projectName).add(details);
}
return retval;
}
use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class Audit2DbExecution method run.
@Override
protected Void run() throws Exception {
StepContext context = getContext();
Run<?, ?> run = context.get(Run.class);
LOGGER.fine("StepContext.Run: " + run);
Properties props = HibernateUtil.getExtraProperties(step.getJdbcDriver(), step.getJdbcUrl(), step.getJdbcUsername(), step.getJdbcPassword());
if (StringUtils.isNotBlank(step.getHibernateDialect())) {
props.put("hibernate.dialect", step.getHibernateDialect());
}
LOGGER.fine("props: " + props);
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(props);
LOGGER.fine("sessionFactory: " + sessionFactory);
BuildDetailsRepository repository = new BuildDetailsHibernateRepository(sessionFactory);
BuildDetails details = BuildDetailsResolver.resolveBuildDetails(run, context.get(Computer.class));
Audit2DbGraphListener listener = new Audit2DbGraphListener(repository, details);
context.get(FlowExecution.class).addListener(listener);
return null;
}
use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method retrievalForMasterAndProjectByMatchingDateRangeShouldReturnNonEmptyList.
@Test
public void retrievalForMasterAndProjectByMatchingDateRangeShouldReturnNonEmptyList() {
final BuildDetails build = TestUtils.createRandomBuildDetails();
final Object buildId = repository.saveBuildDetails(build);
Assert.assertNotNull("Unexpected null build id", buildId);
final List<BuildDetails> builds = repository.getBuildDetails(build.getNode().getMasterHostName(), build.getName(), new Date(0), build.getEndDate());
Assert.assertNotNull("Unexpected null list of builds", builds);
Assert.assertFalse("Unexpected empty list of builds", builds.isEmpty());
Assert.assertEquals("Unexpected number of builds", 1, builds.size());
Assert.assertEquals("Mismatching build details found", build, builds.get(0));
}
use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method retrievalByNonMatchingDateRangeShouldReturnEmptyList.
@Test
public void retrievalByNonMatchingDateRangeShouldReturnEmptyList() {
final BuildDetails build = TestUtils.createRandomBuildDetails();
final Object buildId = repository.saveBuildDetails(build);
Assert.assertNotNull("Unexpected null build id", buildId);
final Calendar start = Calendar.getInstance();
start.set(1914, 6, 28, 9, 0, 0);
final Calendar end = Calendar.getInstance();
end.set(1918, 10, 11, 11, 0, 0);
final List<BuildDetails> builds = repository.getBuildDetailsByDateRange(start.getTime(), end.getTime());
Assert.assertNotNull("Unexpected null list of builds", builds);
Assert.assertTrue("Unexpected non-empty list of builds", builds.isEmpty());
}
use of org.jenkins.plugins.audit2db.model.BuildDetails in project selenium_java by sergueik.
the class BuildDetailsHibernateRepositoryTests method retrievalForMasterByMatchingDateRangeShouldReturnNonEmptyList.
@Test
public void retrievalForMasterByMatchingDateRangeShouldReturnNonEmptyList() {
final BuildDetails build = TestUtils.createRandomBuildDetails();
final Object buildId = repository.saveBuildDetails(build);
Assert.assertNotNull("Unexpected null build id", buildId);
final List<BuildDetails> builds = repository.getBuildDetails(build.getNode().getMasterHostName(), new Date(0), build.getEndDate());
Assert.assertNotNull("Unexpected null list of builds", builds);
Assert.assertFalse("Unexpected empty list of builds", builds.isEmpty());
Assert.assertEquals("Unexpected number of builds", 1, builds.size());
Assert.assertEquals("Mismatching build details found", build, builds.get(0));
}
Aggregations