use of org.jenkins.plugins.audit2db.data.BuildDetailsRepository in project selenium_java by sergueik.
the class WhenSchedulingJob method testParameterisedJobShouldSaveAllParameters.
@Test
public void testParameterisedJobShouldSaveAllParameters() throws Exception {
final FreeStyleProject project = createFreeStyleProject("ParameterisedJob");
// set parameters
final ParameterDefinition param1 = new StringParameterDefinition("myStringParam", "myStringValue", "My String Parameter");
final ParameterDefinition param2 = new BooleanParameterDefinition("myBooleanParam", false, "My Boolean Parameter");
project.addProperty(new ParametersDefinitionProperty(param1, param2));
// enable audit2db plugin
final DbAuditPublisher plugin = getPlugin();
project.getPublishersList().add((Publisher) plugin);
// build now
final Future<FreeStyleBuild> futureBuild = project.scheduleBuild2(0);
final FreeStyleBuild build = futureBuild.get();
Assert.assertNotNull(build);
Assert.assertEquals("Unexpected build result", Result.SUCCESS, build.getResult());
// check data persistence
final BuildDetailsRepository repository = plugin.getRepository();
final BuildDetails actual = repository.getBuildDetailsForBuild(build);
final BuildDetails expected = new BuildDetailsImpl(build);
Assert.assertEquals("Unexpected build details", expected, actual);
Assert.assertNotNull("Unexpected null end date", actual.getEndDate());
Assert.assertTrue("Unexpected duration", actual.getDuration() > 0L);
Assert.assertEquals("Unexpected number of params", 2, actual.getParameters().size());
}
use of org.jenkins.plugins.audit2db.data.BuildDetailsRepository 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.data.BuildDetailsRepository in project selenium_java by sergueik.
the class WhenSchedulingJob method testPlainJobShouldSaveNoParameters.
@Test
public void testPlainJobShouldSaveNoParameters() throws Exception {
final FreeStyleProject project = createFreeStyleProject("PlainJob");
// enable audit2db plugin
final DbAuditPublisher plugin = getPlugin();
project.getPublishersList().add((Publisher) plugin);
// build now
final Future<FreeStyleBuild> futureBuild = project.scheduleBuild2(0);
final FreeStyleBuild build = futureBuild.get();
Assert.assertNotNull(build);
Assert.assertEquals("Unexpected build result", Result.SUCCESS, build.getResult());
// check data persistence
final BuildDetailsRepository repository = plugin.getRepository();
final BuildDetails actual = repository.getBuildDetailsForBuild(build);
final BuildDetails expected = new BuildDetailsImpl(build);
Assert.assertEquals("Unexpected build details", expected, actual);
Assert.assertNotNull("Unexpected null end date", actual.getEndDate());
Assert.assertTrue("Unexpected duration", actual.getDuration() > 0L);
Assert.assertEquals("Unexpected number of params", 0, actual.getParameters().size());
}
Aggregations